Advertisement
mvolden

example

Dec 29th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. #include <string>
  4. #include <fstream>
  5.  
  6. class TestParse
  7. {
  8. public:
  9.     TestParse()
  10.     {}
  11.    
  12.     bool parseConfigFile(std::string const& filename)
  13.     {
  14.         int i(0);
  15.         std::ifstream is(filename.c_str());
  16.        
  17.         std::string line;
  18.         while(std::getline(is, line))
  19.         {
  20.             // Handle empty lines and comments
  21.             if(line.empty() || line[0] == '#')
  22.             {
  23.                 continue;
  24.             }
  25.            
  26.             if(line[0] == '[')
  27.             {
  28.                 ++i;
  29.                 continue;
  30.             }
  31.             ++i;
  32.         }
  33.     }
  34. };
  35.  
  36.  
  37. int main(int argc, char **argv)
  38. {
  39.     TestParse test;
  40.    
  41.     test.parseConfigFile("/path/to/projectfile/project.kdev4");
  42.     std::cout << "Hello, world!" << std::endl;
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement