www.pudn.com > xml2db.rar > chash.h


/**
 *@file chash.h
 *@brief Chash的定义文件
 *
 *Chash是一个工具类,用来分析key=value格式的配置文件,或数据文件
 *Author: cuichao@boco.com.cn \n
 *ChangeLog: \n
 *Create time: 14-09-05 11:12 take from msimq
 */

#ifndef CHASH_H_
#define CHASH_H_

class CHash
{ 
  private:
    std::map m_map;
    std::string m_errstr;    
               
  public:
    typedef std::map::iterator iterator;    
    typedef std::map::const_iterator const_iterator;
    CHash();
    const std::string GetError() const;
    std::string & operator[](const std::string & key);
    const std::string & operator[](const std::string & key) const;
    int InsertAItemFromStr(const std::string & str);   
    int InsertItemsFromFile(const char * fn);
    bool empty() const;       
    const std::string ExportStr(char sp='\n') const;    
    
    iterator find(const std::string & key);
    iterator end();
    iterator begin();
    
    const_iterator find(const std::string & key) const;
    const_iterator end() const;
    const_iterator begin() const;
    CHash(const CHash &);
    const CHash & operator=(const CHash &);
    virtual ~CHash();
    
};

extern std::ostream& operator<<(std::ostream&, const CHash&);

#endif //CHASH_H_