diff options
-rw-r--r-- | src/bzip2.cpp | 5 | ||||
-rw-r--r-- | src/csvreader.cpp | 3 | ||||
-rw-r--r-- | src/fbasicstring.h | 16 | ||||
-rw-r--r-- | src/myriad.cpp | 30 | ||||
-rw-r--r-- | src/myriad.h | 3 | ||||
-rw-r--r-- | src/optparser.cpp | 36 | ||||
-rw-r--r-- | src/optparser.h | 28 | ||||
-rw-r--r-- | src/tools/myriad.cpp | 66 | ||||
-rw-r--r-- | src/unitsuite.cpp | 2 | ||||
-rw-r--r-- | src/util.h | 7 | ||||
-rw-r--r-- | src/variant.cpp | 6 | ||||
-rw-r--r-- | src/variant.h | 1 |
12 files changed, 149 insertions, 54 deletions
diff --git a/src/bzip2.cpp b/src/bzip2.cpp index b855fd9..a6fef25 100644 --- a/src/bzip2.cpp +++ b/src/bzip2.cpp | |||
@@ -160,6 +160,11 @@ size_t Bu::BZip2::read( void *pData, size_t nBytes ) | |||
160 | if( bzState.avail_in == 0 ) | 160 | if( bzState.avail_in == 0 ) |
161 | { | 161 | { |
162 | nRead = rNext.read( pBuf, nBufSize ); | 162 | nRead = rNext.read( pBuf, nBufSize ); |
163 | if( nRead == 0 && rNext.isEos() ) | ||
164 | { | ||
165 | throw Bu::ExceptionBase("Premature end of underlying " | ||
166 | "stream found reading bzip2 stream."); | ||
167 | } | ||
163 | bzState.next_in = pBuf; | 168 | bzState.next_in = pBuf; |
164 | bzState.avail_in = nRead; | 169 | bzState.avail_in = nRead; |
165 | } | 170 | } |
diff --git a/src/csvreader.cpp b/src/csvreader.cpp index 08803e7..f3133c2 100644 --- a/src/csvreader.cpp +++ b/src/csvreader.cpp | |||
@@ -56,7 +56,10 @@ Bu::StrArray Bu::CsvReader::readLine() | |||
56 | { | 56 | { |
57 | i++; | 57 | i++; |
58 | if( !i ) | 58 | if( !i ) |
59 | { | ||
60 | aVals.append(""); | ||
59 | break; | 61 | break; |
62 | } | ||
60 | aVals.append( sDecode( i ) ); | 63 | aVals.append( sDecode( i ) ); |
61 | } | 64 | } |
62 | else | 65 | else |
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index bf43502..064ff16 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -1172,7 +1172,7 @@ namespace Bu | |||
1172 | */ | 1172 | */ |
1173 | chr *getStr() | 1173 | chr *getStr() |
1174 | { | 1174 | { |
1175 | if( core->pFirst == NULL ) | 1175 | if( core->pFirst == NULL || core->nLength == 0 ) |
1176 | return (chr *)""; | 1176 | return (chr *)""; |
1177 | 1177 | ||
1178 | flatten(); | 1178 | flatten(); |
@@ -1187,7 +1187,7 @@ namespace Bu | |||
1187 | */ | 1187 | */ |
1188 | const chr *getStr() const | 1188 | const chr *getStr() const |
1189 | { | 1189 | { |
1190 | if( core->pFirst == NULL ) | 1190 | if( core->pFirst == NULL || core->nLength == 0 ) |
1191 | return (chr *)""; | 1191 | return (chr *)""; |
1192 | 1192 | ||
1193 | flatten(); | 1193 | flatten(); |
@@ -1483,7 +1483,7 @@ namespace Bu | |||
1483 | */ | 1483 | */ |
1484 | bool operator==( const chr *pData ) const | 1484 | bool operator==( const chr *pData ) const |
1485 | { | 1485 | { |
1486 | if( core->pFirst == NULL ) { | 1486 | if( core->pFirst == NULL || core->nLength == 0 ) { |
1487 | if( pData == NULL ) | 1487 | if( pData == NULL ) |
1488 | return true; | 1488 | return true; |
1489 | if( pData[0] == (chr)0 ) | 1489 | if( pData[0] == (chr)0 ) |
@@ -1669,9 +1669,11 @@ namespace Bu | |||
1669 | 1669 | ||
1670 | bool compareSub( const chr *pData, long nIndex, long nLen ) const | 1670 | bool compareSub( const chr *pData, long nIndex, long nLen ) const |
1671 | { | 1671 | { |
1672 | if( core->pFirst == NULL ) { | 1672 | if( core->pFirst == NULL || core->nLength == 0 ) { |
1673 | if( pData == NULL ) | 1673 | if( pData == NULL ) |
1674 | return true; | 1674 | return true; |
1675 | if( nLen == 0 ) | ||
1676 | return true; | ||
1675 | if( pData[0] == (chr)0 ) | 1677 | if( pData[0] == (chr)0 ) |
1676 | return true; | 1678 | return true; |
1677 | return false; | 1679 | return false; |
@@ -1696,7 +1698,7 @@ namespace Bu | |||
1696 | 1698 | ||
1697 | bool compareSub( const MyType &rData, long nIndex, long nLen ) const | 1699 | bool compareSub( const MyType &rData, long nIndex, long nLen ) const |
1698 | { | 1700 | { |
1699 | if( core->pFirst == NULL || rData.core->pFirst == NULL ) | 1701 | if( core->pFirst == NULL || core->nLength == 0 || rData.core->pFirst == NULL || rData.core->nLength == 0 ) |
1700 | return false; | 1702 | return false; |
1701 | if( nLen < 0 ) | 1703 | if( nLen < 0 ) |
1702 | nLen = rData.core->nLength; | 1704 | nLen = rData.core->nLength; |
@@ -1945,7 +1947,7 @@ namespace Bu | |||
1945 | 1947 | ||
1946 | void trimBack( chr c ) | 1948 | void trimBack( chr c ) |
1947 | { | 1949 | { |
1948 | if( core->pFirst == NULL ) | 1950 | if( core->pFirst == NULL || core->nLength == 0 ) |
1949 | return; | 1951 | return; |
1950 | flatten(); | 1952 | flatten(); |
1951 | for( ; core->pFirst->nLength > 0 && core->pFirst->pData[core->pFirst->nLength-1] == c; core->pFirst->nLength--, core->nLength-- ) { } | 1953 | for( ; core->pFirst->nLength > 0 && core->pFirst->pData[core->pFirst->nLength-1] == c; core->pFirst->nLength--, core->nLength-- ) { } |
@@ -2041,7 +2043,7 @@ namespace Bu | |||
2041 | if( isFlat() ) | 2043 | if( isFlat() ) |
2042 | return; | 2044 | return; |
2043 | 2045 | ||
2044 | if( core->pFirst == NULL ) | 2046 | if( core->pFirst == NULL || core->nLength == 0 ) |
2045 | return; | 2047 | return; |
2046 | 2048 | ||
2047 | Chunk *pNew = core->newChunk( core->nLength ); | 2049 | Chunk *pNew = core->newChunk( core->nLength ); |
diff --git a/src/myriad.cpp b/src/myriad.cpp index c3eb97e..b656b52 100644 --- a/src/myriad.cpp +++ b/src/myriad.cpp | |||
@@ -510,6 +510,36 @@ int Bu::Myriad::getNumUsedBlocks() | |||
510 | return iUsed; | 510 | return iUsed; |
511 | } | 511 | } |
512 | 512 | ||
513 | int Bu::Myriad::getTotalUsedBytes() | ||
514 | { | ||
515 | int iTotalSize = 0; | ||
516 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | ||
517 | { | ||
518 | iTotalSize += (*i)->iSize; | ||
519 | } | ||
520 | return iTotalSize; | ||
521 | } | ||
522 | |||
523 | int Bu::Myriad::getTotalUnusedBytes() | ||
524 | { | ||
525 | int iTotalSize = (iBlocks-iUsed)*iBlockSize; | ||
526 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | ||
527 | { | ||
528 | iTotalSize += iBlockSize - ((*i)->iSize%iBlockSize); | ||
529 | } | ||
530 | return iTotalSize; | ||
531 | } | ||
532 | |||
533 | int Bu::Myriad::getTotalUnusedBytes( int iFakeBlockSize ) | ||
534 | { | ||
535 | int iTotalSize = (iBlocks-iUsed)*iFakeBlockSize; | ||
536 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | ||
537 | { | ||
538 | iTotalSize += iFakeBlockSize - ((*i)->iSize%iFakeBlockSize); | ||
539 | } | ||
540 | return iTotalSize; | ||
541 | } | ||
542 | |||
513 | Bu::Myriad::Stream *Bu::Myriad::findStream( int iId ) | 543 | Bu::Myriad::Stream *Bu::Myriad::findStream( int iId ) |
514 | { | 544 | { |
515 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 545 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
diff --git a/src/myriad.h b/src/myriad.h index ed0ef53..582d310 100644 --- a/src/myriad.h +++ b/src/myriad.h | |||
@@ -138,6 +138,9 @@ namespace Bu | |||
138 | int getBlockSize(); | 138 | int getBlockSize(); |
139 | int getNumBlocks(); | 139 | int getNumBlocks(); |
140 | int getNumUsedBlocks(); | 140 | int getNumUsedBlocks(); |
141 | int getTotalUsedBytes(); | ||
142 | int getTotalUnusedBytes(); | ||
143 | int getTotalUnusedBytes( int iFakeBlockSize ); | ||
141 | 144 | ||
142 | /** | 145 | /** |
143 | * Syncronize the header data, etc. with the storage stream. It's not | 146 | * Syncronize the header data, etc. with the storage stream. It's not |
diff --git a/src/optparser.cpp b/src/optparser.cpp index 864d8ce..b81691d 100644 --- a/src/optparser.cpp +++ b/src/optparser.cpp | |||
@@ -45,7 +45,11 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
45 | { | 45 | { |
46 | sOpt.set( argv[j]+2 ); | 46 | sOpt.set( argv[j]+2 ); |
47 | } | 47 | } |
48 | try | 48 | if( !hlOption.has( sOpt ) ) |
49 | { | ||
50 | optionError( "--" + sOpt ); | ||
51 | } | ||
52 | else | ||
49 | { | 53 | { |
50 | // Long param, cool, that's easy, first search for = | 54 | // Long param, cool, that's easy, first search for = |
51 | Option *pOpt = hlOption.get( sOpt ); | 55 | Option *pOpt = hlOption.get( sOpt ); |
@@ -71,26 +75,28 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
71 | } | 75 | } |
72 | else if( sExtraParam.isSet() ) | 76 | else if( sExtraParam.isSet() ) |
73 | { | 77 | { |
74 | pOpt->pProxy->setValue( sExtraParam ); | 78 | pOpt->pProxy->setValueFromStr( sExtraParam ); |
75 | } | 79 | } |
76 | else if( argv[j+1] != '\0' ) | 80 | else if( argv[j+1] != '\0' ) |
77 | { | 81 | { |
78 | pOpt->pProxy->setValue( argv[j+1] ); | 82 | pOpt->pProxy->setValueFromStr( argv[j+1] ); |
79 | j++; | 83 | j++; |
80 | } | 84 | } |
81 | } | 85 | } |
82 | } | 86 | } |
83 | catch( Bu::HashException &e ) | ||
84 | { | ||
85 | optionError( "--" + sOpt ); | ||
86 | } | ||
87 | } | 87 | } |
88 | else | 88 | else |
89 | { | 89 | { |
90 | int iCPos; | 90 | int iCPos; |
91 | for( iCPos = 1; argv[j][iCPos] != '\0'; iCPos++ ) | 91 | for( iCPos = 1; argv[j][iCPos] != '\0'; iCPos++ ) |
92 | { | 92 | { |
93 | try | 93 | if( !hsOption.has( argv[j][iCPos] ) ) |
94 | { | ||
95 | Bu::FString sOpt("-"); | ||
96 | sOpt += argv[j][iCPos]; | ||
97 | optionError( sOpt ); | ||
98 | } | ||
99 | else | ||
94 | { | 100 | { |
95 | Option *pOpt = hsOption.get( argv[j][iCPos] ); | 101 | Option *pOpt = hsOption.get( argv[j][iCPos] ); |
96 | char buf[2] = {argv[j][iCPos], '\0'}; | 102 | char buf[2] = {argv[j][iCPos], '\0'}; |
@@ -123,14 +129,14 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
123 | } | 129 | } |
124 | else if( argv[j][iCPos+1] != '\0' ) | 130 | else if( argv[j][iCPos+1] != '\0' ) |
125 | { | 131 | { |
126 | pOpt->pProxy->setValue( | 132 | pOpt->pProxy->setValueFromStr( |
127 | argv[j]+iCPos+1 | 133 | argv[j]+iCPos+1 |
128 | ); | 134 | ); |
129 | break; | 135 | break; |
130 | } | 136 | } |
131 | else if( argv[j+1] ) | 137 | else if( argv[j+1] ) |
132 | { | 138 | { |
133 | pOpt->pProxy->setValue( | 139 | pOpt->pProxy->setValueFromStr( |
134 | argv[j+1] | 140 | argv[j+1] |
135 | ); | 141 | ); |
136 | j++; | 142 | j++; |
@@ -138,12 +144,6 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
138 | } | 144 | } |
139 | } | 145 | } |
140 | } | 146 | } |
141 | catch( Bu::HashException &e ) | ||
142 | { | ||
143 | Bu::FString sOpt("-"); | ||
144 | sOpt += argv[j][iCPos]; | ||
145 | optionError( sOpt ); | ||
146 | } | ||
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
@@ -176,12 +176,12 @@ void Bu::OptParser::addOption( const Option &opt ) | |||
176 | hlOption.insert( opt.sOpt, &lOption.last() ); | 176 | hlOption.insert( opt.sOpt, &lOption.last() ); |
177 | } | 177 | } |
178 | 178 | ||
179 | void Bu::OptParser::setOverride( char cOpt, const Bu::FString &sOverride ) | 179 | void Bu::OptParser::setOverride( char cOpt, const Bu::Variant &sOverride ) |
180 | { | 180 | { |
181 | hsOption.get( cOpt )->sOverride = sOverride; | 181 | hsOption.get( cOpt )->sOverride = sOverride; |
182 | } | 182 | } |
183 | 183 | ||
184 | void Bu::OptParser::setOverride( const Bu::FString &sOpt, const Bu::FString &sOverride ) | 184 | void Bu::OptParser::setOverride( const Bu::FString &sOpt, const Bu::Variant &sOverride ) |
185 | { | 185 | { |
186 | hlOption.get( sOpt )->sOverride = sOverride; | 186 | hlOption.get( sOpt )->sOverride = sOverride; |
187 | } | 187 | } |
diff --git a/src/optparser.h b/src/optparser.h index 2936a4b..7ec69e5 100644 --- a/src/optparser.h +++ b/src/optparser.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "bu/array.h" | 15 | #include "bu/array.h" |
16 | #include "bu/membuf.h" | 16 | #include "bu/membuf.h" |
17 | #include "bu/formatter.h" | 17 | #include "bu/formatter.h" |
18 | #include "bu/variant.h" | ||
18 | 19 | ||
19 | namespace Bu | 20 | namespace Bu |
20 | { | 21 | { |
@@ -40,7 +41,8 @@ namespace Bu | |||
40 | _ValueProxy(); | 41 | _ValueProxy(); |
41 | virtual ~_ValueProxy(); | 42 | virtual ~_ValueProxy(); |
42 | 43 | ||
43 | virtual void setValue( const Bu::FString & )=0; | 44 | virtual void setValueFromStr( const Bu::FString & )=0; |
45 | virtual void setValue( const Bu::Variant &vVar )=0; | ||
44 | virtual _ValueProxy *clone()=0; | 46 | virtual _ValueProxy *clone()=0; |
45 | }; | 47 | }; |
46 | 48 | ||
@@ -57,12 +59,28 @@ namespace Bu | |||
57 | { | 59 | { |
58 | } | 60 | } |
59 | 61 | ||
60 | virtual void setValue( const Bu::FString &sVal ) | 62 | virtual void setValueFromStr( const Bu::FString &sVal ) |
61 | { | 63 | { |
62 | Bu::MemBuf mb( sVal ); | 64 | Bu::MemBuf mb( sVal ); |
63 | Bu::Formatter f( mb ); | 65 | Bu::Formatter f( mb ); |
64 | f >> v; | 66 | f >> v; |
65 | } | 67 | } |
68 | |||
69 | virtual void setValue( const Bu::Variant &vVar ) | ||
70 | { | ||
71 | if( vVar.getType() == typeid(ptype) ) | ||
72 | { | ||
73 | v = vVar.get<ptype>(); | ||
74 | } | ||
75 | else if( vVar.getType() == typeid(Bu::FString) ) | ||
76 | { | ||
77 | setValueFromStr( vVar.get<Bu::FString>() ); | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | setValueFromStr( vVar.toString() ); | ||
82 | } | ||
83 | } | ||
66 | 84 | ||
67 | virtual _ValueProxy *clone() | 85 | virtual _ValueProxy *clone() |
68 | { | 86 | { |
@@ -87,7 +105,7 @@ namespace Bu | |||
87 | Bu::FString sHelp; | 105 | Bu::FString sHelp; |
88 | OptionSignal sUsed; | 106 | OptionSignal sUsed; |
89 | _ValueProxy *pProxy; | 107 | _ValueProxy *pProxy; |
90 | Bu::FString sOverride; | 108 | Bu::Variant sOverride; |
91 | Bu::FString sHelpDefault; | 109 | Bu::FString sHelpDefault; |
92 | }; | 110 | }; |
93 | 111 | ||
@@ -162,9 +180,9 @@ namespace Bu | |||
162 | addOption( sUsed, cOpt, "", sHelp ); | 180 | addOption( sUsed, cOpt, "", sHelp ); |
163 | } | 181 | } |
164 | 182 | ||
165 | void setOverride( char cOpt, const Bu::FString &sOverride ); | 183 | void setOverride( char cOpt, const Bu::Variant &sOverride ); |
166 | void setOverride( const Bu::FString &sOpt, | 184 | void setOverride( const Bu::FString &sOpt, |
167 | const Bu::FString &sOverride ); | 185 | const Bu::Variant &sOverride ); |
168 | 186 | ||
169 | void setHelpDefault( const Bu::FString &sOpt, const Bu::FString &sTxt ); | 187 | void setHelpDefault( const Bu::FString &sOpt, const Bu::FString &sTxt ); |
170 | 188 | ||
diff --git a/src/tools/myriad.cpp b/src/tools/myriad.cpp index 73ceba1..b6e435d 100644 --- a/src/tools/myriad.cpp +++ b/src/tools/myriad.cpp | |||
@@ -22,6 +22,7 @@ enum Mode | |||
22 | modeStreamNew, | 22 | modeStreamNew, |
23 | modeStreamDump, | 23 | modeStreamDump, |
24 | modeStreamPut, | 24 | modeStreamPut, |
25 | modeStreamGet, | ||
25 | 26 | ||
26 | modeNone | 27 | modeNone |
27 | }; | 28 | }; |
@@ -43,9 +44,11 @@ public: | |||
43 | addOption( eMode, 'n', "new", | 44 | addOption( eMode, 'n', "new", |
44 | "Create a new sub-stream in a Myriad file."); | 45 | "Create a new sub-stream in a Myriad file."); |
45 | addOption( eMode, 'd', "dump", | 46 | addOption( eMode, 'd', "dump", |
46 | "Read a stream from a Myriad file."); | 47 | "Display a hexdump of a stream from a Myriad file."); |
48 | addOption( eMode, "get", | ||
49 | "Get a file out of a Myriad stream (use --dst)."); | ||
47 | addOption( eMode, "put", | 50 | addOption( eMode, "put", |
48 | "Put a file into a Myriad stream."); | 51 | "Put a file into a Myriad stream (usr --src)."); |
49 | addHelpOption(); | 52 | addHelpOption(); |
50 | 53 | ||
51 | addHelpBanner("\nGeneral options:"); | 54 | addHelpBanner("\nGeneral options:"); |
@@ -55,12 +58,15 @@ public: | |||
55 | addOption( sFile, 'f', "file", "Set the Myriad filename." ); | 58 | addOption( sFile, 'f', "file", "Set the Myriad filename." ); |
56 | addOption( iStream, 's', "stream", "Substream to work with."); | 59 | addOption( iStream, 's', "stream", "Substream to work with."); |
57 | addOption( sSrc, "src", "Source file for copying into a Myriad file."); | 60 | addOption( sSrc, "src", "Source file for copying into a Myriad file."); |
61 | addOption( sDst, "dst", | ||
62 | "Destination file for copying out of a Myriad file."); | ||
58 | 63 | ||
59 | setOverride( "create", "create" ); | 64 | setOverride( "create", modeCreate ); |
60 | setOverride( "info", "info" ); | 65 | setOverride( "info", modeInfo ); |
61 | setOverride( "new", "new" ); | 66 | setOverride( "new", modeStreamNew ); |
62 | setOverride( "dump", "dump" ); | 67 | setOverride( "dump", modeStreamDump ); |
63 | setOverride( "put", "put" ); | 68 | setOverride( "put", modeStreamPut ); |
69 | setOverride( "get", modeStreamGet ); | ||
64 | 70 | ||
65 | parse( argc, argv ); | 71 | parse( argc, argv ); |
66 | } | 72 | } |
@@ -71,23 +77,12 @@ public: | |||
71 | int iStream; | 77 | int iStream; |
72 | Bu::FString sFile; | 78 | Bu::FString sFile; |
73 | Bu::FString sSrc; | 79 | Bu::FString sSrc; |
80 | Bu::FString sDst; | ||
74 | }; | 81 | }; |
75 | 82 | ||
76 | Bu::Formatter &operator>>( Bu::Formatter &f, Mode &m ) | 83 | Bu::Formatter &operator>>( Bu::Formatter &f, Mode &e ) |
77 | { | 84 | { |
78 | Bu::FString sTok = f.readToken(); | 85 | sio << "Uh oh, the formatter was called..." << sio.nl; |
79 | if( sTok == "create" ) | ||
80 | m = modeCreate; | ||
81 | else if( sTok == "info" ) | ||
82 | m = modeInfo; | ||
83 | else if( sTok == "new" ) | ||
84 | m = modeStreamNew; | ||
85 | else if( sTok == "dump" ) | ||
86 | m = modeStreamDump; | ||
87 | else if( sTok == "put" ) | ||
88 | m = modeStreamPut; | ||
89 | else | ||
90 | m = modeNone; | ||
91 | return f; | 86 | return f; |
92 | } | 87 | } |
93 | 88 | ||
@@ -126,7 +121,10 @@ int main( int argc, char *argv[] ) | |||
126 | << " Blocks used: " << m.getNumUsedBlocks() << " (" | 121 | << " Blocks used: " << m.getNumUsedBlocks() << " (" |
127 | << m.getNumUsedBlocks()*100/m.getNumBlocks() << "%)" | 122 | << m.getNumUsedBlocks()*100/m.getNumBlocks() << "%)" |
128 | << sio.nl | 123 | << sio.nl |
129 | << " Stream count: " << m.getNumStreams() << sio.nl; | 124 | << " Stream count: " << m.getNumStreams() << sio.nl |
125 | << " Used space: " << m.getTotalUsedBytes() << sio.nl | ||
126 | << " Unused space: " << m.getTotalUnusedBytes() << sio.nl | ||
127 | << " % of files: " << (double)(m.getNumBlocks()*m.getBlockSize())/(double)(m.getTotalUsedBytes() + m.getTotalUnusedBytes( 4096 ))*100.0 << sio.nl; | ||
130 | Bu::Array<int> aStreams = m.getStreamIds(); | 128 | Bu::Array<int> aStreams = m.getStreamIds(); |
131 | sio << " Stream info:" << sio.nl; | 129 | sio << " Stream info:" << sio.nl; |
132 | for( Bu::Array<int>::iterator i = aStreams.begin(); i; i++ ) | 130 | for( Bu::Array<int>::iterator i = aStreams.begin(); i; i++ ) |
@@ -220,6 +218,30 @@ int main( int argc, char *argv[] ) | |||
220 | } | 218 | } |
221 | break; | 219 | break; |
222 | 220 | ||
221 | case modeStreamGet: | ||
222 | if( !opts.sFile.isSet() ) | ||
223 | { | ||
224 | sio << "Please specify a file manipulate." << sio.nl; | ||
225 | return 0; | ||
226 | } | ||
227 | else if( !opts.sDst.isSet() ) | ||
228 | { | ||
229 | sio << "Please specify a destination file to write." << sio.nl; | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | File fIn( opts.sFile, File::Write|File::Read ); | ||
234 | Myriad m( fIn ); | ||
235 | MyriadStream sIn = m.openStream( opts.iStream ); | ||
236 | File fOut( opts.sDst, File::Write|File::Create|File::Truncate ); | ||
237 | char buf[1024]; | ||
238 | while( !sIn.isEos() ) | ||
239 | { | ||
240 | fOut.write( buf, sIn.read( buf, 1024 ) ); | ||
241 | } | ||
242 | } | ||
243 | break; | ||
244 | |||
223 | case modeNone: | 245 | case modeNone: |
224 | sio << "Please select a mode, for more info, try --help." | 246 | sio << "Please select a mode, for more info, try --help." |
225 | << sio.nl << sio.nl; | 247 | << sio.nl << sio.nl; |
diff --git a/src/unitsuite.cpp b/src/unitsuite.cpp index 7a20128..ce6d037 100644 --- a/src/unitsuite.cpp +++ b/src/unitsuite.cpp | |||
@@ -40,7 +40,7 @@ int Bu::UnitSuite::run( int argc, char *argv[] ) | |||
40 | p.addOption( Bu::slot( this, &Bu::UnitSuite::onListCases ), 'l', "list", | 40 | p.addOption( Bu::slot( this, &Bu::UnitSuite::onListCases ), 'l', "list", |
41 | "List available test cases." ); | 41 | "List available test cases." ); |
42 | p.addOption( bCleanup, "no-cleanup", "Don't erase temp files."); | 42 | p.addOption( bCleanup, "no-cleanup", "Don't erase temp files."); |
43 | p.setOverride( "no-cleanup", "false" ); | 43 | p.setOverride( "no-cleanup", false ); |
44 | p.addHelpOption(); | 44 | p.addHelpOption(); |
45 | p.parse( argc, argv ); | 45 | p.parse( argc, argv ); |
46 | 46 | ||
@@ -39,6 +39,11 @@ namespace Bu | |||
39 | b = tmp; | 39 | b = tmp; |
40 | } | 40 | } |
41 | 41 | ||
42 | #ifdef WIN32 | ||
43 | #warning: removing min and max win32 macros because of compile conflict | ||
44 | #undef min | ||
45 | #undef max | ||
46 | #endif | ||
42 | /** | 47 | /** |
43 | * Finds the lesser of the two objects, objects passed in must be | 48 | * Finds the lesser of the two objects, objects passed in must be |
44 | * less-than-comparable. | 49 | * less-than-comparable. |
@@ -90,7 +95,7 @@ namespace Bu | |||
90 | { | 95 | { |
91 | return b<a?a:b; | 96 | return b<a?a:b; |
92 | } | 97 | } |
93 | 98 | ||
94 | /** | 99 | /** |
95 | * Given three objects this finds the one between the other two. | 100 | * Given three objects this finds the one between the other two. |
96 | *@param a A value to test. | 101 | *@param a A value to test. |
diff --git a/src/variant.cpp b/src/variant.cpp index a66ec39..a239e0f 100644 --- a/src/variant.cpp +++ b/src/variant.cpp | |||
@@ -34,6 +34,12 @@ Bu::Variant::Variant( const Variant &v ) : | |||
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | Bu::Variant::Variant( const char *t ) : | ||
38 | pCore( NULL ) | ||
39 | { | ||
40 | set( Bu::FString( t ) ); | ||
41 | } | ||
42 | |||
37 | Bu::Variant::~Variant() | 43 | Bu::Variant::~Variant() |
38 | { | 44 | { |
39 | if( pCore ) | 45 | if( pCore ) |
diff --git a/src/variant.h b/src/variant.h index 9819f2c..f659ad2 100644 --- a/src/variant.h +++ b/src/variant.h | |||
@@ -114,6 +114,7 @@ namespace Bu | |||
114 | public: | 114 | public: |
115 | Variant(); | 115 | Variant(); |
116 | Variant( const Variant &v ); | 116 | Variant( const Variant &v ); |
117 | Variant( const char *t ); | ||
117 | template<class t> | 118 | template<class t> |
118 | Variant( const t &v ) : | 119 | Variant( const t &v ) : |
119 | pCore( new VariantType<t>() ) | 120 | pCore( new VariantType<t>() ) |