Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Types | Protected Attributes | List of all members
cNameValueParser Class Reference

#include <NameValueParser.h>

Inheritance diagram for cNameValueParser:
Inheritance graph
[legend]
Collaboration diagram for cNameValueParser:
Collaboration graph
[legend]

Public Member Functions

 cNameValueParser (bool a_AllowsKeyOnly=true)
 Creates an empty parser. More...
 
 cNameValueParser (const char *a_Data, size_t a_Size, bool a_AllowsKeyOnly=true)
 Creates an empty parser, then parses the data given. More...
 
bool Finish (void)
 Notifies the parser that no more data will be coming. More...
 
bool IsFinished (void) const
 Returns true if the parser expects no more data. More...
 
bool IsValid (void) const
 Returns true if the data parsed so far was valid. More...
 
void Parse (const char *a_Data, size_t a_Size)
 Parses the data given. More...
 

Protected Types

enum  eState {
  psKeySpace , psKey , psEqualSpace , psEqual ,
  psValueInSQuotes , psValueInDQuotes , psValueRaw , psAfterValue ,
  psInvalid , psFinished
}
 

Protected Attributes

bool m_AllowsKeyOnly
 If true, the parser will accept keys without an equal sign and the value. More...
 
AString m_CurrentKey
 Buffer for the current Key. More...
 
AString m_CurrentValue
 Buffer for the current Value;. More...
 
eState m_State
 The current state of the parser. More...
 

Detailed Description

Definition at line 16 of file NameValueParser.h.

Member Enumeration Documentation

◆ eState

enum cNameValueParser::eState
protected
Enumerator
psKeySpace 

Parsing the space in front of the next key.

psKey 

Currently adding more chars to the key in m_CurrentKey.

psEqualSpace 

Space after m_CurrentKey.

psEqual 

Just parsed the = sign after a name.

psValueInSQuotes 

Just parsed a Single-quote sign after the Equal sign.

psValueInDQuotes 

Just parsed a Double-quote sign after the Equal sign.

psValueRaw 

Just parsed a raw value without a quote.

psAfterValue 

Just finished parsing the value, waiting for semicolon or data end.

psInvalid 

The parser has encountered an invalid input; further parsing is skipped.

psFinished 

The parser has already been instructed to finish and doesn't expect any more data.

Definition at line 39 of file NameValueParser.h.

Constructor & Destructor Documentation

◆ cNameValueParser() [1/2]

cNameValueParser::cNameValueParser ( bool  a_AllowsKeyOnly = true)

Creates an empty parser.

Definition at line 74 of file NameValueParser.cpp.

◆ cNameValueParser() [2/2]

cNameValueParser::cNameValueParser ( const char *  a_Data,
size_t  a_Size,
bool  a_AllowsKeyOnly = true 
)

Creates an empty parser, then parses the data given.

Doesn't call Finish(), so more data can be parsed later

Definition at line 84 of file NameValueParser.cpp.

Member Function Documentation

◆ Finish()

bool cNameValueParser::Finish ( void  )

Notifies the parser that no more data will be coming.

Returns true if the parser state is valid

Definition at line 361 of file NameValueParser.cpp.

◆ IsFinished()

bool cNameValueParser::IsFinished ( void  ) const
inline

Returns true if the parser expects no more data.

Definition at line 36 of file NameValueParser.h.

◆ IsValid()

bool cNameValueParser::IsValid ( void  ) const
inline

Returns true if the data parsed so far was valid.

Definition at line 33 of file NameValueParser.h.

◆ Parse()

void cNameValueParser::Parse ( const char *  a_Data,
size_t  a_Size 
)

Parses the data given.

Definition at line 95 of file NameValueParser.cpp.

Member Data Documentation

◆ m_AllowsKeyOnly

bool cNameValueParser::m_AllowsKeyOnly
protected

If true, the parser will accept keys without an equal sign and the value.

Definition at line 57 of file NameValueParser.h.

◆ m_CurrentKey

AString cNameValueParser::m_CurrentKey
protected

Buffer for the current Key.

Definition at line 60 of file NameValueParser.h.

◆ m_CurrentValue

AString cNameValueParser::m_CurrentValue
protected

Buffer for the current Value;.

Definition at line 63 of file NameValueParser.h.

◆ m_State

eState cNameValueParser::m_State
protected

The current state of the parser.

Definition at line 54 of file NameValueParser.h.


The documentation for this class was generated from the following files: