Skip to content

Commit

Permalink
Merge pull request #74 from jwillemsen/jwi-cppmode
Browse files Browse the repository at this point in the history
Restructure cpp11 to CPPMODE wich can be 03/11/17
  • Loading branch information
jwillemsen authored Aug 30, 2024
2 parents f062fb3 + 90ab624 commit f323d9c
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 161 deletions.
25 changes: 16 additions & 9 deletions XSC/be/CXX/Elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ typedef std::vector<string> NamespaceMapping;
class Context
{
public:
// Which C++ version we generate for
enum class CPPMODE {
CPP03,
CPP11,
CPP17
};


public:
Expand Down Expand Up @@ -61,7 +67,7 @@ class Context
ns_mapping_ (ns_mapping),
cdr_reader_generation_ (false),
cdr_writer_generation_ (false),
cpp11_ (false),
cppmode_ (CPPMODE::CPP03),
generate_ra_sequences_ (false)
{
if (char_type == L"wchar_t")
Expand Down Expand Up @@ -107,7 +113,7 @@ class Context
ns_mapping_ (c.ns_mapping_),
cdr_reader_generation_ (c.cdr_reader_generation_),
cdr_writer_generation_ (c.cdr_writer_generation_),
cpp11_ (c.cpp11_),
cppmode_ (c.cppmode_),
generate_ra_sequences_ (c.generate_ra_sequences_)
{
}
Expand Down Expand Up @@ -218,9 +224,9 @@ class Context
this->cdr_writer_generation_ = flag;
}
void
cpp11 (bool flag)
cppmode (CPPMODE flag)
{
this->cpp11_ = flag;
this->cppmode_ = flag;
}
bool
cdr_reader_generation_enabled ()
Expand All @@ -232,10 +238,10 @@ class Context
{
return this->cdr_writer_generation_;
}
bool
cpp11 ()
CPPMODE
cppmode ()
{
return this->cpp11_;
return this->cppmode_;
}

void
Expand Down Expand Up @@ -315,8 +321,9 @@ class Context
bool cdr_reader_generation_;
bool cdr_writer_generation_;

// Generate code depending on C++11 features
bool cpp11_;
// Generate code depending on C++ features
CPPMODE cppmode_;

bool generate_ra_sequences_;
};

Expand Down
19 changes: 15 additions & 4 deletions XSC/be/CXX/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ options (po::options_description& d)
"CDR streams.")
("cxx-cpp11",
"Generate code that depends on C++11 features.")
("cxx-cpp17",
"Generate code that depends on C++17 features.")
;
}

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

bool cpp11 (vm.count ("cxx-cpp11"));
::Context::CPPMODE cppmode_ { ::Context::CPPMODE::CPP03 };
if (vm.count ("cxx-cpp11"))
{
cppmode_ = ::Context::CPPMODE::CPP11;
}
if (vm.count ("cxx-cpp17"))
{
cppmode_ = ::Context::CPPMODE::CPP17;
}


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

ctx.cpp11 (cpp11);
ctx.cppmode (cppmode_);

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

ctx.cpp11 (cpp11);
ctx.cppmode (cppmode_);

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

ctx.cpp11 (cpp11);
ctx.cppmode (cppmode_);

if (!inline_)
{
Expand Down
Loading

0 comments on commit f323d9c

Please sign in to comment.