File: ini_parser_test.cpp

package info (click to toggle)
xboxdrv 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,252 kB
  • sloc: cpp: 19,297; xml: 3,202; ansic: 507; python: 483; sh: 89; makefile: 34; ruby: 19
file content (50 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <sstream>

#include "ini_parser.hpp"
#include "ini_builder.hpp"

class INIParserTestBuilder : public INIBuilder
{
public:
  void send_section(const std::string& section) 
  {
    std::cout << "[" << section << "]" << std::endl;
  }

  void send_pair(const std::string& name, const std::string& value) 
  {
    std::cout << "\"" << name << "\" = \"" << value << "\"" << std::endl;
  }
};

int main()
try
{
  std::istringstream in(
    "[test]\n"
    "name = value1 # comment\n"
    "name = value2\n"
    "  name   =    value3   \n"
    "name#foo = value#foo # comment\n"
    "\n"
    "   name#foo     = value#foo # comment\n"
    "   name#foo     =        value#foo          # comment\n"
    "  name#empty \n"
    "  name#empty =\n"
    "\"name#not-empty\" = \"value#foo\" # comment\n"
    "  foo    bar     =       oing    # foo"
    );

  INIParserTestBuilder builder;
  INIParser parser(in, builder, "test");
  parser.run();

  return 0;
}
catch(const std::exception& err)
{
  std::cout << "exception: " << err.what() << std::endl;
}

/* EOF */