Changeset 3010


Ignore:
Timestamp:
2002-02-27T11:57:02+13:00 (22 years ago)
Author:
jrm21
Message:

overloaded write_cfg_line() to take a file descriptor as argument instead
of an ofstream.

Location:
trunk/gsdl/lib
Files:
2 edited

Legend:

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

    r1739 r3010  
    7171  return 0;
    7272}
     73// same, but use a file descriptor this time
     74int write_cfg_line (int fileout, const text_tarray &values) {
     75  outconvertclass text_t2ascii;
     76
     77  text_tarray::const_iterator here = values.begin();
     78  text_tarray::const_iterator end = values.end();
     79
     80  bool first = true;
     81  while (here != end) {
     82    if (first) text_t2ascii << *here;
     83    else text_t2ascii << "  \"" << *here << "\"";
     84
     85    size_t buffersize=here->size() + 4; // +4 in case of " and spaces
     86    char *buffer=new char[buffersize];
     87    size_t num_chars;
     88    convertclass::status_t status;
     89    text_t2ascii.convert(buffer, buffersize, num_chars, status);
     90    // ignore status - assume it is "finished" as buffer is big enough
     91    write(fileout, buffer, num_chars);
     92    delete buffer;
     93    first = false;
     94    here ++;
     95  }
     96  write(fileout,"\n",1);
     97  return 0;
     98}
     99
    73100
    74101// returns 0 on success, -1 on failure
  • trunk/gsdl/lib/cfgread.h

    r1421 r3010  
    4343int read_ini_line (ifstream &filein, text_t &key, text_t &value);
    4444int write_cfg_line (ofstream &fileout, const text_tarray &values);
     45int write_cfg_line (int filedesc, const text_tarray &values);
    4546int read_cfg_line (ifstream &filein, text_tarray &values);
    4647
Note: See TracChangeset for help on using the changeset viewer.