Changeset 8727
- Timestamp:
- 2004-12-03T11:21:34+13:00 (19 years ago)
- Location:
- trunk/gsdl/lib
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/cfgread.cpp
r7733 r8727 27 27 #include <ctype.h> // for isspace() 28 28 29 int write_ini_line (ofstream &fileout, const text_t &key, const text_t value) {29 int write_ini_line (ofstream &fileout, const text_t &key, const text_t &value) { 30 30 if (key.empty() || value.empty()) return -1; 31 31 outconvertclass text_t2ascii; … … 67 67 else fileout << text_t2ascii << " \"" << *here << "\""; 68 68 first = false; 69 here ++;69 ++here; 70 70 } 71 71 fileout << "\n"; … … 83 83 char *s=here->getcstr(); 84 84 write(fileout,s ,here->size()); 85 delete s;85 delete []s; 86 86 87 87 ++here; … … 91 91 char *s=here->getcstr(); 92 92 write(fileout,s ,here->size()); 93 delete s;93 delete []s; 94 94 write(fileout, "\"", 1); 95 95 -
trunk/gsdl/lib/cfgread.h
r3010 r8727 40 40 41 41 // return 0 on success, -1 on failure 42 int write_ini_line (ofstream &fileout, const text_t &key, const text_t value);42 int write_ini_line (ofstream &fileout, const text_t &key, const text_t &value); 43 43 int read_ini_line (ifstream &filein, text_t &key, text_t &value); 44 44 int write_cfg_line (ofstream &fileout, const text_tarray &values); -
trunk/gsdl/lib/cnfgable.cpp
r1860 r8727 13 13 #include "cfgread.h" 14 14 15 bool configurable::read_configfile ( text_tfilename) {15 bool configurable::read_configfile (const text_t &filename) { 16 16 // read in the build configuration file 17 17 text_t key; … … 19 19 char *cstr = filename.getcstr(); 20 20 ifstream confin (cstr); 21 delete cstr;21 delete []cstr; 22 22 23 23 if (confin) { -
trunk/gsdl/lib/cnfgable.h
r1860 r8727 9 9 virtual ~configurable () {} 10 10 11 bool read_configfile ( text_tfilename);11 bool read_configfile (const text_t &filename); 12 12 protected: 13 13 configurable() {} -
trunk/gsdl/lib/cnfgator.cpp
r1860 r8727 20 20 } 21 21 22 bool configurator::configure( text_tfilename) {22 bool configurator::configure(const text_t &filename) { 23 23 // read in the build configuration file 24 24 text_t key; … … 26 26 char *cstr = filename.getcstr(); 27 27 ifstream confin (cstr); 28 delete cstr;28 delete []cstr; 29 29 30 30 if (confin) { … … 40 40 while (configureIter != configureobjs.end()) { 41 41 configureObject = *configureIter; 42 configureIter ++;42 ++configureIter; 43 43 44 44 configureObject->configure (key, cfgline); -
trunk/gsdl/lib/cnfgator.h
r1896 r8727 14 14 public: 15 15 configurator(configurable *configureobject); 16 bool configure( text_tfilename);16 bool configure(const text_t &filename); 17 17 void add_configurable(configurable *configureobject); 18 18 }; -
trunk/gsdl/lib/display.cpp
r8485 r8727 131 131 // a Global macro will still be hid by a non-Global one with 132 132 // the same name. 133 if ((package != "Global") &&134 (macro_find ( "Global", macroname) != NULL))133 if ((package != displayclass::defaultpackage) && 134 (macro_find (displayclass::defaultpackage, macroname) != NULL)) 135 135 { 136 136 warning -= 2; // found the macroname … … 355 355 { 356 356 // found the end of the parameter 357 here++;357 ++here; 358 358 break; 359 359 } … … 368 368 } 369 369 370 here++;370 ++here; 371 371 } 372 372 … … 422 422 } 423 423 424 here++;424 ++here; 425 425 } 426 426 … … 460 460 { 461 461 // found the end of the key 462 here ++;462 ++here; 463 463 break; 464 464 } … … 472 472 key.push_back (*here); // copy this character 473 473 } 474 here ++;474 ++here; 475 475 } 476 476 … … 487 487 { 488 488 // found the end of the value 489 here ++;489 ++here; 490 490 break; 491 491 } … … 499 499 value.push_back (*here); // copy this character 500 500 } 501 here ++;501 ++here; 502 502 } 503 503 … … 546 546 } 547 547 548 inline int my_isalphanum (unsigned short c) 549 { 550 return ((c >= 'A' && c <= 'Z') || 551 (c >= 'a' && c <= 'z') || (c >='0' && c <= '9')); 552 } 553 548 554 549 555 … … 553 559 if (here != end) 554 560 { 555 here++;561 ++here; 556 562 if (here != end) return (*here); 557 563 } … … 604 610 // -3 if it redefined a macro and hid a Global macro 605 611 // -4 if no macroname was supplied 606 int displayclass::setdefaultmacro ( text_tpackage, const text_t ¯oname,607 text_tmparams, const text_t ¯ovalue)612 int displayclass::setdefaultmacro (const text_t &package, const text_t ¯oname, 613 const text_t &mparams, const text_t ¯ovalue) 608 614 { 609 615 return setdefaultmacro (package, macroname, mparams, "memory", macrovalue); … … 683 689 } 684 690 685 if (c == '\n') line++;691 if (c == '\n') ++line; 686 692 return c; 687 693 } … … 693 699 // 1 if was (re)loaded 694 700 // -1 an error occurred while trying to load the file 695 int displayclass::loadparammacros (parammacros_t* macrotable, text_tthisfilename) {701 int displayclass::loadparammacros (parammacros_t* macrotable, const text_t &thisfilename) { 696 702 // convert the filename to a C string 697 703 char *filenamestr = thisfilename.getcstr(); … … 706 712 if (fin.fail()) return -1; // read failed 707 713 708 text_t package = "Global";714 text_t package = defaultpackage; 709 715 int line = 1; 710 716 int isunicode = 0, bigendian = 1; … … 747 753 // get the package name 748 754 tmp.clear(); // init tmp 749 while (!fin.eof() && my_isalpha (c)) {755 while (!fin.eof() && my_isalphanum(c)) { 750 756 tmp.push_back(c); 751 757 c = my_uni_get(fin, line, isunicode, bigendian); 752 758 } 753 759 package = tmp; 754 if (package.empty()) package = "Global";760 if (package.empty()) package = defaultpackage; 755 761 756 762 } else { 757 763 // error 758 764 if (logout != NULL) { 759 (*logout) << text_t2ascii << "Expected 'package' on line " << line 760 << " of " << thisfilename << "\n"; 765 (*logout) << text_t2ascii << text_t("Expected 'package' on line ") + line + text_t(" of ") + thisfilename + "\n"; 761 766 } 762 767 } … … 842 847 thisfilename, macrovalue); 843 848 if ((err == -1 || err == -3) && logout != NULL) { 844 (*logout) << text_t2ascii << "Warning: redefinition of _" << 845 package << ":" << macroname << "_[" << macroparameters << 846 "] on line "; 847 (*logout) << line; 848 (*logout) << text_t2ascii << " of " << thisfilename << "\n"; 849 (*logout) << text_t2ascii << ("Warning: redefinition of _" + package + ":" + macroname + "_[" + macroparameters + "] on line " + line + " of " + thisfilename + "\n"); 849 850 850 851 } else if (err == -2 && logout != NULL) { … … 860 861 861 862 } else if (err == -4 && logout != NULL) { 862 (*logout) << text_t2ascii << "Error: macro name expected on line "; 863 (*logout) << line ; 864 (*logout) << text_t2ascii << " of " << thisfilename << "\n"; 863 (*logout) << text_t2ascii << text_t("Error: macro name expected on line ") + line + text_t(" of ") + thisfilename + "\n"; 865 864 } 866 865 … … 874 873 // found an error, skip to the end of the line 875 874 if (logout != NULL) { 876 (*logout) << text_t2ascii << "Error: "; 877 if (err == 1) (*logout) << text_t2ascii << "'_'"; 878 else if (err == 2) (*logout) << text_t2ascii << "']'"; 879 else if (err == 3) (*logout) << text_t2ascii << "'}'"; 880 else if (err == 4) (*logout) << text_t2ascii << "'{'"; 881 (*logout) << text_t2ascii << " expected on line "; 882 (*logout) << line ; 883 (*logout) << text_t2ascii << " of " << thisfilename << "\n"; 875 text_t message = "Error: "; 876 if (err == 1) message += "'_'"; 877 else if (err == 2) message += "']'"; 878 else if (err == 3) message += "'}'"; 879 else if (err == 4) message += "'{'"; 880 message += " expected on line "; 881 message += line; 882 message += " of " + thisfilename + "\n"; 883 (*logout) << text_t2ascii << message; 884 885 // (*logout) << text_t2ascii << "Error: "; 886 // if (err == 1) (*logout) << text_t2ascii << "'_'"; 887 // else if (err == 2) (*logout) << text_t2ascii << "']'"; 888 // else if (err == 3) (*logout) << text_t2ascii << "'}'"; 889 // else if (err == 4) (*logout) << text_t2ascii << "'{'"; 890 // (*logout) << text_t2ascii << " expected on line "; 891 // (*logout) << line ; 892 // (*logout) << text_t2ascii << " of " << thisfilename << "\n"; 884 893 } 885 894 while (!fin.eof ()) { … … 892 901 // found an error, skip to the end of the line 893 902 if (logout != NULL) { 894 (*logout) << text_t2ascii << "Error: Unexpected input on line " << line 895 << " of " << thisfilename << "\n"; 903 (*logout) << text_t2ascii << text_t("Error: Unexpected input on line ") + line + text_t(" of ") + thisfilename + "\n"; 896 904 } 897 905 while (!fin.eof ()) { … … 906 914 907 915 // free up memory 908 delete filenamestr;916 delete []filenamestr; 909 917 return 0; 910 918 } … … 915 923 // 1 if was (re)loaded 916 924 // -1 an error occurred while trying to load the file 917 int displayclass::loaddefaultmacros ( text_tthisfilename)925 int displayclass::loaddefaultmacros (const text_t &thisfilename) 918 926 { 919 927 return loadparammacros(defaultmacros,thisfilename); … … 924 932 // 1 if was (re)loaded 925 933 // -1 an error occurred while trying to load the file 926 int displayclass::loadcollectionmacros ( text_tthisfilename)934 int displayclass::loadcollectionmacros (const text_t &thisfilename) 927 935 { 928 936 return loadparammacros(collectionmacros,thisfilename); … … 975 983 for (text_tsetit=allparams.begin(); 976 984 text_tsetit!=allparams.end(); 977 text_tsetit++)985 ++text_tsetit) 978 986 { 979 987 tmpps.param = (*text_tsetit); … … 998 1006 cerr << text_t2ascii << "param=" << (*pshere).param; 999 1007 cerr << " spec=" << (int)((*pshere).spec) << "\n"; 1000 pshere++;1008 ++pshere; 1001 1009 } 1002 1010 #endif … … 1009 1017 // -4 if no macroname was supplied 1010 1018 int displayclass::setmacro (const text_t ¯oname, 1011 text_tpackage,1019 const text_t &package, 1012 1020 const text_t ¯ovalue) 1013 1021 { … … 1016 1024 1017 1025 // make package "Global" if it doesn't point to anything yet 1018 if (package.empty()) package = "Global"; 1019 1026 if (package.empty()) 1027 return currentmacros->setmacro(defaultpackage, macroname, "memory", macrovalue); 1028 1020 1029 // set the macro 1021 1030 return currentmacros->setmacro(package, macroname, "memory", macrovalue); 1022 1031 } 1023 1032 1024 1025 void displayclass::expandstring (const text_t &inputtext, text_t &outputtext) 1026 { 1027 expandstring("", inputtext, outputtext); 1028 } 1029 1030 1031 void displayclass::expandstring (text_t package, const text_t &inputtext, 1033 int displayclass::setmacroif (const text_t ¯o_to_set_and_test, 1034 const text_t ¯o_to_set_if_macro_not_set, 1035 const text_t ¯oname, 1036 const text_t &package) { 1037 1038 if (macroname.empty()) return -4; 1039 if (macro_to_set_and_test.empty()) return -40; 1040 1041 text_t temp; 1042 expandstring(defaultpackage, macro_to_set_and_test, temp); 1043 1044 if (package.empty()) { 1045 if (temp == macro_to_set_and_test) return currentmacros->setmacro(defaultpackage, macroname, "memory", macro_to_set_if_macro_not_set); 1046 return currentmacros->setmacro(defaultpackage, macroname, "memory", macro_to_set_and_test); 1047 } else { 1048 if (temp == macro_to_set_and_test) return currentmacros->setmacro(package, macroname, "memory", macro_to_set_if_macro_not_set); 1049 return currentmacros->setmacro(package, macroname, "memory", macro_to_set_and_test); 1050 1051 } 1052 } 1053 1054 void displayclass::expandstring (const text_t &package, const text_t &inputtext, 1032 1055 text_t &outputtext, int recursiondepth) 1033 1056 { … … 1038 1061 int openbrackets=0; 1039 1062 1040 if (package.empty()) package = "Global";1063 if (package.empty()) expandstring(defaultpackage, inputtext, outputtext, recursiondepth); 1041 1064 1042 1065 outputtext.clear(); … … 1111 1134 { 1112 1135 c = my_ttnextchar (tthere, ttend); // skip '(' 1113 openbrackets++;1136 ++openbrackets; 1114 1137 // have to be careful of quotes 1115 1138 unsigned short quote = '\0'; … … 1129 1152 if (c == '(') 1130 1153 { 1131 openbrackets++;1154 ++openbrackets; 1132 1155 //// macroargs.push_back (c); 1133 1156 //// c = my_ttnextchar (tthere, ttend); … … 1135 1158 else if (c == ')') 1136 1159 { 1137 openbrackets--;1160 --openbrackets; 1138 1161 if (openbrackets==0) { 1139 1162 // found end of the arguments … … 1171 1194 // try to expand out this macro 1172 1195 text_t expandedmacro; 1173 if (macro (macroname, macropackage , macroargs, expandedmacro, recursiondepth))1196 if (macro (macroname, macropackage.empty()?defaultpackage:macropackage, macroargs, expandedmacro, recursiondepth)) 1174 1197 { 1175 1198 // append the expanded macro … … 1231 1254 // in the global package was found 1232 1255 // 2 if a macro in the given package was found 1233 int displayclass::isdefaultmacro ( text_tpackage, const text_t ¯oname) {1256 int displayclass::isdefaultmacro (const text_t &package, const text_t ¯oname) { 1234 1257 // make sure a macroname was supplied 1235 1258 if (macroname.empty()) return 0; 1236 1259 1260 if (!package.empty()) { 1261 // check the given package 1262 if (defaultmacros->macro_find(package, macroname) != NULL) return 2; 1263 } 1264 1265 // check the Global package 1266 if (defaultmacros->macro_find(defaultpackage, macroname) != NULL) return 1; 1267 // not found 1268 return 0; 1269 } 1270 1271 // havemacro sees if there is an entry in the list of macros or 1272 // default macros with the given package and macro name 1273 // returns 0 if no macros in the package or in the global package 1274 // were found 1275 // 1 if no macros in the package were found but a macro 1276 // in the global package was found 1277 // 2 if a macro in the given package was found 1278 // 4 if no macros in the package were found but a macro 1279 // in the global package was found in default macros 1280 // 8 if a macro in the given package was found in default 1281 int displayclass::havemacro(const text_t &package, const text_t ¯oname) 1282 { 1283 // make sure a macroname was supplied 1284 if (macroname.empty()) return 0; 1285 1237 1286 // make package "Global" if it doesn't point to anything yet 1238 if (package.empty()) package = "Global"; 1239 1240 // check the given package 1241 if (defaultmacros->macro_find(package, macroname) != NULL) return 2; 1242 1243 // check the Global package 1244 if (defaultmacros->macro_find("Global", macroname) != NULL) return 1; 1245 1246 return 0; 1247 } 1248 1249 1287 if (package.empty()) { 1288 // check the Global package in current macros list 1289 if (currentmacros->macro_find(defaultpackage, macroname) != NULL) return 1; 1290 1291 // check the Global package in default macros list 1292 if (defaultmacros->macro_find(defaultpackage, macroname) != NULL) return 4; 1293 } else { 1294 // check the given package in current macros list 1295 if (currentmacros->macro_find(package, macroname) != NULL) return 2; 1296 1297 // check the Global package in current macros list 1298 if (currentmacros->macro_find(defaultpackage, macroname) != NULL) return 1; 1299 1300 // check the given package in default macros list 1301 if (defaultmacros->macro_find(package, macroname) != NULL) return 8; 1302 1303 // check the Global package in default macros list 1304 if (defaultmacros->macro_find(defaultpackage, macroname) != NULL) return 4; 1305 } 1306 } 1307 1308 1250 1309 // setparammacro adds an entry to the list of default macros 1251 1310 // returns 0 if there was no error, … … 1255 1314 // -4 if no macroname was supplied 1256 1315 int displayclass::setparammacro (parammacros_t* macrotable, 1257 text_t package, const text_t ¯oname, 1258 text_t macroparams, const text_t &filename, 1316 const text_t &package, 1317 const text_t ¯oname, 1318 text_t macroparams, 1319 const text_t &filename, 1259 1320 const text_t ¯ovalue) 1260 1321 { … … 1268 1329 joinparams (paramhash, macroparams); 1269 1330 1270 // make package "Global" if it doesn't point to anything yet1271 if (package.empty()) package = "Global";1272 1273 1331 // remember these parameters 1274 1332 allparams.insert (macroparams); … … 1277 1335 1278 1336 // set the macro 1279 return macrotable->setmacro(package, macroname, macroparams, filename, 1280 macrovalue); 1337 if (package.empty()) { 1338 return macrotable->setmacro(defaultpackage, macroname, macroparams, filename, macrovalue); 1339 } else { 1340 return macrotable->setmacro(package, macroname, macroparams, filename, macrovalue); 1341 } 1281 1342 } 1282 1343 … … 1287 1348 // -3 if it redefined a macro and hid a Global macro 1288 1349 // -4 if no macroname was supplied 1289 int displayclass::setdefaultmacro (text_t package, const text_t ¯oname, 1290 text_t macroparams, const text_t &filename, 1350 int displayclass::setdefaultmacro (const text_t &package, 1351 const text_t ¯oname, 1352 text_t macroparams, 1353 const text_t &filename, 1291 1354 const text_t ¯ovalue) 1292 1355 { 1293 return setparammacro(defaultmacros,package,macroname, macroparams,1294 filename,macrovalue);1356 return setparammacro(defaultmacros,package,macroname, 1357 macroparams,filename,macrovalue); 1295 1358 } 1296 1359 1297 1360 // public function 1298 int displayclass::setcollectionmacro(text_t package, const text_t ¯oname, 1299 text_t mparams, const text_t ¯ovalue) 1361 int displayclass::setcollectionmacro(const text_t &package, 1362 const text_t ¯oname, 1363 text_t mparams, 1364 const text_t ¯ovalue) 1300 1365 { 1301 1366 return setcollectionmacro(package, macroname, mparams, "memory", macrovalue); … … 1308 1373 // -3 if it redefined a macro and hid a Global macro 1309 1374 // -4 if no macroname was supplied 1310 int displayclass::setcollectionmacro (text_t package, const text_t ¯oname, 1311 text_t mparams, const text_t &filename, 1375 int displayclass::setcollectionmacro (const text_t &package, 1376 const text_t ¯oname, 1377 text_t mparams, 1378 const text_t &filename, 1312 1379 const text_t ¯ovalue) 1313 1380 { … … 1322 1389 // format "XXXX" eq/ne "dddd" in which case 1323 1390 // the two quoted strings are compared 1324 bool displayclass::boolexpr ( text_tpackage, const text_t &expr, int recursiondepth) {1391 bool displayclass::boolexpr (const text_t &package, const text_t &expr, int recursiondepth) { 1325 1392 1326 1393 if (expr.empty()) return false; 1327 1394 1328 1395 text_t expexpr; 1329 if (package.empty()) package = "Global"; 1330 expandstring (package, expr, expexpr, recursiondepth); 1331 1396 if (package.empty()) { 1397 expandstring (defaultpackage, expr, expexpr, recursiondepth); 1398 } else { 1399 expandstring (package, expr, expexpr, recursiondepth); 1400 } 1332 1401 if (expexpr.empty() || expexpr == "0") return false; 1333 1402 if (expr[0] != '\"') return true; … … 1354 1423 op.clear(); 1355 1424 while (here != end) { 1356 if (*here == '"') quotecount++;1425 if (*here == '"') ++quotecount; 1357 1426 else if (quotecount == 1) string1.push_back(*here); 1358 1427 else if ((quotecount == 2) && !is_unicode_space (*here)) … … 1360 1429 else if (quotecount == 3) string2.push_back(*here); 1361 1430 else if (quotecount >= 4) break; 1362 here ++;1431 ++here; 1363 1432 } 1364 1433 … … 1390 1459 while (here != end && *here != '"') { 1391 1460 if (!is_unicode_space(*here)) combineop.push_back(*here); 1392 here++;1461 ++here; 1393 1462 } 1394 1463 } … … 1398 1467 1399 1468 1400 mvalue* displayclass::macro_find (parammacros_t* macrotable, text_t packagename, 1469 mvalue* displayclass::macro_find (parammacros_t* macrotable, 1470 const text_t &packagename, 1401 1471 const text_t ¯oname) 1402 1472 { … … 1413 1483 macrovalue = macrotable->parameter_find(packagename, macroname, 1414 1484 (*paramhere).param); 1415 paramhere++;1485 ++paramhere; 1416 1486 } 1417 1487 } … … 1424 1494 // returns true if the macro was found 1425 1495 // false if the macro was not found 1426 bool displayclass::macro (const text_t ¯oname, text_t macropackage, 1427 const text_t ¯oparam, text_t &outputtext, 1428 int recursiondepth) 1429 { 1430 outconvertclass text_t2ascii; 1496 // macropackage should never be empty 1497 bool displayclass::macro (const text_t ¯oname, 1498 const text_t ¯opackage, 1499 const text_t ¯oparam, 1500 text_t &outputtext, 1501 int recursiondepth) 1502 { 1503 assert(!macropackage.empty()); //??? 1504 //outconvertclass text_t2ascii; 1431 1505 text_tlist splitmacroparam; 1432 1506 text_t::const_iterator hereit, endit; … … 1444 1518 1445 1519 // check the macropackage 1446 if (macropackage.empty()) macropackage = "Global";1520 //if (macropackage.empty()) macropackage = "Global"; 1447 1521 1448 1522 // get the parameters (but don't expand them) … … 1487 1561 } else if (c=='(') { 1488 1562 aparam.push_back(c); 1489 openbrackets++;1563 ++openbrackets; 1490 1564 } else if (c==')') { 1491 openbrackets--;1565 --openbrackets; 1492 1566 aparam.push_back(c); 1493 1567 } else { … … 1514 1588 if (paramcond != paramend) { 1515 1589 paramthen = paramcond; 1516 paramthen++;1590 ++paramthen; 1517 1591 } 1518 1592 if (paramthen != paramend) { 1519 1593 paramelse = paramthen; 1520 paramelse++;1594 ++paramelse; 1521 1595 } 1522 1596 … … 1584 1658 } 1585 1659 1586 if (macrovalue == NULL) packagehere++;1660 if (macrovalue == NULL) ++packagehere; 1587 1661 } 1588 1662 … … 1626 1700 text_tlist::iterator ttlistend = splitmacroparam.end(); 1627 1701 while ((argnum > 1) && (ttlisthere != ttlistend)) { 1628 argnum--;1629 ttlisthere++;1702 --argnum; 1703 ++ttlisthere; 1630 1704 } 1631 1705 if (ttlisthere != ttlistend) { … … 1664 1738 // GRB: deal with remaining code properly as it faults 1665 1739 return false; 1666 1740 outconvertclass text_t2ascii; 1667 1741 if (logout != NULL) { 1668 1742 (*logout) << text_t2ascii << "Warning: _" << … … 1686 1760 for (packagemapit = defaultmacros->package_begin(); 1687 1761 packagemapit != defaultmacros->package_end(); 1688 packagemapit++)1762 ++packagemapit) 1689 1763 { 1690 1764 packagename = (*packagemapit).first; … … 1693 1767 for (macromapit = (*packagemapit).second.begin(); 1694 1768 macromapit != (*packagemapit).second.end(); 1695 macromapit++)1769 ++macromapit) 1696 1770 { 1697 1771 macroname = (*macromapit).first; … … 1700 1774 for (parammapit = (*macromapit).second.begin(); 1701 1775 parammapit != (*macromapit).second.end(); 1702 parammapit++)1776 ++parammapit) 1703 1777 { 1704 1778 macroparam = (*parammapit).first; … … 1722 1796 for (text_tsetit=allparams.begin(); 1723 1797 text_tsetit!=allparams.end(); 1724 text_tsetit++) {1798 ++text_tsetit) { 1725 1799 cerr << text_t2ascii << (*text_tsetit) << "\n"; 1726 1800 } -
trunk/gsdl/lib/display.h
r8485 r8727 178 178 // in the global package was found 179 179 // 2 if a macro in the given package was found 180 int isdefaultmacro ( text_tpackage, const text_t ¯oname);180 int isdefaultmacro (const text_t &package, const text_t ¯oname); 181 181 182 182 // setdefaultmacro adds an entry to the list of default macros … … 186 186 // -3 if it redefined a macro and hid a Global macro 187 187 // -4 if no macroname was supplied 188 int setdefaultmacro (text_t package, const text_t ¯oname, 189 text_t params, const text_t ¯ovalue); 188 int setdefaultmacro (const text_t &package, 189 const text_t ¯oname, 190 const text_t ¶ms, 191 const text_t ¯ovalue); 190 192 191 193 // loads a default macro file (if it isn't already loaded) … … 193 195 // 1 if was (re)loaded 194 196 // -1 an error occurred while trying to load the file 195 int loaddefaultmacros ( text_tthisfilename);197 int loaddefaultmacros (const text_t &thisfilename); 196 198 197 199 … … 200 202 // -1 if it redefined a macro 201 203 // -4 if no macroname was supplied 202 int setcollectionmacro (text_t package, const text_t ¯oname, 203 text_t params, const text_t ¯ovalue); 204 int setcollectionmacro (const text_t &package, 205 const text_t ¯oname, 206 text_t params, 207 const text_t ¯ovalue); 204 208 205 209 // loads a collection specific macro file … … 207 211 // 1 if was (re)loaded 208 212 // -1 an error occurred while trying to load the file 209 int loadcollectionmacros ( text_tthisfilename);213 int loadcollectionmacros (const text_t &thisfilename); 210 214 211 215 // unloads all default macros … … 230 234 // -4 if no macroname was supplied 231 235 int setmacro (const text_t ¯oname, 232 text_tpackage,236 const text_t &package, 233 237 const text_t ¯ovalue); 234 238 235 void expandstring (const text_t &inputtext, text_t &outputtext); 236 void expandstring (text_t package, const text_t &inputtext, 239 // havemacro sees if there is an entry in the list of macros or 240 // default macros with the given package and macro name 241 // returns 0 if no macros in the package or in the global package 242 // were found 243 // 1 if no macros in the package were found but a macro 244 // in the global package was found 245 // 2 if a macro in the given package was found 246 // 4 if no macros in the package were found but a macro 247 // in the global package was found in default macros 248 // 8 if a macro in the given package was found in default 249 int havemacro(const text_t &package, const text_t ¯oname); 250 251 int setmacroif (const text_t ¯o_to_set_and_test, 252 const text_t ¯o_to_set_if_macro_not_set, 253 const text_t ¯oname, 254 const text_t& package); 255 256 inline void expandstring (const text_t &inputtext, text_t &outputtext) { expandstring(defaultpackage, inputtext, outputtext); } 257 258 void expandstring (const text_t &package, const text_t &inputtext, 237 259 text_t &outputtext, int recursiondepth = 0); 238 260 … … 275 297 int checkdefaultmacrofiles (); 276 298 277 int loadparammacros (parammacros_t* macrotable, text_tthisfilename);299 int loadparammacros (parammacros_t* macrotable, const text_t &thisfilename); 278 300 279 301 int setparammacro (parammacros_t* macrotable, 280 text_t package, const text_t ¯oname, 302 const text_t &package, 303 const text_t ¯oname, 281 304 text_t params, const text_t &filename, 282 305 const text_t ¯ovalue); 283 306 284 int setdefaultmacro (text_t package, const text_t ¯oname, 307 int setdefaultmacro (const text_t &package, 308 const text_t ¯oname, 285 309 text_t params, const text_t &filename, 286 310 const text_t ¯ovalue); 287 311 288 int setcollectionmacro (text_t package, const text_t ¯oname, 289 text_t params, const text_t &filename, 290 const text_t ¯ovalue); 291 312 int setcollectionmacro(const text_t &package, 313 const text_t ¯oname, 314 text_t params, 315 const text_t &filename, 316 const text_t ¯ovalue); 317 292 318 // evaluates a boolean expression 293 bool boolexpr (text_t package, const text_t &expr, int recursiondepth); 294 295 mvalue* macro_find (parammacros_t* macrotable, text_t packagename, 319 bool boolexpr (const text_t &package, const text_t &expr, 320 int recursiondepth); 321 322 mvalue* macro_find (parammacros_t* macrotable, 323 const text_t &packagename, 296 324 const text_t ¯oname); 297 325 … … 299 327 // returns true if the macro was found 300 328 // false if the macro was not found 301 bool macro (const text_t ¯oname, text_t macropackage, 329 bool macro (const text_t ¯oname, 330 const text_t ¯opackage, 302 331 const text_t ¯oparam, text_t &outputtext, 303 332 int recursiondepth); -
trunk/gsdl/lib/fileutil.cpp
r3527 r8727 49 49 // remove all trailing slashes 50 50 here = path1.end(); 51 here--;51 --here; 52 52 begin = path1.begin(); 53 53 while (here != begin && (*here == '/' || *here == '\\')) { 54 here--;54 --here; 55 55 } 56 here++;56 ++here; 57 57 path1.erase(here,path1.end()); 58 58 … … 69 69 end = path2.end(); 70 70 while (here != end && (*here == '/' || *here == '\\')) { 71 here++;71 ++here; 72 72 } 73 73 path2.erase (path2.begin(), here); … … 84 84 if (*here == '\\') *here = '/'; 85 85 #endif 86 here ++;86 ++here ; 87 87 } 88 88 return fullpath; … … 116 116 ifstream filestream (cstr, ios::in); 117 117 #endif 118 delete cstr;118 delete []cstr; 119 119 120 120 if (filestream) { … … 136 136 ifstream filestream (cstr, ios::out); 137 137 #endif 138 delete cstr;138 delete []cstr; 139 139 140 140 if (filestream) { … … 162 162 hSearch = FindFirstFile(dirpath, &FileData); 163 163 if (hSearch == INVALID_HANDLE_VALUE) { 164 delete dirpath;164 delete []dirpath; 165 165 return false; 166 166 } 167 167 168 168 FindClose (hSearch); 169 delete dirpath;169 delete []dirpath; 170 170 return true; 171 171 } … … 181 181 hSearch = FindFirstFile(dirpath, &FileData); 182 182 if (hSearch == INVALID_HANDLE_VALUE) { 183 delete dirpath;183 delete []dirpath; 184 184 return false; 185 185 } … … 197 197 198 198 FindClose(hSearch); 199 delete dirpath;199 delete []dirpath; 200 200 201 201 return true; … … 212 212 hSearch = FindFirstFile(dirpath, &FileData); 213 213 if (hSearch == INVALID_HANDLE_VALUE) { 214 delete dirpath;214 delete []dirpath; 215 215 return false; 216 216 } … … 228 228 229 229 FindClose(hSearch); 230 delete dirpath;230 delete []dirpath; 231 231 232 232 return true; … … 241 241 char *tmp = dirname.getcstr(); 242 242 DIR *dirin = opendir (tmp); 243 delete tmp;243 delete []tmp; 244 244 245 245 if (dirin == NULL) return false; … … 252 252 char *tmp = dirname.getcstr(); 253 253 DIR *dirin = opendir (tmp); 254 delete tmp;254 delete []tmp; 255 255 256 256 if (dirin == NULL) return false; … … 273 273 char *tmp = dirname.getcstr(); 274 274 DIR *dirin = opendir (tmp); 275 delete tmp;275 delete []tmp; 276 276 277 277 if (dirin == NULL) return false; … … 321 321 #endif 322 322 323 delete fromfilec;324 delete tofilec;323 delete []fromfilec; 324 delete []tofilec; 325 325 if (fail) return false; 326 326 return true; … … 353 353 char linec[MAXLINELENGTH]; 354 354 ifstream file_in (filenamec); 355 delete filenamec;355 delete []filenamec; 356 356 if (file_in) { 357 357 file_in.seekg (0, ios::end); … … 371 371 break; 372 372 } 373 here ++;373 ++here; 374 374 } 375 375 } … … 395 395 char *dirnamec = dirname.getcstr(); 396 396 int rv = _mkdir (dirnamec); 397 delete dirnamec;397 delete []dirnamec; 398 398 if (rv == 0) return true; 399 399 return false; … … 411 411 char *dirnamec = dirname.getcstr(); 412 412 int rv = mkdir (dirnamec, mode); 413 delete dirnamec;413 delete []dirnamec; 414 414 if (rv == 0) return true; 415 415 return false; … … 429 429 ifstream file_in (filenamec, ios::in); 430 430 #endif 431 delete filenamec;431 delete []filenamec; 432 432 433 433 if (file_in) { -
trunk/gsdl/lib/gsdlconf.h
r3155 r8727 29 29 30 30 #define GSDL_VERSION "x.xx" 31 32 #if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_) || defined(WIN32) 33 #ifndef __WIN32__ 34 #define __WIN32__ 1 35 #endif 36 #endif 31 37 32 38 #if defined(__WIN32__) && !defined(__CYGWIN__) -
trunk/gsdl/lib/gsdltimes.cpp
r3516 r8727 35 35 tm *tm_ptr = localtime(&time); 36 36 37 if (tm_ptr == NULL) return "";37 if (tm_ptr == NULL) return g_EmptyText; 38 38 39 39 // year … … 142 142 if (ltime) tm_ptr = localtime (&t); 143 143 else tm_ptr = gmtime (&t); 144 if (tm_ptr == NULL) return "";144 if (tm_ptr == NULL) return g_EmptyText; 145 145 char *timestr = new char[128]; 146 146 text_t ret; -
trunk/gsdl/lib/gsdltools.cpp
r2937 r8727 53 53 } 54 54 55 void dm_js_safe(const text_t &instring, text_t &outstring) 56 { 57 text_t::const_iterator here = instring.begin(); 58 text_t::const_iterator end = instring.end(); 59 while (here != end) { 60 if (*here == '_') outstring.push_back('\\'); 61 else if (*here == '\\' || *here == '\'') { 62 outstring.push_back('\\'); 63 outstring.push_back('\\'); 64 } 65 outstring.push_back(*here); 66 ++here; 67 } 68 } 69 55 70 // gsdl_system creates a new process for the cmd command (which 56 71 // may contain arguments). … … 95 110 logout << "gsdl_system failed to start " << cmd_c 96 111 << " process, error code " << GetLastError(); 97 delete cmd_c;112 delete []cmd_c; 98 113 return -1; 99 114 } … … 118 133 logout << "gsdl_system failed to start " << cmd_c 119 134 << " process, command interpreter not found\n"; 120 delete cmd_c;135 delete []cmd_c; 121 136 return -1; 122 137 } … … 126 141 int pid = fork(); 127 142 if (pid == -1) { 128 delete cmd_c;143 delete []cmd_c; 129 144 return -1; 130 145 } … … 141 156 #endif 142 157 143 delete cmd_c;158 delete []cmd_c; 144 159 return ret; 145 160 } -
trunk/gsdl/lib/gsdltools.h
r1817 r8727 42 42 text_t dm_safe (const text_t &instring); 43 43 44 // escapes "\", "'" and "_" characters with '\' 45 // note that single '\' characters occurring 46 // naturally within text (or filenames!!) will 47 // be removed by the dm macro language 48 //WARNING: instring will be appended to outstring 49 // so is your responsability to clean the outstring 50 // before call this function; 51 void dm_js_safe(const text_t &instring, text_t &outstring); 52 inline text_t dm_js_safe (const text_t &instring) {text_t outstring; dm_js_safe(instring, outstring); return outstring;} 53 44 54 // gsdl_system creates a new process for the cmd command (which 45 55 // may contain arguments). -
trunk/gsdl/lib/gsdlunicode.cpp
r8666 r8727 57 57 while (here != end) { 58 58 charlen = output_utf8_char (*here, thischar, &thischar[MAXUTF8CHARLEN-1]); 59 for (i=0; i<charlen; i++) out.push_back(thischar[i]);60 here++;59 for (i=0; i<charlen; ++i) out.push_back(thischar[i]); 60 ++here; 61 61 } 62 62 … … 76 76 77 77 // get the last valid character in the string 78 while (*end != '\0') end++;79 end--;78 while (*end != '\0') ++end; 79 --end; 80 80 81 81 while ((charlen = parse_utf8_char (here, end, &unichar)) > 0) { … … 84 84 } 85 85 86 delete in_cstr;86 delete []in_cstr; 87 87 88 88 return out; … … 101 101 text_t::iterator textend = input->end(); 102 102 len = 0; 103 if (maxlen % 2) maxlen--; // we need an even number of output bytes...103 if (maxlen % 2) --maxlen; // we need an even number of output bytes... 104 104 while ((len < maxlen) && (texthere != textend)) { 105 105 unsigned short int uni_char=(unsigned short int) *texthere; … … 183 183 int i; 184 184 int diff = utf8buflen - realcharlen; 185 for (i=0; i < diff; i++) utf8buf[i] = utf8buf[i+diff];185 for (i=0; i < diff; ++i) utf8buf[i] = utf8buf[i+diff]; 186 186 utf8buflen = diff; 187 187 charlen = getutf8charlen (); … … 244 244 while (len < maxlen && utf8bufhere < utf8buflen) { 245 245 *uoutput = utf8buf[utf8bufhere]; 246 uoutput++;247 len++;248 utf8bufhere++;246 ++uoutput; 247 ++len; 248 ++utf8bufhere; 249 249 } 250 250 … … 261 261 utf8buflen = output_utf8_char (*texthere, utf8buf, 262 262 &utf8buf[MAXUTF8CHARLEN-1]); 263 texthere++;263 ++texthere; 264 264 utf8bufhere = 0; 265 265 } … … 276 276 277 277 mapdata_t::mapdata_t () { 278 int i;279 278 280 279 // reset all the map ptrs to be NULL 281 for (i =0; i<256; i++) {280 for (int i=0; i<256; ++i) { 282 281 ptrs[i] = (unsigned short *)NULL; 283 282 } … … 323 322 if (cfilename == (char *)NULL) return false; 324 323 mapfilein = fopen(cfilename, "rb"); 325 delete cfilename;324 delete []cfilename; cfilename = NULL; 326 325 327 326 if (mapfilein == (FILE *)NULL) return false; … … 339 338 340 339 // clear the array 341 for (i=0; i<256; i++) arrptr[i] = 0;340 for (i=0; i<256; ++i) arrptr[i] = 0; 342 341 343 342 // read in this block … … 348 347 arrptr[i] = ((unsigned short)n1 << 8) | (unsigned short)n2; 349 348 350 i++;349 ++i; 351 350 if (i >= 256) break; 352 351 n1 = fgetc (mapfilein); … … 365 364 if (!mapdata.loaded) return; 366 365 367 int i; 368 for (i=0; i<256; i++) { 366 for (int i=0; i<256; ++i) { 369 367 if (mapdata.ptrs[i] != (unsigned short *)NULL) { 370 368 delete [] mapdata.ptrs[i]; … … 405 403 while (here != end) { 406 404 outstr.push_back(this->convert(*here)); 407 here++;405 ++here; 408 406 } 409 407 … … 517 515 while (len < maxlen && mapbufhere < mapbuflen) { 518 516 *uoutput = mapbuf[mapbufhere]; 519 uoutput++;520 len++;521 mapbufhere++;517 ++uoutput; 518 ++len; 519 ++mapbufhere; 522 520 } 523 521 … … 548 546 } 549 547 550 texthere++;548 ++texthere; 551 549 mapbufhere = 0; 552 550 } … … 568 566 ifstream mapfilein (cfilename, ios::in); 569 567 #endif 570 delete cfilename;568 delete []cfilename; 571 569 if (!mapfilein) return false; 572 570 … … 601 599 sscanf (from, "%i", &f); 602 600 sscanf (to, "%i", &t); 603 delete from;604 delete to;601 delete []from; 602 delete []to; 605 603 606 604 if (in) mapping[(unsigned short)f] = (unsigned short)t; -
trunk/gsdl/lib/text_t.cpp
r7382 r8727 28 28 /* 29 29 $Log$ 30 Revision 1.23 2004/12/02 22:21:34 kjdon 31 added some changes made by Emanuel Dejanu (Simple Words) 32 30 33 Revision 1.22 2004/05/24 03:43:22 mdewsnip 31 34 (Human Info) Added const text_t g_EmptyText("") to use instead of plain ol' "". … … 123 126 124 127 // new stream converter ... 125 ostream& operator<< (ostream &o, const text_t text)128 ostream& operator<< (ostream &o, const text_t &text) 126 129 { 127 130 text_t::const_iterator ithere = text.begin(); … … 144 147 o << '?'; 145 148 } 146 ithere++;149 ++ithere; 147 150 } 148 151 … … 163 166 } 164 167 165 text_t::text_t (c har *s)168 text_t::text_t (const char *s) 166 169 { 167 170 setencoding(0); … … 170 173 } 171 174 175 text_t::text_t (const char *s, size_type nLength) 176 { 177 setencoding(0); 178 clear (); 179 appendcarr(s, nLength); 180 } 181 172 182 173 183 void text_t::append (const text_t &t) 174 184 { 175 185 text.insert(text.end(), t.begin(), t.end()); 176 // const_iterator here, end=t.end();177 // for (here=t.begin(); here!=end;here++)178 // {179 // text.push_back(*here);180 // }181 186 } 182 187 … … 184 189 { 185 190 text.insert(text.end(), first, last); 186 // while (first != last)187 // {188 // text.push_back (*first);189 // first++;190 // }191 191 } 192 192 … … 194 194 { 195 195 text.insert(text.end(), first, last); 196 // while (first != last)197 // {198 // text.push_back (*first);199 // first++;200 // }201 196 } 202 197 … … 233 228 } 234 229 235 delete buf;230 delete []buf; 236 231 } 237 232 … … 255 250 { 256 251 mult = 1; 257 here++;252 ++here; 258 253 } 259 254 } … … 263 258 { 264 259 i = 10*i + (*here - '0'); 265 here++;260 ++here; 266 261 } 267 262 … … 280 275 { 281 276 i = 10*i + (*here - '0'); 282 here++;277 ++here; 283 278 } 284 279 … … 286 281 } 287 282 288 void text_t::appendcarr (c har *s, size_type len)283 void text_t::appendcarr (const char *s, size_type len) 289 284 { 290 285 unsigned char *us = (unsigned char *)s; 286 if (text.capacity() < (text.size() + len + 2)) { 287 text.reserve(text.size() + len + 2); 288 } 289 291 290 while (len > 0) 292 291 { 293 292 text.push_back (*us); // append this character 294 us++; 295 len--; 296 } 297 } 298 299 void text_t::appendcstr (char *s) 300 { 293 ++us; 294 --len; 295 } 296 } 297 298 void text_t::appendcstr (const char *s) 299 { 300 size_t len = strlen(s); 301 if (text.capacity() < (text.size() + len + 2)) { 302 text.reserve(text.size() + len + 2); 303 } 304 301 305 unsigned char *us = (unsigned char *)s; 302 306 while (*us != '\0') 303 307 { 304 308 text.push_back (*us); // append this character 305 us++;309 ++us; 306 310 } 307 311 } … … 309 313 310 314 // strings returned from getcarr and getcstr become the callers 311 // responsibility and should be deallocated with "delete "315 // responsibility and should be deallocated with "delete []" 312 316 313 317 char *text_t::getcarr(size_type &len) const … … 328 332 else cstr[len] = '?'; 329 333 } 330 len++;331 ithere++;334 ++len; 335 ++ithere; 332 336 } 333 337 … … 352 356 else cstr[len] = '?'; 353 357 } 354 len++;355 ithere++;358 ++len; 359 ++ithere; 356 360 } 357 361 … … 371 375 { 372 376 if (*first == c) break; 373 first++;377 ++first; 374 378 } 375 379 return first; … … 382 386 { 383 387 if (*first == c) break; 384 first++;388 ++first; 385 389 } 386 390 return first; 387 391 } 388 392 389 text_t::iterator findword (text_t::iterator first, text_t::iterator last, 393 text_t::iterator findword (text_t::iterator first, 394 text_t::iterator last, 390 395 const text_t& word) 391 396 { … … 403 408 break; 404 409 } 405 char_match++;406 word_here++;410 ++char_match; 411 ++word_here; 407 412 } 408 413 if (word_here==word_end) … … 410 415 return first; 411 416 } 412 first++;417 ++first; 413 418 } 414 419 return last; // get to here only if there is no match … … 424 429 outstr.clear(); 425 430 outstr.appendrange (first, here); 426 if (here != last) here++; // skip c431 if (here != last) ++here; // skip c 427 432 return here; 428 433 } … … 435 440 outstr.clear(); 436 441 outstr.appendrange (first, here); 437 if (here != last) here++; // skip c442 if (here != last) ++here; // skip c 438 443 return here; 439 444 } … … 489 494 text_tset::const_iterator here = inlist.begin (); 490 495 text_tset::const_iterator end = inlist.end (); 491 bool first = true; 492 while (here != end)493 {494 if (!first) outtext.push_back (c);495 first = false;496 497 if (here != end) { 498 outtext += *here; ++here; 499 while (here != end) { 500 outtext.push_back (c); 496 501 outtext += *here; 497 here++; 498 } 502 ++here; 503 } 504 } 499 505 } 500 506 … … 505 511 text_tlist::const_iterator here = inlist.begin (); 506 512 text_tlist::const_iterator end = inlist.end (); 507 bool first = true; 508 while (here != end) 509 { 510 if (!first) outtext.push_back (c); 511 first = false; 513 if (here != end) { 514 outtext += *here; ++here; 515 while (here != end) { 516 outtext.push_back (c); 512 517 outtext += *here; 513 here++; 514 } 518 ++here; 519 } 520 } 515 521 } 516 522 … … 521 527 text_tarray::const_iterator here = inlist.begin (); 522 528 text_tarray::const_iterator end = inlist.end (); 523 bool first = true; 524 while (here != end) 525 { 526 if (!first) outtext.push_back (c); 527 first = false; 529 if (here != end) { 530 outtext += *here; ++here; 531 while (here != end) { 532 outtext.push_back (c); 528 533 outtext += *here; 529 here++; 530 } 531 } 532 533 void joinchar (const text_tlist &inlist, text_t c, text_t &outtext) 534 ++here; 535 } 536 } 537 } 538 539 void joinchar (const text_tlist &inlist, const text_t &c, text_t &outtext) 534 540 { 535 541 outtext.clear (); … … 537 543 text_tlist::const_iterator here = inlist.begin (); 538 544 text_tlist::const_iterator end = inlist.end (); 539 bool first = true; 540 while (here != end) 541 { 542 if (!first) outtext += c; 543 first = false; 545 if (here != end) { 546 outtext += *here; ++here; 547 while (here != end) { 548 outtext += c; 544 549 outtext += *here; 545 here++; 546 } 547 } 548 549 void joinchar (const text_tset &inlist, text_t c, text_t &outtext) 550 ++here; 551 } 552 } 553 } 554 555 void joinchar (const text_tset &inlist, const text_t &c, text_t &outtext) 550 556 { 551 557 outtext.clear (); … … 553 559 text_tset::const_iterator here = inlist.begin (); 554 560 text_tset::const_iterator end = inlist.end (); 555 bool first = true; 556 while (here != end) 557 { 558 if (!first) outtext += c; 559 first = false; 561 if (here != end) { 562 outtext += *here; ++here; 563 while (here != end) { 564 outtext += c; 560 565 outtext += *here; 561 here++; 562 } 563 } 564 565 void joinchar (const text_tarray &inlist, text_t c, text_t &outtext) 566 ++here; 567 } 568 } 569 } 570 571 void joinchar (const text_tarray &inlist, const text_t &c, text_t &outtext) 566 572 { 567 573 outtext.clear (); … … 569 575 text_tarray::const_iterator here = inlist.begin (); 570 576 text_tarray::const_iterator end = inlist.end (); 571 bool first = true; 572 while (here != end) 573 { 574 if (!first) outtext += c; 575 first = false; 577 if (here != end) { 578 outtext += *here; ++here; 579 while (here != end) { 580 outtext += c; 576 581 outtext += *here; 577 here++; 578 } 582 ++here; 583 } 584 } 579 585 } 580 586 … … 594 600 text_t substr (text_t::const_iterator first, text_t::const_iterator last) { 595 601 596 text_t substr; 602 text_t substr; substr.reserve(last - first + 2); 597 603 while (first != last) { 598 604 substr.push_back(*first); 599 first ++;605 ++first; 600 606 } 601 607 return substr; … … 607 613 while (first != last) { 608 614 *first = unicode_tolower(*first); 609 first++;615 ++first; 610 616 } 611 617 } … … 615 621 while (first != last) { 616 622 *first = unicode_toupper(*first); 617 first++;623 ++first; 618 624 } 619 625 } … … 631 637 (*here!='6') && (*here!='7') && (*here!='8') && 632 638 (*here!='9')) return false; 633 here ++;639 ++here; 634 640 } 635 641 return true; … … 645 651 while (here != end) { 646 652 if (is_unicode_letdig (*here)) return true; 647 here++;653 ++here; 648 654 } 649 655 … … 708 714 } 709 715 716 if (output.capacity() < len + 2) 717 output.reserve(len + 2); 718 710 719 // don't want any funny sign conversions happening 711 720 unsigned char *here = (unsigned char *)start; … … 732 741 size_t cbuflen = 0; 733 742 743 out.clear(); 744 if (out.capacity() < t.size() + 2) 745 out.reserve(t.size() + 2); 734 746 while (here != end) { 735 747 while (here != end && cbuflen < 256) { 736 748 cbuf[cbuflen++] = (unsigned char)(*here & 0xff); 737 here++;749 ++here; 738 750 } 739 751 … … 792 804 } 793 805 806 void outconvertclass::setdata(text_t *theinput, text_t::iterator thetexthere) 807 { 808 input = theinput; 809 texthere = thetexthere; 810 } 811 794 812 void outconvertclass::convert (char *output, size_t maxlen, 795 813 size_t &len, status_t &status) … … 832 850 size_t cbuflen = 0; 833 851 status_t status = unfinished; 834 852 853 out.clear(); 854 if (out.capacity() < t.size() + 2) 855 out.reserve(t.size() + 2); 835 856 setinput ((text_t *)&t); // discard constant 836 857 while (status == unfinished) { -
trunk/gsdl/lib/text_t.h
r7396 r8727 59 59 60 60 // class prototypes 61 class text_t; 61 62 class inconvertclass; 62 63 class outconvertclass; … … 70 71 71 72 typedef vector<unsigned short> usvector; 73 extern const text_t g_EmptyText; 72 74 73 75 // The class text_t can handle long strings which may contain … … 94 96 text_t (); 95 97 text_t (int i); 96 text_t (c har *s); // assumed to be a normal c string97 98 text_t (const char *s); // assumed to be a normal c string 99 text_t (const char *s, size_type nLength); // support for arrays of chars 98 100 void setencoding (unsigned short theencoding) {encoding=theencoding;}; 99 101 unsigned short getencoding () {return encoding;}; … … 117 119 118 120 void reserve (size_type n) {text.reserve(n);} 121 size_type capacity() const { return text.capacity(); } 119 122 120 123 bool empty () const {return text.empty();} … … 151 154 152 155 // support for arrays of chars 153 void appendcarr (c har *s, size_type len);156 void appendcarr (const char *s, size_type len); 154 157 void setcarr (char *s, size_type len) {clear();appendcarr(s,len);} 155 158 156 // support for null-terminated C strings 157 void appendcstr (char *s); 158 void setcstr (char *s) {clear();appendcstr(s);} 159 text_t &operator= (char *s) {setcstr(s);return *this;} // c string 160 text_t &operator+= (char *s) {appendcstr(s);return *this;} // c string 161 162 // support for const null-terminated C string 163 void appendcstr (const char *s) {appendcstr((char *)s);} 164 void setcstr (const char *s) {clear();appendcstr((char *) s);} 165 text_t &operator= (const char *s) {setcstr((char *) s);return *this;} // c string 166 text_t &operator+= (const char *s) {appendcstr((char *) s);return *this;} // c string 159 // support for const null-terminated C strings 160 void appendcstr (const char *s); 161 void setcstr (const char *s) {clear();appendcstr(s);} 162 text_t &operator= (const char *s) {setcstr(s);return *this;} // c string 163 text_t &operator+= (const char *s) {appendcstr(s);return *this;} // c string 167 164 168 165 // strings returned from getcarr and getcstr become the callers 169 // responsibility and should be deallocated with "delete "166 // responsibility and should be deallocated with "delete []" 170 167 char *getcarr(size_type &len) const; 171 168 char *getcstr() const; … … 174 171 175 172 // new stream converter ... 176 ostream& operator<< (ostream &o, const text_t text);173 ostream& operator<< (ostream &o, const text_t &text); 177 174 178 175 inline text_t operator+(const text_t &t1, const text_t &t2) … … 250 247 void joinchar (const text_tlist &inlist, unsigned short c, text_t &outtext); 251 248 void joinchar (const text_tarray &inlist, unsigned short c, text_t &outtext); 252 void joinchar (const text_tset &inlist, text_tc, text_t &outtext);253 void joinchar (const text_tlist &inlist, text_tc, text_t &outtext);254 void joinchar (const text_tarray &inlist, text_tc, text_t &outtext);249 void joinchar (const text_tset &inlist, const text_t &c, text_t &outtext); 250 void joinchar (const text_tlist &inlist, const text_t &c, text_t &outtext); 251 void joinchar (const text_tarray &inlist, const text_t &c, text_t &outtext); 255 252 256 253 // count the occurances of a character within a range … … 338 335 public: 339 336 outconvertclass (); 340 void reset (); 341 void setinput (text_t *theinput); 337 virtual void reset (); 338 virtual void setinput (text_t *theinput); 339 virtual void setdata(text_t *input, text_t::iterator texthere); 342 340 // note that convert does not null-terminate the 343 341 // output array of characters … … 350 348 text_t convert (const text_t &t); 351 349 352 v oid setostream (ostream *theouts);350 virtual void setostream (ostream *theouts); 353 351 ostream *getostream (); 354 352 … … 370 368 outconvertclass &operator<< (outconvertclass &outconverter, const text_t &t); 371 369 372 extern const text_t g_EmptyText; 373 374 #endif 370 371 #endif
Note:
See TracChangeset
for help on using the changeset viewer.