aboutsummaryrefslogtreecommitdiff
path: root/src/stringprocbuild.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stringprocbuild.cpp')
-rw-r--r--src/stringprocbuild.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp
new file mode 100644
index 0000000..56eae12
--- /dev/null
+++ b/src/stringprocbuild.cpp
@@ -0,0 +1,52 @@
1#include "stringprocbuild.h"
2#include "build.h"
3
4StringProcBuild::StringProcBuild( Build *pBld ) :
5 StringProc( pBld )
6{
7}
8
9StringProcBuild::~StringProcBuild()
10{
11}
12
13std::string StringProcBuild::replVars( const std::string &sSrc, const std::string &sCont )
14{
15 std::string sDes, sBuf;
16 int nMode = 0;
17
18 int nLen = sSrc.size();
19 for( int j = 0; j < nLen; j++ )
20 {
21 if( sSrc[j] == '{' )
22 {
23 sBuf = "";
24 nMode = 1;
25 }
26 else if( nMode == 0 )
27 {
28 sDes += sSrc[j];
29 }
30 else if( nMode == 1 )
31 {
32 if( sSrc[j] == '}' )
33 {
34 sDes += getBuild()->getVar( sCont, sBuf );
35 nMode = 0;
36 }
37 else
38 {
39 sBuf += sSrc[j];
40 }
41 }
42 }
43
44 if( nMode == 1 )
45 {
46 throw BuildException(
47 "Unterminated variable replacement found: \"%s\"",
48 sSrc.c_str()
49 );
50 }
51}
52