Skip to content

Commit f323d9c

Browse files
authored
Merge pull request #74 from jwillemsen/jwi-cppmode
Restructure cpp11 to CPPMODE wich can be 03/11/17
2 parents f062fb3 + 90ab624 commit f323d9c

File tree

9 files changed

+202
-161
lines changed

9 files changed

+202
-161
lines changed

XSC/be/CXX/Elements.hpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ typedef std::vector<string> NamespaceMapping;
2424
class Context
2525
{
2626
public:
27+
// Which C++ version we generate for
28+
enum class CPPMODE {
29+
CPP03,
30+
CPP11,
31+
CPP17
32+
};
2733

2834

2935
public:
@@ -61,7 +67,7 @@ class Context
6167
ns_mapping_ (ns_mapping),
6268
cdr_reader_generation_ (false),
6369
cdr_writer_generation_ (false),
64-
cpp11_ (false),
70+
cppmode_ (CPPMODE::CPP03),
6571
generate_ra_sequences_ (false)
6672
{
6773
if (char_type == L"wchar_t")
@@ -107,7 +113,7 @@ class Context
107113
ns_mapping_ (c.ns_mapping_),
108114
cdr_reader_generation_ (c.cdr_reader_generation_),
109115
cdr_writer_generation_ (c.cdr_writer_generation_),
110-
cpp11_ (c.cpp11_),
116+
cppmode_ (c.cppmode_),
111117
generate_ra_sequences_ (c.generate_ra_sequences_)
112118
{
113119
}
@@ -218,9 +224,9 @@ class Context
218224
this->cdr_writer_generation_ = flag;
219225
}
220226
void
221-
cpp11 (bool flag)
227+
cppmode (CPPMODE flag)
222228
{
223-
this->cpp11_ = flag;
229+
this->cppmode_ = flag;
224230
}
225231
bool
226232
cdr_reader_generation_enabled ()
@@ -232,10 +238,10 @@ class Context
232238
{
233239
return this->cdr_writer_generation_;
234240
}
235-
bool
236-
cpp11 ()
241+
CPPMODE
242+
cppmode ()
237243
{
238-
return this->cpp11_;
244+
return this->cppmode_;
239245
}
240246

241247
void
@@ -315,8 +321,9 @@ class Context
315321
bool cdr_reader_generation_;
316322
bool cdr_writer_generation_;
317323

318-
// Generate code depending on C++11 features
319-
bool cpp11_;
324+
// Generate code depending on C++ features
325+
CPPMODE cppmode_;
326+
320327
bool generate_ra_sequences_;
321328
};
322329

XSC/be/CXX/Generator.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ options (po::options_description& d)
117117
"CDR streams.")
118118
("cxx-cpp11",
119119
"Generate code that depends on C++11 features.")
120+
("cxx-cpp17",
121+
"Generate code that depends on C++17 features.")
120122
;
121123
}
122124

@@ -332,7 +334,16 @@ generate (po::variables_map const& vm, Schema& schema, fs::path const& file_path
332334
bool cdr_reader (vm.count ("cxx-generate-cdr-reader-types"));
333335
bool cdr_writer (vm.count ("cxx-generate-cdr-writer-types"));
334336

335-
bool cpp11 (vm.count ("cxx-cpp11"));
337+
::Context::CPPMODE cppmode_ { ::Context::CPPMODE::CPP03 };
338+
if (vm.count ("cxx-cpp11"))
339+
{
340+
cppmode_ = ::Context::CPPMODE::CPP11;
341+
}
342+
if (vm.count ("cxx-cpp17"))
343+
{
344+
cppmode_ = ::Context::CPPMODE::CPP17;
345+
}
346+
336347

337348
// Check about random access sequences
338349
bool ra_sequences (vm.count ("cxx-enable-random-access-sequences"));
@@ -413,7 +424,7 @@ generate (po::variables_map const& vm, Schema& schema, fs::path const& file_path
413424
ctx.cdr_reader_generation (cdr_reader);
414425
ctx.cdr_writer_generation (cdr_writer);
415426

416-
ctx.cpp11 (cpp11);
427+
ctx.cppmode (cppmode_);
417428

418429
// Add additional information to the context:
419430
ctx.generate_ra_sequences (ra_sequences);
@@ -455,7 +466,7 @@ generate (po::variables_map const& vm, Schema& schema, fs::path const& file_path
455466
ctx.cdr_reader_generation (cdr_reader);
456467
ctx.cdr_writer_generation (cdr_writer);
457468

458-
ctx.cpp11 (cpp11);
469+
ctx.cppmode (cppmode_);
459470

460471
// Add additional information to the context:
461472
ctx.generate_ra_sequences (ra_sequences);
@@ -479,7 +490,7 @@ generate (po::variables_map const& vm, Schema& schema, fs::path const& file_path
479490
// Add additional information to the context:
480491
ctx.generate_ra_sequences (ra_sequences);
481492

482-
ctx.cpp11 (cpp11);
493+
ctx.cppmode (cppmode_);
483494

484495
if (!inline_)
485496
{

0 commit comments

Comments
 (0)