diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2009-12-21 18:03:28 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2009-12-21 18:03:28 +0000 |
| commit | 51e21a316be6e052251b3dfc7d671061ebd67cee (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/functionregexp.cpp | |
| parent | ad6f4dfcc671d3f8d458c42b0992956f2a2cf979 (diff) | |
| download | build-51e21a316be6e052251b3dfc7d671061ebd67cee.tar.gz build-51e21a316be6e052251b3dfc7d671061ebd67cee.tar.bz2 build-51e21a316be6e052251b3dfc7d671061ebd67cee.tar.xz build-51e21a316be6e052251b3dfc7d671061ebd67cee.zip | |
Removed the old trunk contents. About to load up m3
Diffstat (limited to 'src/functionregexp.cpp')
| -rw-r--r-- | src/functionregexp.cpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp deleted file mode 100644 index 2dc18b2..0000000 --- a/src/functionregexp.cpp +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | #include "functionregexp.h" | ||
| 2 | #include "bu/plugger.h" | ||
| 3 | #include "regexp.h" | ||
| 4 | |||
| 5 | PluginInterface2(regexp, FunctionRegexp, Function, "Mike Buland", 0, 1 ); | ||
| 6 | |||
| 7 | FunctionRegexp::FunctionRegexp() | ||
| 8 | { | ||
| 9 | } | ||
| 10 | |||
| 11 | FunctionRegexp::~FunctionRegexp() | ||
| 12 | { | ||
| 13 | } | ||
| 14 | |||
| 15 | void FunctionRegexp::execute( Build *bld, const StringList &lInput, StringList &lOutput ) | ||
| 16 | { | ||
| 17 | if( lParams.size() == 1 ) | ||
| 18 | { | ||
| 19 | RegExp re( lParams.front().c_str() ); | ||
| 20 | |||
| 21 | for( StringList::const_iterator i = lInput.begin(); | ||
| 22 | i != lInput.end(); i++ ) | ||
| 23 | { | ||
| 24 | if( re.execute( (*i).c_str() ) ) | ||
| 25 | { | ||
| 26 | lOutput.push_back( *i ); | ||
| 27 | if( bld ) | ||
| 28 | { | ||
| 29 | int jmax = re.getNumSubStrings(); | ||
| 30 | for( int j = 0; j < jmax; j++ ) | ||
| 31 | { | ||
| 32 | char buf[30]; | ||
| 33 | sprintf( buf, "re:%d", j ); | ||
| 34 | bld->set( *i, buf, re.getSubString( j ) ); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
| 40 | else | ||
| 41 | { | ||
| 42 | if( !bld ) | ||
| 43 | { | ||
| 44 | throw BuildException("You apparently can't use regexp with two params here. Isn't that odd?"); | ||
| 45 | } | ||
| 46 | |||
| 47 | RegExp re( lParams.front().c_str() ); | ||
| 48 | lParams.pop_front(); | ||
| 49 | std::string p2 = lParams.front(); | ||
| 50 | |||
| 51 | for( StringList::const_iterator i = lInput.begin(); | ||
| 52 | i != lInput.end(); i++ ) | ||
| 53 | { | ||
| 54 | if( re.execute( (*i).c_str() ) ) | ||
| 55 | { | ||
| 56 | VarMap ext; | ||
| 57 | int jmax = re.getNumSubStrings(); | ||
| 58 | for( int j = 0; j < jmax; j++ ) | ||
| 59 | { | ||
| 60 | char buf[30]; | ||
| 61 | sprintf( buf, "re:%d", j ); | ||
| 62 | ext[buf] = re.getSubString( j ); | ||
| 63 | } | ||
| 64 | |||
| 65 | std::string sNew = bld->replVars( p2, NULL, &ext ); | ||
| 66 | lOutput.push_back( sNew ); | ||
| 67 | |||
| 68 | for( int j = 0; j < jmax; j++ ) | ||
| 69 | { | ||
| 70 | char buf[30]; | ||
| 71 | sprintf( buf, "re:%d", j ); | ||
| 72 | bld->set( sNew, buf, re.getSubString( j ) ); | ||
| 73 | } | ||
| 74 | bld->copyContext( *i, sNew ); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | Function *FunctionRegexp::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) | ||
| 81 | { | ||
| 82 | Function *pRet = new FunctionRegexp(); | ||
| 83 | pRet->copyData( this, bld, cont, mExtra ); | ||
| 84 | return pRet; | ||
| 85 | } | ||
| 86 | |||
