-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from bigladder/add-core-to-cpp
Add core to cpp
- Loading branch information
Showing
8 changed files
with
145 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from jinja2 import Template | ||
import os | ||
import sys | ||
from lattice.file_io import dump | ||
from lattice.util import snake_style | ||
from pathlib import Path | ||
|
||
# file_loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), 'generation_templates')) | ||
# env = Environment(loader=file_loader) | ||
|
||
def generate_support_headers(namespace_name: str, output_directory: Path): | ||
for template in Path(__file__).with_name("templates").iterdir(): | ||
enum_info = Template(template.read_text()) | ||
generated_file_name = "-".join(snake_style(template.stem).split("_")) | ||
dump(enum_info.render(namespace=namespace_name), Path(output_directory) / generated_file_name) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef ENUM_INFO_H_ | ||
#define ENUM_INFO_H_ | ||
|
||
#include <string_view> | ||
|
||
namespace {{namespace}} { | ||
|
||
struct enum_info | ||
{ | ||
std::string_view enumerant_name; | ||
std::string_view display_text; | ||
std::string_view description; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef LOAD_OBJECT_H_ | ||
#define LOAD_OBJECT_H_ | ||
|
||
#include <nlohmann/json.hpp> | ||
#include <courierr/courierr.h> | ||
|
||
namespace {{namespace}} { | ||
|
||
template<class T> | ||
void json_get(nlohmann::json j, | ||
Courierr::Courierr& logger, | ||
const char *subnode, | ||
T& object, | ||
bool& object_is_set, | ||
bool required = false) | ||
{ | ||
try | ||
{ | ||
object = j.at(subnode).get<T>(); | ||
object_is_set = true; | ||
} | ||
catch (nlohmann::json::out_of_range & ex) | ||
{ | ||
object_is_set = false; | ||
if (required) | ||
{ | ||
logger.warning(ex.what()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters