3131#include < stack>
3232#include < stdexcept>
3333#include < string>
34- #if __cplusplus >= 201103L
3534#ifdef SIMPLECPP_WINDOWS
3635#include < mutex>
3736#endif
3837#include < unordered_map>
39- #endif
4038#include < utility>
4139#include < vector>
4240
5149#undef ERROR
5250#endif
5351
54- #if __cplusplus >= 201103L
55- #define OVERRIDE override
56- #define EXPLICIT explicit
57- #else
58- #define OVERRIDE
59- #define EXPLICIT
60- #endif
61-
62- #if (__cplusplus < 201103L) && !defined(__APPLE__)
63- #define nullptr NULL
64- #endif
65-
6652static bool isHex (const std::string &s)
6753{
6854 return s.size ()>2 && (s.compare (0 ,2 ," 0x" )==0 || s.compare (0 ,2 ," 0X" )==0 );
@@ -368,22 +354,22 @@ class simplecpp::TokenList::Stream {
368354class StdIStream : public simplecpp ::TokenList::Stream {
369355public:
370356 // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
371- EXPLICIT StdIStream (std::istream &istr)
357+ explicit StdIStream (std::istream &istr)
372358 : istr(istr) {
373359 assert (istr.good ());
374360 init ();
375361 }
376362
377- virtual int get () OVERRIDE {
363+ virtual int get () override {
378364 return istr.get ();
379365 }
380- virtual int peek () OVERRIDE {
366+ virtual int peek () override {
381367 return istr.peek ();
382368 }
383- virtual void unget () OVERRIDE {
369+ virtual void unget () override {
384370 istr.unget ();
385371 }
386- virtual bool good () OVERRIDE {
372+ virtual bool good () override {
387373 return istr.good ();
388374 }
389375
@@ -402,20 +388,20 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
402388 init ();
403389 }
404390
405- virtual int get () OVERRIDE {
391+ virtual int get () override {
406392 if (pos >= size)
407393 return lastStatus = EOF;
408394 return str[pos++];
409395 }
410- virtual int peek () OVERRIDE {
396+ virtual int peek () override {
411397 if (pos >= size)
412398 return lastStatus = EOF;
413399 return str[pos];
414400 }
415- virtual void unget () OVERRIDE {
401+ virtual void unget () override {
416402 --pos;
417403 }
418- virtual bool good () OVERRIDE {
404+ virtual bool good () override {
419405 return lastStatus != EOF;
420406 }
421407
@@ -429,7 +415,7 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
429415class FileStream : public simplecpp ::TokenList::Stream {
430416public:
431417 // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
432- EXPLICIT FileStream (const std::string &filename, std::vector<std::string> &files)
418+ explicit FileStream (const std::string &filename, std::vector<std::string> &files)
433419 : file(fopen(filename.c_str(), "rb"))
434420 , lastCh(0 )
435421 , lastStatus(0 ) {
@@ -440,25 +426,25 @@ class FileStream : public simplecpp::TokenList::Stream {
440426 init ();
441427 }
442428
443- ~FileStream () OVERRIDE {
429+ ~FileStream () override {
444430 fclose (file);
445431 file = nullptr ;
446432 }
447433
448- virtual int get () OVERRIDE {
434+ virtual int get () override {
449435 lastStatus = lastCh = fgetc (file);
450436 return lastCh;
451437 }
452- virtual int peek () OVERRIDE {
438+ virtual int peek () override {
453439 // keep lastCh intact
454440 const int ch = fgetc (file);
455441 unget_internal (ch);
456442 return ch;
457443 }
458- virtual void unget () OVERRIDE {
444+ virtual void unget () override {
459445 unget_internal (lastCh);
460446 }
461- virtual bool good () OVERRIDE {
447+ virtual bool good () override {
462448 return lastStatus != EOF;
463449 }
464450
@@ -519,12 +505,10 @@ simplecpp::TokenList::TokenList(const TokenList &other) : frontToken(nullptr), b
519505 *this = other;
520506}
521507
522- #if __cplusplus >= 201103L
523508simplecpp::TokenList::TokenList (TokenList &&other) : frontToken(nullptr ), backToken(nullptr ), files(other.files)
524509{
525510 *this = std::move (other);
526511}
527- #endif
528512
529513simplecpp::TokenList::~TokenList ()
530514{
@@ -543,7 +527,6 @@ simplecpp::TokenList &simplecpp::TokenList::operator=(const TokenList &other)
543527 return *this ;
544528}
545529
546- #if __cplusplus >= 201103L
547530simplecpp::TokenList &simplecpp::TokenList::operator =(TokenList &&other)
548531{
549532 if (this != &other) {
@@ -557,7 +540,6 @@ simplecpp::TokenList &simplecpp::TokenList::operator=(TokenList &&other)
557540 }
558541 return *this ;
559542}
560- #endif
561543
562544void simplecpp::TokenList::clear ()
563545{
@@ -1477,11 +1459,7 @@ unsigned int simplecpp::TokenList::fileIndex(const std::string &filename)
14771459
14781460namespace simplecpp {
14791461 class Macro ;
1480- #if __cplusplus >= 201103L
14811462 using MacroMap = std::unordered_map<TokenString,Macro>;
1482- #else
1483- typedef std::map<TokenString,Macro> MacroMap;
1484- #endif
14851463
14861464 class Macro {
14871465 public:
@@ -2380,47 +2358,9 @@ namespace simplecpp {
23802358
23812359#ifdef SIMPLECPP_WINDOWS
23822360
2383- #if __cplusplus >= 201103L
23842361using MyMutex = std::mutex;
23852362template <class T >
23862363using MyLock = std::lock_guard<T>;
2387- #else
2388- class MyMutex {
2389- public:
2390- MyMutex () {
2391- InitializeCriticalSection (&m_criticalSection);
2392- }
2393-
2394- ~MyMutex () {
2395- DeleteCriticalSection (&m_criticalSection);
2396- }
2397-
2398- CRITICAL_SECTION* lock () {
2399- return &m_criticalSection;
2400- }
2401- private:
2402- CRITICAL_SECTION m_criticalSection;
2403- };
2404-
2405- template <typename T>
2406- class MyLock {
2407- public:
2408- explicit MyLock (T& m)
2409- : m_mutex(m) {
2410- EnterCriticalSection (m_mutex.lock ());
2411- }
2412-
2413- ~MyLock () {
2414- LeaveCriticalSection (m_mutex.lock ());
2415- }
2416-
2417- private:
2418- MyLock& operator =(const MyLock&);
2419- MyLock (const MyLock&);
2420-
2421- T& m_mutex;
2422- };
2423- #endif
24242364
24252365class RealFileNameMap {
24262366public:
@@ -4032,7 +3972,3 @@ std::string simplecpp::getCppStdString(const std::string &std)
40323972{
40333973 return getCppStdString (getCppStd (std));
40343974}
4035-
4036- #if (__cplusplus < 201103L) && !defined(__APPLE__)
4037- #undef nullptr
4038- #endif
0 commit comments