Changeset 798
- Timestamp:
- 1999-12-06T10:08:28+13:00 (24 years ago)
- Location:
- trunk/gsdl/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/cfgread.cpp
r534 r798 28 28 /* 29 29 $Log$ 30 Revision 1.6 1999/12/05 21:08:28 sjboddie 31 added support for reading and writing windows ini files 32 30 33 Revision 1.5 1999/09/07 04:57:41 sjboddie 31 34 added gpl notice … … 49 52 50 53 #include "cfgread.h" 54 55 void collectioninfo_t::clear () { 56 gsdl_gsdlhome.clear(); 57 gsdl_gdbmhome.clear(); 58 } 59 60 int write_ini_line (ofstream &fileout, const text_t &key, const text_t value) { 61 if (key.empty() || value.empty()) return -1; 62 outconvertclass text_t2ascii; 63 fileout << text_t2ascii << key << "=" << value << "\n"; 64 return 0; 65 } 66 67 int read_ini_line (ifstream &filein, text_t &key, text_t &value) { 68 if (filein.eof()) return -1; 69 70 key.clear(); 71 value.clear(); 72 char c; 73 filein.get(c); 74 75 int foundeq = 0; 76 while (!filein.eof() && c != '\n') { 77 if (!foundeq && c == '=') {foundeq = 1; filein.get(c);} 78 79 if (foundeq) value.push_back(c); 80 else key.push_back(c); 81 filein.get(c); 82 } 83 if (key.empty()) return -1; 84 return 0; 85 } 51 86 52 87 -
trunk/gsdl/lib/cfgread.h
r534 r798 41 41 #endif 42 42 43 struct collectioninfo_t { 44 void clear (); 45 collectioninfo_t () {clear();} 43 46 44 // returns 0 on success, -1 on failure 47 text_t gsdl_gsdlhome; 48 text_t gsdl_gdbmhome; 49 }; 50 51 typedef map<text_t, collectioninfo_t, lttext_t> colinfo_tmap; 52 53 // return 0 on success, -1 on failure 54 int write_ini_line (ofstream &fileout, const text_t &key, const text_t value); 55 int read_ini_line (ifstream &filein, text_t &key, text_t &value); 45 56 int read_cfg_line (ifstream &filein, text_tarray &values); 46 57
Note:
See TracChangeset
for help on using the changeset viewer.