blob: 071e941539910505d2d1b1d4f0114138753f64ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "stringprocbuild.h"
#include "build.h"
StringProcBuild::StringProcBuild( Build *pBld ) :
StringProc( pBld )
{
}
StringProcBuild::~StringProcBuild()
{
}
std::string StringProcBuild::replVars( const std::string &sSrc, const std::string &sCont, VarMap *mExtra )
{
std::string sDes, sBuf;
int nMode = 0;
int nLen = sSrc.size();
for( int j = 0; j < nLen; j++ )
{
if( sSrc[j] == '{' )
{
sBuf = "";
nMode = 1;
}
else if( nMode == 0 )
{
sDes += sSrc[j];
}
else if( nMode == 1 )
{
if( sSrc[j] == '}' )
{
sDes += getBuild()->getVar( sCont, sBuf, mExtra );
nMode = 0;
}
else
{
sBuf += sSrc[j];
}
}
}
if( nMode == 1 )
{
throw BuildException(
"Unterminated variable replacement found: \"%s\"",
sSrc.c_str()
);
}
return sDes;
}
|