Changeset 798


Ignore:
Timestamp:
1999-12-06T10:08:28+13:00 (24 years ago)
Author:
sjboddie
Message:

added support for reading and writing windows ini files

Location:
trunk/gsdl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/cfgread.cpp

    r534 r798  
    2828/*
    2929   $Log$
     30   Revision 1.6  1999/12/05 21:08:28  sjboddie
     31   added support for reading and writing windows ini files
     32
    3033   Revision 1.5  1999/09/07 04:57:41  sjboddie
    3134   added gpl notice
     
    4952
    5053#include "cfgread.h"
     54
     55void collectioninfo_t::clear () {
     56  gsdl_gsdlhome.clear();
     57  gsdl_gdbmhome.clear();
     58}
     59
     60int 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
     67int 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}
    5186
    5287
  • trunk/gsdl/lib/cfgread.h

    r534 r798  
    4141#endif
    4242
     43struct collectioninfo_t {
     44  void clear ();
     45  collectioninfo_t () {clear();}
    4346
    44 // returns 0 on success, -1 on failure
     47  text_t gsdl_gsdlhome;
     48  text_t gsdl_gdbmhome;
     49};
     50
     51typedef map<text_t, collectioninfo_t, lttext_t> colinfo_tmap;
     52
     53// return 0 on success, -1 on failure
     54int write_ini_line (ofstream &fileout, const text_t &key, const text_t value);
     55int read_ini_line (ifstream &filein, text_t &key, text_t &value);
    4556int read_cfg_line (ifstream &filein, text_tarray &values);
    4657
Note: See TracChangeset for help on using the changeset viewer.