cog/Frameworks/GME/gme/Bml_Parser.h

62 lines
1.4 KiB
C
Raw Normal View History

2013-09-28 03:24:46 +00:00
#ifndef BML_PARSER_H
#define BML_PARSER_H
#include <vector>
#include <string>
#include <sstream>
2013-09-28 03:24:46 +00:00
class Bml_Node
{
char * name;
char * value;
std::vector<Bml_Node> children;
static Bml_Node emptyNode;
public:
Bml_Node();
Bml_Node(char const* name, size_t max_length = ~0UL);
2013-09-28 03:24:46 +00:00
Bml_Node(Bml_Node const& in);
~Bml_Node();
void clear();
void setLine(const char * line, size_t max_length = ~0UL);
Bml_Node& addChild(Bml_Node const& child);
2013-09-28 03:24:46 +00:00
const char * getName() const;
const char * getValue() const;
void setValue(char const* value);
2013-09-28 03:24:46 +00:00
size_t getChildCount() const;
Bml_Node const& getChild(size_t index) const;
Bml_Node & walkToNode( const char * path, bool use_indexes = false );
2013-09-28 03:24:46 +00:00
Bml_Node const& walkToNode( const char * path ) const;
};
class Bml_Parser
{
Bml_Node document;
public:
Bml_Parser() { }
void parseDocument(const char * document, size_t max_length = ~0UL);
2013-09-28 03:24:46 +00:00
const char * enumValue(std::string const& path) const;
void setValue(std::string const& path, long value);
void setValue(std::string const& path, const char * value);
2013-09-28 03:24:46 +00:00
void serialize(std::string & out) const;
private:
void serialize(std::ostringstream & out, Bml_Node const* node, unsigned int indent) const;
2013-09-28 03:24:46 +00:00
};
#endif // BML_PARSER_H