start changing the Space API

removed table_single from Space



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1065 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2017-06-27 16:51:55 +00:00
parent 62f16ecb1b
commit cde990ba82
9 changed files with 253 additions and 400 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2012, Tomasz Sowa
* Copyright (c) 2010-2017, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,7 @@ sample of use:
if( parser.status == SpaceParser::ok )
{
// the whole config we have in parser.table (parser.table_single)
// the whole config we have in parser.table
}
config syntax:
@@ -174,8 +174,6 @@ public:
void Clear();
// first we are searching in 'table_single' and if there is not
// such a 'name' there then we are looking in 'table' (for the first item in the vector)
// these methods return true if 'name' was found
// in other case they return false and 'out' will be equal 'def'
// they can return a null pointer if there is not such a 'name'
@@ -195,7 +193,7 @@ public:
/*
those methods are used to extract information from space.table or space.table_single
those methods are used to extract information from space.table
as a parameter they take the name of an option
and a default value (if there is no such a parameter),
they return appropriate value (either text, int or boolean)
@@ -229,21 +227,23 @@ public:
std::wstring & FindAdd(const std::wstring & name);
std::wstring & FindAdd(const WTextStream & name);
std::wstring & Add(const wchar_t * name, bool value);
std::wstring & Add(const std::wstring & name, bool value);
std::wstring & Add(const wchar_t * name, int value);
std::wstring & Add(const std::wstring & name, int value);
std::wstring & Add(const wchar_t * name, long value);
std::wstring & Add(const std::wstring & name, long value);
std::wstring & Add(const wchar_t * name, size_t value);
std::wstring & Add(const std::wstring & name, size_t value);
std::wstring & Add(const wchar_t * name, const wchar_t * value);
std::wstring & Add(const wchar_t * name, const std::wstring & value);
std::wstring & Add(const std::wstring & name, const std::wstring & value);
std::wstring & Add(const wchar_t * name, bool value, bool replace_existing = true);
std::wstring & Add(const std::wstring & name, bool value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, int value, bool replace_existing = true);
std::wstring & Add(const std::wstring & name, int value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, long value, bool replace_existing = true);
std::wstring & Add(const std::wstring & name, long value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, size_t value, bool replace_existing = true);
std::wstring & Add(const std::wstring & name, size_t value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, const WTextStream & value);
std::wstring & Add(const std::wstring & name, const WTextStream & value);
std::wstring & Add(const WTextStream & name, const WTextStream & value);
std::wstring & Add(const std::wstring & name, const std::wstring & value, bool replace_existing = true);
std::wstring & Add(const std::wstring & name, const wchar_t * value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, const wchar_t * value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, const std::wstring & value, bool replace_existing = true);
std::wstring & Add(const wchar_t * name, const WTextStream & value, bool replace_existing = true);
std::wstring & Add(const std::wstring & name, const WTextStream & value, bool replace_existing = true);
std::wstring & Add(const WTextStream & name, const WTextStream & value, bool replace_existing = true);
void Remove(const wchar_t * name);
void Remove(const std::wstring & name);
@@ -285,20 +285,7 @@ public:
/*
if your config file consists mainly of single forms such as:
option = value
option2 = value2
then you can call SplitSingle(true) for not inserting single values to
previous 'table' but instead to 'table_single'
table_single as the second parameter takes only std::wstring (instead of the whole std::vector)
so you can save a little memory from not using std::vector
*/
typedef std::map<std::wstring, std::wstring> TableSingle;
std::wstring name; // space name
TableSingle table_single; // std::map<std::wstring, std::wstring>
Table table; // std::map<std::wstring, std::vector<std::wstring> >
// childs
@@ -313,10 +300,9 @@ public:
/*
those methods are used to extract lists
note: if there is one option in table_single they will return it
return true if such an option exists (but value can be an empty list)
*/
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
bool ListText(const std::wstring & name, std::vector<std::wstring> & list);
@@ -326,9 +312,6 @@ public:
template<class Stream>
void Serialize(Stream & out, bool use_indents = false, bool use_comments = false, int level = 0) const;
template<class Stream>
void SerializeTableSingle(Stream & out, bool use_indents, int level) const;
template<class Stream>
void SerializeTableMulti(Stream & out, bool use_indents, int level) const;
@@ -346,6 +329,7 @@ public:
private:
std::wstring tmp_name;
std::wstring tmp_value;
std::wstring tmp_value_text;
std::string tmp_value_text_ascii;
@@ -415,21 +399,6 @@ bool use_quote = false;
}
template<class Stream>
void Space::SerializeTableSingle(Stream & out, bool use_indents, int level) const
{
TableSingle::const_iterator i;
for(i=table_single.begin() ; i != table_single.end() ; ++i)
{
PrintLevel(out, use_indents, level);
PrintKey(out, i->first);
out << L" = ";
PrintValue(out, i->second);
out << '\n';
}
}
template<class Stream>
@@ -489,7 +458,6 @@ void Space::Serialize(Stream & out, bool use_indents, bool use_comments, int lev
}
}
SerializeTableSingle(out, use_indents, level);
SerializeTableMulti(out, use_indents, level);
for(size_t i=0 ; i<spaces.size() ; ++i)