Cuberite
A lightweight, fast and extensible game server for Minecraft
NameValueParser.h
Go to the documentation of this file.
1 
2 // NameValueParser.h
3 
4 // Declares the cNameValueParser class that parses strings in the "name=value;name2=value2" format into a stringmap
5 
6 
7 
8 
9 
10 #pragma once
11 
12 
13 
14 
15 
17  public std::map<AString, AString>
18 {
19 public:
21  cNameValueParser(bool a_AllowsKeyOnly = true);
22 
24  cNameValueParser(const char * a_Data, size_t a_Size, bool a_AllowsKeyOnly = true);
25 
27  void Parse(const char * a_Data, size_t a_Size);
28 
30  bool Finish(void);
31 
33  bool IsValid(void) const { return (m_State != psInvalid); }
34 
36  bool IsFinished(void) const { return ((m_State == psInvalid) || (m_State == psFinished)); }
37 
38 protected:
39  enum eState
40  {
51  } ;
52 
55 
58 
61 
64 
65 
66 } ;
67 
68 
69 
70 
AString m_CurrentValue
Buffer for the current Value;.
Parsing the space in front of the next key.
Just parsed a Double-quote sign after the Equal sign.
The parser has already been instructed to finish and doesn&#39;t expect any more data.
Just parsed the = sign after a name.
The parser has encountered an invalid input; further parsing is skipped.
Currently adding more chars to the key in m_CurrentKey.
bool Finish(void)
Notifies the parser that no more data will be coming.
bool IsFinished(void) const
Returns true if the parser expects no more data.
AString m_CurrentKey
Buffer for the current Key.
Just parsed a raw value without a quote.
eState m_State
The current state of the parser.
bool m_AllowsKeyOnly
If true, the parser will accept keys without an equal sign and the value.
std::string AString
Definition: StringUtils.h:13
Space after m_CurrentKey.
void Parse(const char *a_Data, size_t a_Size)
Parses the data given.
Just parsed a Single-quote sign after the Equal sign.
bool IsValid(void) const
Returns true if the data parsed so far was valid.
cNameValueParser(bool a_AllowsKeyOnly=true)
Creates an empty parser.
Just finished parsing the value, waiting for semicolon or data end.