Chinaunix首页 | 论坛 | 博客
  • 博客访问: 432807
  • 博文数量: 138
  • 博客积分: 4114
  • 博客等级: 上校
  • 技术积分: 1341
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-14 20:41
文章分类

全部博文(138)

文章存档

2014年(1)

2013年(2)

2012年(78)

2011年(13)

2010年(34)

2009年(10)

我的朋友

分类: LINUX

2010-06-02 16:49:39

今天一个网友让我看一个程序有错误, 就改, 可是设计的实在是混乱, 根本不知道程序在做什么,就自己改啊改, 但是发现自己以前c++最基本的东西都忘记了, 只是知道有这么个东西, 得去看reference,呵呵, 真是不经常用就会手生啊! 脑子里剩下的就是逻辑了, 怎么实现这个逻辑, 脑子里剩下的已经不再是代码了。
后来看看自己项目里的文件读写的实现, 记录之, 这样可能印象会深点


typedef std::map CConfigSection;
class CConfigReader
{
    protected:
       std::string    _filename;
      
       std::map  _sections;
       ConfigSection*    _currentSection;
       ConfigSection::const_inerator   _sectionIter;

       void cleanup();
    public:
       ConfigReader();
       ConfigReader(const std::string &);
   
       virtual  ~CConfigReader();
       bool read();
       bool read(const std::string &);
      
       bool get(const std::string&, const std::string&, zuint32&);
       bool get(const std::string&, const std::string&, zint32 &);
       bool get(const std::string&, const std::string&, long&);
       bool get(const std::string&, const std::string&, float&);
       bool get(const std::string&, const std::string&, std::string&);
     
      bool  gotoSection(const std::string&);
      bool  getNext(std::string&, std::string &);

   public:
      static  const std::string GetLastError();
   protected:
      static std::stringstream _lastError();
};

最精华的就在类的声明中

阅读(677) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~