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:
@@ -1791,13 +1769,8 @@ namespace simplecpp {
17911769 tok = tok->next ;
17921770 }
17931771 }
1794- #if __cplusplus >= 201103L
17951772 optExpandValue = new TokenList (std::move (expandValue));
17961773 optNoExpandValue = new TokenList (std::move (noExpandValue));
1797- #else
1798- optExpandValue = new TokenList (expandValue);
1799- optNoExpandValue = new TokenList (noExpandValue);
1800- #endif
18011774 }
18021775
18031776 return true ;
@@ -2437,47 +2410,9 @@ namespace simplecpp {
24372410
24382411#ifdef SIMPLECPP_WINDOWS
24392412
2440- #if __cplusplus >= 201103L
24412413using MyMutex = std::mutex;
24422414template <class T >
24432415using MyLock = std::lock_guard<T>;
2444- #else
2445- class MyMutex {
2446- public:
2447- MyMutex () {
2448- InitializeCriticalSection (&m_criticalSection);
2449- }
2450-
2451- ~MyMutex () {
2452- DeleteCriticalSection (&m_criticalSection);
2453- }
2454-
2455- CRITICAL_SECTION* lock () {
2456- return &m_criticalSection;
2457- }
2458- private:
2459- CRITICAL_SECTION m_criticalSection;
2460- };
2461-
2462- template <typename T>
2463- class MyLock {
2464- public:
2465- explicit MyLock (T& m)
2466- : m_mutex(m) {
2467- EnterCriticalSection (m_mutex.lock ());
2468- }
2469-
2470- ~MyLock () {
2471- LeaveCriticalSection (m_mutex.lock ());
2472- }
2473-
2474- private:
2475- MyLock& operator =(const MyLock&);
2476- MyLock (const MyLock&);
2477-
2478- T& m_mutex;
2479- };
2480- #endif
24812416
24822417class RealFileNameMap {
24832418public:
@@ -4099,7 +4034,3 @@ std::string simplecpp::getCppStdString(const std::string &std)
40994034{
41004035 return getCppStdString (getCppStd (std));
41014036}
4102-
4103- #if (__cplusplus < 201103L) && !defined(__APPLE__)
4104- #undef nullptr
4105- #endif
0 commit comments