16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

minor c++ standard compliance fixes

This commit is contained in:
tmj-fstate
2017-07-29 02:02:02 +02:00
parent 4357919272
commit 01ef6b3887
5 changed files with 78 additions and 72 deletions

View File

@@ -35,12 +35,6 @@ class cParser //: public std::stringstream
template <typename Type_>
cParser &
operator>>( Type_ &Right );
template <>
cParser &
operator>>( std::string &Right );
template <>
cParser &
operator>>( bool &Right );
template <typename Output_>
Output_
getToken( bool const ToLower = true, const char *Break = "\n\r\t ;" ) {
@@ -48,41 +42,34 @@ class cParser //: public std::stringstream
Output_ output;
*this >> output;
return output; };
template <>
bool
getToken<bool>( bool const ToLower, const char *Break ) {
auto const token = getToken<std::string>( true, Break );
return ( ( token == "true" )
|| ( token == "yes" )
|| ( token == "1" ) ); }
inline void ignoreToken()
{
readToken();
};
inline void ignoreTokens(int count)
{
for (int i = 0; i < count; i++)
readToken();
};
inline bool expectToken(std::string const &value)
{
return readToken() == value;
};
bool eof()
{
return mStream->eof();
};
bool ok()
{
return !mStream->fail();
};
bool getTokens(unsigned int Count = 1, bool ToLower = true, char const *Break = "\n\r\t ;");
inline
void
ignoreToken() {
readToken(); };
inline
void
ignoreTokens(int count) {
for( int i = 0; i < count; ++i ) {
readToken(); } };
inline
bool
expectToken( std::string const &Value ) {
return readToken() == Value; };
bool
eof() {
return mStream->eof(); };
bool
ok() {
return !mStream->fail(); };
bool
getTokens( unsigned int Count = 1, bool ToLower = true, char const *Break = "\n\r\t ;" );
// returns next incoming token, if any, without removing it from the set
std::string peek() const {
return (
false == tokens.empty() ?
tokens.front() :
"" ); }
std::string
peek() const {
return (
false == tokens.empty() ?
tokens.front() :
"" ); }
// returns percentage of file processed so far
int getProgress() const;
int getFullProgress() const;
@@ -129,26 +116,12 @@ cParser::operator>>( Type_ &Right ) {
template<>
cParser&
cParser::operator>>( std::string &Right ) {
if( true == this->tokens.empty() ) { return *this; }
Right = this->tokens.front();
this->tokens.pop_front();
return *this;
}
cParser::operator>>( std::string &Right );
template<>
cParser&
cParser::operator>>( bool &Right ) {
cParser::operator>>( bool &Right );
if( true == this->tokens.empty() ) { return *this; }
Right = ( ( this->tokens.front() == "true" )
|| ( this->tokens.front() == "yes" )
|| ( this->tokens.front() == "1" ) );
this->tokens.pop_front();
return *this;
}
template<>
bool
cParser::getToken<bool>( bool const ToLower, const char *Break );