Changeset 6520 for trunk/licq

Show
Ignore:
Timestamp:
09/13/08 22:58:45 (3 months ago)
Author:
flynd
Message:

Added functions for reading and writing std strings to/from configuration files.

Location:
trunk/licq
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/licq/include/licq_file.h

    r6505 r6520  
    4848  bool SetSection(const char *_szSectionName); 
    4949  bool CreateSection(const char *_szSectionName); 
     50 
     51  /** 
     52   * Read a string value from the configuration file 
     53   * 
     54   * @param key Key of value to read 
     55   * @param data String to put value in 
     56   * @param defValue Default value to set if key doesn't exist 
     57   * @param trim True if leading and trailing white spaces should be trimmed 
     58   * @return True if value was found or false if default value was used 
     59   */ 
     60  bool readString(const std::string& key, std::string& data, 
     61      const std::string& defValue = "", bool trim = true); 
     62 
    5063  bool ReadStr(const std::string& Key, char* data, const char* defValue = NULL, bool trim = true, int maxLength = 0); 
    5164  bool ReadNum(const std::string& key, unsigned long &data, unsigned long defValue = 0); 
     
    5770  bool ReadNum(const std::string& key, char &data, char defValue = 0); 
    5871  bool ReadBool(const std::string& key, bool &data, const bool defValue = false); 
     72 
     73  /** 
     74   * Write a string value to the configuration file 
     75   * 
     76   * @param key Key of value to write 
     77   * @param data Value to write 
     78   */ 
     79  void writeString(const std::string& key, const std::string& data); 
    5980 
    6081  bool WriteStr(const std::string& key, const char* data); 
  • trunk/licq/src/file.cpp

    r6504 r6520  
    654654} 
    655655 
     656bool CIniFile::readString(const string& key, string& data, 
     657    const string& defValue, bool trim) 
     658{ 
     659  char buffer[MAX_LINE_LEN]; 
     660  bool ret = ReadStr(key, buffer, defValue.c_str(), trim, MAX_LINE_LEN); 
     661  data = buffer; 
     662  return ret; 
     663} 
    656664 
    657665//-----ReadStr----------------------------------------------------------------- 
     
    686694  return (true); 
    687695} 
    688  
    689696 
    690697//-----ReadNum----------------------------------------------------------------- 
     
    794801} 
    795802 
     803void CIniFile::writeString(const std::string& key, const std::string& data) 
     804{ 
     805  WriteStr(key, data.c_str()); 
     806} 
    796807 
    797808//-----WriteStr----------------------------------------------------------------