1212#define _WIN32_WINNT 0x0602
1313#include < windows.h>
1414#undef ERROR
15- #else
16- #include < sys/stat.h>
1715#endif
1816
1917#include " simplecpp.h"
4038#include < stack>
4139#include < stdexcept>
4240#include < string>
43- #if __cplusplus >= 201103L
4441#ifdef SIMPLECPP_WINDOWS
4542#include < mutex>
4643#endif
4744#include < unordered_map>
48- #endif
4945#include < utility>
5046#include < vector>
5147
5248#ifdef _WIN32
5349#include < direct.h>
5450#else
51+ #include < sys/stat.h>
5552#include < unistd.h>
5653#endif
5754
58- #if __cplusplus >= 201103L
59- #define OVERRIDE override
60- #define EXPLICIT explicit
61- #else
62- #define OVERRIDE
63- #define EXPLICIT
64- #endif
65-
66- #if (__cplusplus < 201103L) && !defined(__APPLE__)
67- #define nullptr NULL
68- #endif
69-
7055static bool isHex (const std::string &s)
7156{
7257 return s.size ()>2 && (s.compare (0 ,2 ," 0x" )==0 || s.compare (0 ,2 ," 0X" )==0 );
@@ -372,22 +357,22 @@ class simplecpp::TokenList::Stream {
372357class StdIStream : public simplecpp ::TokenList::Stream {
373358public:
374359 // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
375- EXPLICIT StdIStream (std::istream &istr)
360+ explicit StdIStream (std::istream &istr)
376361 : istr(istr) {
377362 assert (istr.good ());
378363 init ();
379364 }
380365
381- virtual int get () OVERRIDE {
366+ virtual int get () override {
382367 return istr.get ();
383368 }
384- virtual int peek () OVERRIDE {
369+ virtual int peek () override {
385370 return istr.peek ();
386371 }
387- virtual void unget () OVERRIDE {
372+ virtual void unget () override {
388373 istr.unget ();
389374 }
390- virtual bool good () OVERRIDE {
375+ virtual bool good () override {
391376 return istr.good ();
392377 }
393378
@@ -406,20 +391,20 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
406391 init ();
407392 }
408393
409- virtual int get () OVERRIDE {
394+ virtual int get () override {
410395 if (pos >= size)
411396 return lastStatus = EOF;
412397 return str[pos++];
413398 }
414- virtual int peek () OVERRIDE {
399+ virtual int peek () override {
415400 if (pos >= size)
416401 return lastStatus = EOF;
417402 return str[pos];
418403 }
419- virtual void unget () OVERRIDE {
404+ virtual void unget () override {
420405 --pos;
421406 }
422- virtual bool good () OVERRIDE {
407+ virtual bool good () override {
423408 return lastStatus != EOF;
424409 }
425410
@@ -433,7 +418,7 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
433418class FileStream : public simplecpp ::TokenList::Stream {
434419public:
435420 // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
436- EXPLICIT FileStream (const std::string &filename, std::vector<std::string> &files)
421+ explicit FileStream (const std::string &filename, std::vector<std::string> &files)
437422 : file(fopen(filename.c_str(), "rb"))
438423 , lastCh(0 )
439424 , lastStatus(0 ) {
@@ -444,25 +429,25 @@ class FileStream : public simplecpp::TokenList::Stream {
444429 init ();
445430 }
446431
447- ~FileStream () OVERRIDE {
432+ ~FileStream () override {
448433 fclose (file);
449434 file = nullptr ;
450435 }
451436
452- virtual int get () OVERRIDE {
437+ virtual int get () override {
453438 lastStatus = lastCh = fgetc (file);
454439 return lastCh;
455440 }
456- virtual int peek () OVERRIDE {
441+ virtual int peek () override {
457442 // keep lastCh intact
458443 const int ch = fgetc (file);
459444 unget_internal (ch);
460445 return ch;
461446 }
462- virtual void unget () OVERRIDE {
447+ virtual void unget () override {
463448 unget_internal (lastCh);
464449 }
465- virtual bool good () OVERRIDE {
450+ virtual bool good () override {
466451 return lastStatus != EOF;
467452 }
468453
@@ -523,12 +508,10 @@ simplecpp::TokenList::TokenList(const TokenList &other) : frontToken(nullptr), b
523508 *this = other;
524509}
525510
526- #if __cplusplus >= 201103L
527511simplecpp::TokenList::TokenList (TokenList &&other) : frontToken(nullptr ), backToken(nullptr ), files(other.files)
528512{
529513 *this = std::move (other);
530514}
531- #endif
532515
533516simplecpp::TokenList::~TokenList ()
534517{
@@ -547,7 +530,6 @@ simplecpp::TokenList &simplecpp::TokenList::operator=(const TokenList &other)
547530 return *this ;
548531}
549532
550- #if __cplusplus >= 201103L
551533simplecpp::TokenList &simplecpp::TokenList::operator =(TokenList &&other)
552534{
553535 if (this != &other) {
@@ -561,7 +543,6 @@ simplecpp::TokenList &simplecpp::TokenList::operator=(TokenList &&other)
561543 }
562544 return *this ;
563545}
564- #endif
565546
566547void simplecpp::TokenList::clear ()
567548{
@@ -1481,11 +1462,7 @@ unsigned int simplecpp::TokenList::fileIndex(const std::string &filename)
14811462
14821463namespace simplecpp {
14831464 class Macro ;
1484- #if __cplusplus >= 201103L
14851465 using MacroMap = std::unordered_map<TokenString,Macro>;
1486- #else
1487- typedef std::map<TokenString,Macro> MacroMap;
1488- #endif
14891466
14901467 class Macro {
14911468 public:
@@ -2383,48 +2360,9 @@ namespace simplecpp {
23832360}
23842361
23852362#ifdef SIMPLECPP_WINDOWS
2386-
2387- #if __cplusplus >= 201103L
23882363using MyMutex = std::mutex;
23892364template <class T >
23902365using MyLock = std::lock_guard<T>;
2391- #else
2392- class MyMutex {
2393- public:
2394- MyMutex () {
2395- InitializeCriticalSection (&m_criticalSection);
2396- }
2397-
2398- ~MyMutex () {
2399- DeleteCriticalSection (&m_criticalSection);
2400- }
2401-
2402- CRITICAL_SECTION* lock () {
2403- return &m_criticalSection;
2404- }
2405- private:
2406- CRITICAL_SECTION m_criticalSection;
2407- };
2408-
2409- template <typename T>
2410- class MyLock {
2411- public:
2412- explicit MyLock (T& m)
2413- : m_mutex(m) {
2414- EnterCriticalSection (m_mutex.lock ());
2415- }
2416-
2417- ~MyLock () {
2418- LeaveCriticalSection (m_mutex.lock ());
2419- }
2420-
2421- private:
2422- MyLock& operator =(const MyLock&);
2423- MyLock (const MyLock&);
2424-
2425- T& m_mutex;
2426- };
2427- #endif
24282366
24292367static bool isAbsolutePath (const std::string &path)
24302368{
@@ -2433,7 +2371,6 @@ static bool isAbsolutePath(const std::string &path)
24332371 return path.length () > 1U && (path[0 ] == ' /' || path[0 ] == ' \\ ' );
24342372}
24352373#else
2436-
24372374static bool isAbsolutePath (const std::string &path)
24382375{
24392376 return path.length () > 1U && path[0 ] == ' /' ;
@@ -3934,7 +3871,3 @@ std::string simplecpp::getCppStdString(const std::string &std)
39343871{
39353872 return getCppStdString (getCppStd (std));
39363873}
3937-
3938- #if (__cplusplus < 201103L) && !defined(__APPLE__)
3939- #undef nullptr
3940- #endif
0 commit comments