From 01ef6b3887ed3ee1e408012f3c70552070938049 Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Sat, 29 Jul 2017 02:02:02 +0200 Subject: [PATCH] minor c++ standard compliance fixes --- McZapkie/MOVER.h | 16 ++++----- ResourceManager.h | 2 +- Texture.cpp | 5 +-- parser.cpp | 36 +++++++++++++++++++ parser.h | 91 +++++++++++++++++------------------------------ 5 files changed, 78 insertions(+), 72 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 8a83e79a..2fe15ace 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -384,14 +384,14 @@ struct TBoilerType { }; /*rodzaj odbieraka pradu*/ struct TCurrentCollector { - long CollectorsNo{ 0 }; //musi być tu, bo inaczej się kopie - double MinH{ 0.0 }; double MaxH{ 0.0 }; //zakres ruchu pantografu, nigdzie nie używany - double CSW{ 0.0 }; //szerokość części roboczej (styku) ślizgacza - double MinV{ 0.0 }; double MaxV{ 0.0 }; //minimalne i maksymalne akceptowane napięcie - double OVP{ 0.0 }; //czy jest przekaznik nadnapieciowy - double InsetV{ 0.0 }; //minimalne napięcie wymagane do załączenia - double MinPress{ 0.0 }; //minimalne ciśnienie do załączenia WS - double MaxPress{ 0.0 }; //maksymalne ciśnienie za reduktorem + long CollectorsNo; //musi być tu, bo inaczej się kopie + double MinH; double MaxH; //zakres ruchu pantografu, nigdzie nie używany + double CSW; //szerokość części roboczej (styku) ślizgacza + double MinV; double MaxV; //minimalne i maksymalne akceptowane napięcie + double OVP; //czy jest przekaznik nadnapieciowy + double InsetV; //minimalne napięcie wymagane do załączenia + double MinPress; //minimalne ciśnienie do załączenia WS + double MaxPress; //maksymalne ciśnienie za reduktorem //inline TCurrentCollector() { // CollectorsNo = 0; // MinH, MaxH, CSW, MinV, MaxV = 0.0; diff --git a/ResourceManager.h b/ResourceManager.h index 50e65600..ae890b57 100644 --- a/ResourceManager.h +++ b/ResourceManager.h @@ -110,7 +110,7 @@ private: std::chrono::nanoseconds const m_unusedresourcetimetolive; typename Container_::size_type const m_unusedresourcesweepsize; std::string const m_resourcename; - typename Container_ &m_container; + Container_ &m_container; typename Container_::size_type m_resourcesweepindex { 0 }; std::chrono::steady_clock::time_point m_resourcetimestamp { std::chrono::steady_clock::now() }; }; diff --git a/Texture.cpp b/Texture.cpp index f6147f05..228d314d 100644 --- a/Texture.cpp +++ b/Texture.cpp @@ -592,10 +592,7 @@ opengl_texture::create() { } } - data.swap( std::vector() ); // TBD, TODO: keep the texture data if we start doing some gpu data cleaning down the road -/* - data_state = resource_state::none; -*/ + data = std::vector(); data_state = resource_state::none; is_ready = true; } diff --git a/parser.cpp b/parser.cpp index 68355475..c7bbebd5 100644 --- a/parser.cpp +++ b/parser.cpp @@ -72,6 +72,42 @@ cParser::~cParser() mComments.clear(); } +template<> +cParser& +cParser::operator>>( std::string &Right ) { + + if( true == this->tokens.empty() ) { return *this; } + + Right = this->tokens.front(); + this->tokens.pop_front(); + + return *this; +} + +template<> +cParser& +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 const ToLower, const char *Break ) { + + auto const token = getToken( true, Break ); + return ( ( token == "true" ) + || ( token == "yes" ) + || ( token == "1" ) ); +} + // methods bool cParser::getTokens(unsigned int Count, bool ToLower, const char *Break) { diff --git a/parser.h b/parser.h index b8176c0a..982959ef 100644 --- a/parser.h +++ b/parser.h @@ -35,12 +35,6 @@ class cParser //: public std::stringstream template cParser & operator>>( Type_ &Right ); - template <> - cParser & - operator>>( std::string &Right ); - template <> - cParser & - operator>>( bool &Right ); template 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 const ToLower, const char *Break ) { - auto const token = getToken( 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 const ToLower, const char *Break );