-
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 #10 from Dannode36/dev
v2.1
- Loading branch information
Showing
16 changed files
with
564 additions
and
235 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,18 @@ | ||
{ | ||
"int32": "int", | ||
"uint32": "uint", | ||
"int64": "int64_t", | ||
"uint64": "uint64_t", | ||
"float32": "float", | ||
"float64": "double", | ||
"bool": "bool", | ||
"string": "string", | ||
"placeholder": "void*", | ||
"var": "{0} {1};", | ||
"array": "std::vector<{}>", | ||
"structStart": "struct {}{{", | ||
"structEnd": "};", | ||
"usingArray": "#include <vector>", | ||
"usingString": "#include <string>", | ||
"extension": "h" | ||
} |
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,18 @@ | ||
{ | ||
"int32": "int", | ||
"uint32": "uint", | ||
"int64": "int64_t", | ||
"uint64": "uint64_t", | ||
"float32": "float", | ||
"float64": "double", | ||
"bool": "bool", | ||
"string": "string", | ||
"placeholder": "void*", | ||
"var": "{0} {1};", | ||
"array": "std::vector<{}>", | ||
"structStart": "struct {} {{", | ||
"structEnd": "};", | ||
"usingArray": "#include <vector>", | ||
"usingString": "#include <string>", | ||
"extension": "h" | ||
} |
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,18 @@ | ||
{ | ||
"int32": "", | ||
"uint32": "", | ||
"int64": "", | ||
"uint64": "", | ||
"float32": "", | ||
"float64": "", | ||
"bool": "", | ||
"string": "", | ||
"placeholder": "", | ||
"var": "", | ||
"array": "", | ||
"structStart": "", | ||
"structEnd": "", | ||
"usingArray": "", | ||
"usingString": "", | ||
"extension": "" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <fstream> | ||
#include "LangFormat.h" | ||
#include "rapidjson/document.h" | ||
#include "rapidjson/error/en.h" | ||
#include "fmt/format.h" | ||
|
||
void LangFormat::parseFormatByName(std::string name) | ||
{ | ||
//Load JSON file | ||
std::ifstream formatFile(USER_FORMATS_PATH + name + ".json"); | ||
|
||
if (!formatFile.is_open()) { | ||
throw std::exception(fmt::format("\"{}\" is not a supported language or could not be found in {}\n", name, USER_FORMATS_PATH).c_str()); | ||
} | ||
|
||
//Read file contents into a string | ||
std::string json((std::istreambuf_iterator<char>(formatFile)), | ||
std::istreambuf_iterator<char>()); | ||
|
||
rapidjson::Document doc; | ||
doc.Parse(json.c_str()); | ||
if (doc.HasParseError()) { | ||
throw std::exception( | ||
fmt::format("ERROR: User format file: (offset {}}): {}\n", | ||
(unsigned)doc.GetErrorOffset(), | ||
GetParseError_En(doc.GetParseError())).c_str() | ||
); | ||
} | ||
|
||
this->int32_t = doc["int32"].GetString(); | ||
this->uint32_t = doc["uint32"].GetString(); | ||
this->int64_t = doc["int64"].GetString(); | ||
this->uint64_t = doc["uint64"].GetString(); | ||
this->float_t = doc["float32"].GetString(); | ||
this->double_t = doc["float64"].GetString(); | ||
this->bool_t = doc["bool"].GetString(); | ||
this->string_t = doc["string"].GetString(); | ||
this->placeholder_t = doc["placeholder"].GetString(); | ||
this->var_format = doc["var"].GetString(); | ||
this->array_format = doc["array"].GetString(); | ||
this->structS_format = doc["structStart"].GetString(); | ||
this->structE_format = doc["structEnd"].GetString(); | ||
this->using_array = doc["usingArray"].GetString(); | ||
this->using_string = doc["usingString"].GetString(); | ||
this->file_extension = doc["extension"].GetString(); | ||
} |
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
Oops, something went wrong.