mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
The section name is now also the literal section name rather than to_s called on the parsed scope selector or glob (which wouldn’t necessarily give the source value).
42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
#ifndef INI_PARSER_H_LJ9XOMJG
|
|
#define INI_PARSER_H_LJ9XOMJG
|
|
|
|
struct ini_file_t
|
|
{
|
|
struct section_t
|
|
{
|
|
section_t (std::vector<std::string> const& names) : names(names) { }
|
|
|
|
struct value_t
|
|
{
|
|
value_t (std::string const& name, std::string const& value, size_t lineNumber) : name(name), value(value), line_number(lineNumber) { }
|
|
std::string name, value;
|
|
size_t line_number;
|
|
};
|
|
|
|
std::vector<std::string> names;
|
|
std::vector<value_t> values;
|
|
};
|
|
|
|
ini_file_t (std::string const& path) : path(path) { }
|
|
|
|
void new_section (std::vector<std::string> const& names)
|
|
{
|
|
sections.emplace_back(names);
|
|
}
|
|
|
|
void insert_value (std::string const& name, std::string const& value, size_t lineNumber)
|
|
{
|
|
if(sections.empty())
|
|
new_section(std::vector<std::string>());
|
|
sections.back().values.emplace_back(name, value, lineNumber);
|
|
}
|
|
|
|
std::string path;
|
|
std::vector<section_t> sections;
|
|
};
|
|
|
|
char const* parse_ini (char const* p, char const* pe, ini_file_t& iniFile);
|
|
|
|
#endif /* end of include guard: INI_PARSER_H_LJ9XOMJG */
|