102 lines
1.6 KiB
C++
102 lines
1.6 KiB
C++
#ifndef _GUITAR_LINEPARSER_HPP_
|
|
#define _GUITAR_LINEPARSER_HPP_
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
#ifndef _COMMON_FILE_HPP_
|
|
#include <common/file.hpp>
|
|
#endif
|
|
#ifndef _GUITAR_ELEMENT_HPP_
|
|
#include <guitar/element.hpp>
|
|
#endif
|
|
|
|
class LineParser : private String
|
|
{
|
|
public:
|
|
LineParser();
|
|
LineParser(const String &string);
|
|
virtual ~LineParser();
|
|
LineParser &operator=(const String &string);
|
|
LineParser &operator++();
|
|
LineParser &operator++(int /*postfixdummy*/);
|
|
void reset(void);
|
|
int getElement(Element &element);
|
|
void putElement(const Element &element);
|
|
void putElement(char ch);
|
|
int length(void)const;
|
|
int getPosition(void)const;
|
|
bool serialize(File &outFile)const;
|
|
private:
|
|
int peekElement(Element &element);
|
|
|
|
int mPosition;
|
|
int mLength;
|
|
};
|
|
|
|
inline
|
|
LineParser::LineParser()
|
|
: mPosition(0), mLength(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
LineParser::LineParser(const String &string)
|
|
: String(string), mPosition(0), mLength(String::length())
|
|
{
|
|
}
|
|
|
|
inline
|
|
LineParser::~LineParser()
|
|
{
|
|
}
|
|
|
|
inline
|
|
LineParser &LineParser::operator=(const String &string)
|
|
{
|
|
(String&)*this=string;
|
|
mPosition=0;
|
|
mLength=String::length();
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
LineParser &LineParser::operator++()
|
|
{
|
|
mPosition++;
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
LineParser &LineParser::operator++(int /*postfixdummy*/)
|
|
{
|
|
mPosition++;
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
void LineParser::reset(void)
|
|
{
|
|
mPosition=0;
|
|
}
|
|
|
|
inline
|
|
int LineParser::length(void)const
|
|
{
|
|
return mLength;
|
|
}
|
|
|
|
inline
|
|
int LineParser::getPosition(void)const
|
|
{
|
|
return mPosition;
|
|
}
|
|
|
|
inline
|
|
bool LineParser::serialize(File &outFile)const
|
|
{
|
|
if(!outFile.isOkay())return false;
|
|
outFile.writeLine(*this);
|
|
return true;
|
|
}
|
|
#endif
|