12
12
#define _WIN32_WINNT 0x0602
13
13
#include < windows.h>
14
14
#undef ERROR
15
- #else
16
- #include < sys/stat.h>
17
15
#endif
18
16
19
17
#include " simplecpp.h"
40
38
#include < stack>
41
39
#include < stdexcept>
42
40
#include < string>
43
- #if __cplusplus >= 201103L
44
41
#ifdef SIMPLECPP_WINDOWS
45
42
#include < mutex>
46
43
#endif
47
44
#include < unordered_map>
48
- #endif
49
45
#include < utility>
50
46
#include < vector>
51
47
52
48
#ifdef _WIN32
53
49
#include < direct.h>
54
50
#else
51
+ #include < sys/stat.h>
55
52
#include < unistd.h>
56
53
#endif
57
54
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
-
70
55
static bool isHex (const std::string &s)
71
56
{
72
57
return s.size ()>2 && (s.compare (0 ,2 ," 0x" )==0 || s.compare (0 ,2 ," 0X" )==0 );
@@ -372,22 +357,22 @@ class simplecpp::TokenList::Stream {
372
357
class StdIStream : public simplecpp ::TokenList::Stream {
373
358
public:
374
359
// cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
375
- EXPLICIT StdIStream (std::istream &istr)
360
+ explicit StdIStream (std::istream &istr)
376
361
: istr(istr) {
377
362
assert (istr.good ());
378
363
init ();
379
364
}
380
365
381
- virtual int get () OVERRIDE {
366
+ virtual int get () override {
382
367
return istr.get ();
383
368
}
384
- virtual int peek () OVERRIDE {
369
+ virtual int peek () override {
385
370
return istr.peek ();
386
371
}
387
- virtual void unget () OVERRIDE {
372
+ virtual void unget () override {
388
373
istr.unget ();
389
374
}
390
- virtual bool good () OVERRIDE {
375
+ virtual bool good () override {
391
376
return istr.good ();
392
377
}
393
378
@@ -406,20 +391,20 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
406
391
init ();
407
392
}
408
393
409
- virtual int get () OVERRIDE {
394
+ virtual int get () override {
410
395
if (pos >= size)
411
396
return lastStatus = EOF;
412
397
return str[pos++];
413
398
}
414
- virtual int peek () OVERRIDE {
399
+ virtual int peek () override {
415
400
if (pos >= size)
416
401
return lastStatus = EOF;
417
402
return str[pos];
418
403
}
419
- virtual void unget () OVERRIDE {
404
+ virtual void unget () override {
420
405
--pos;
421
406
}
422
- virtual bool good () OVERRIDE {
407
+ virtual bool good () override {
423
408
return lastStatus != EOF;
424
409
}
425
410
@@ -433,7 +418,7 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
433
418
class FileStream : public simplecpp ::TokenList::Stream {
434
419
public:
435
420
// 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)
437
422
: file(fopen(filename.c_str(), "rb"))
438
423
, lastCh(0 )
439
424
, lastStatus(0 ) {
@@ -444,25 +429,25 @@ class FileStream : public simplecpp::TokenList::Stream {
444
429
init ();
445
430
}
446
431
447
- ~FileStream () OVERRIDE {
432
+ ~FileStream () override {
448
433
fclose (file);
449
434
file = nullptr ;
450
435
}
451
436
452
- virtual int get () OVERRIDE {
437
+ virtual int get () override {
453
438
lastStatus = lastCh = fgetc (file);
454
439
return lastCh;
455
440
}
456
- virtual int peek () OVERRIDE {
441
+ virtual int peek () override {
457
442
// keep lastCh intact
458
443
const int ch = fgetc (file);
459
444
unget_internal (ch);
460
445
return ch;
461
446
}
462
- virtual void unget () OVERRIDE {
447
+ virtual void unget () override {
463
448
unget_internal (lastCh);
464
449
}
465
- virtual bool good () OVERRIDE {
450
+ virtual bool good () override {
466
451
return lastStatus != EOF;
467
452
}
468
453
@@ -523,12 +508,10 @@ simplecpp::TokenList::TokenList(const TokenList &other) : frontToken(nullptr), b
523
508
*this = other;
524
509
}
525
510
526
- #if __cplusplus >= 201103L
527
511
simplecpp::TokenList::TokenList (TokenList &&other) : frontToken(nullptr ), backToken(nullptr ), files(other.files)
528
512
{
529
513
*this = std::move (other);
530
514
}
531
- #endif
532
515
533
516
simplecpp::TokenList::~TokenList ()
534
517
{
@@ -547,7 +530,6 @@ simplecpp::TokenList &simplecpp::TokenList::operator=(const TokenList &other)
547
530
return *this ;
548
531
}
549
532
550
- #if __cplusplus >= 201103L
551
533
simplecpp::TokenList &simplecpp::TokenList::operator =(TokenList &&other)
552
534
{
553
535
if (this != &other) {
@@ -561,7 +543,6 @@ simplecpp::TokenList &simplecpp::TokenList::operator=(TokenList &&other)
561
543
}
562
544
return *this ;
563
545
}
564
- #endif
565
546
566
547
void simplecpp::TokenList::clear ()
567
548
{
@@ -1481,11 +1462,7 @@ unsigned int simplecpp::TokenList::fileIndex(const std::string &filename)
1481
1462
1482
1463
namespace simplecpp {
1483
1464
class Macro ;
1484
- #if __cplusplus >= 201103L
1485
1465
using MacroMap = std::unordered_map<TokenString,Macro>;
1486
- #else
1487
- typedef std::map<TokenString,Macro> MacroMap;
1488
- #endif
1489
1466
1490
1467
class Macro {
1491
1468
public:
@@ -2383,48 +2360,9 @@ namespace simplecpp {
2383
2360
}
2384
2361
2385
2362
#ifdef SIMPLECPP_WINDOWS
2386
-
2387
- #if __cplusplus >= 201103L
2388
2363
using MyMutex = std::mutex;
2389
2364
template <class T >
2390
2365
using 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
2428
2366
2429
2367
static bool isAbsolutePath (const std::string &path)
2430
2368
{
@@ -2433,7 +2371,6 @@ static bool isAbsolutePath(const std::string &path)
2433
2371
return path.length () > 1U && (path[0 ] == ' /' || path[0 ] == ' \\ ' );
2434
2372
}
2435
2373
#else
2436
-
2437
2374
static bool isAbsolutePath (const std::string &path)
2438
2375
{
2439
2376
return path.length () > 1U && path[0 ] == ' /' ;
@@ -3934,7 +3871,3 @@ std::string simplecpp::getCppStdString(const std::string &std)
3934
3871
{
3935
3872
return getCppStdString (getCppStd (std));
3936
3873
}
3937
-
3938
- #if (__cplusplus < 201103L) && !defined(__APPLE__)
3939
- #undef nullptr
3940
- #endif
0 commit comments