Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use boost for JSON parsing #923

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5e0c681
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 1, 2023
d5f7361
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 3, 2023
d08bfcf
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Apr 25, 2024
5126833
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk May 3, 2024
7fb35f5
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Jul 22, 2024
ad5c297
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Aug 15, 2024
08daa5b
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Sep 2, 2024
4354d63
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Oct 3, 2024
606f5d4
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Oct 14, 2024
d7dc075
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Oct 14, 2024
b7ce610
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Nov 2, 2024
bd42430
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Nov 15, 2024
4f72ce2
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Nov 21, 2024
a86672e
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Nov 25, 2024
cc621ff
Use boost for JSON parsing
royfalk Dec 2, 2024
4ac74e8
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 5, 2024
c12cd37
Try and fix CMake errors
royfalk Dec 6, 2024
89b7966
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 8, 2024
b46c233
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 8, 2024
0a95c09
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 8, 2024
a6bedff
Add boost-json to bootstrap
royfalk Dec 8, 2024
a41580f
Remove support for Jammy and Focal
royfalk Dec 8, 2024
89b1960
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Dec 8, 2024
5898c41
Merge from master
royfalk Dec 8, 2024
f6116df
Make GitHub.ci run bootstrap
royfalk Dec 10, 2024
c1445b2
Multiple fixes
royfalk Dec 10, 2024
ebd6df4
Upgrade from jammy to noble
royfalk Dec 10, 2024
cbbe29a
Fix cmake to use python38 instead of python3
royfalk Dec 14, 2024
f1448dc
Fix cmake part 2
royfalk Dec 14, 2024
56618c7
More attempts to fix cmake
royfalk Dec 15, 2024
dcbbc03
Another attempt - this time run in docker
royfalk Dec 15, 2024
50f4d78
Add missing quotes
royfalk Dec 15, 2024
b636abc
Try without sudo
royfalk Dec 15, 2024
308f2a6
Fix some more distros in bootstrap
royfalk Dec 15, 2024
c325ade
Remove some unsupported distros
royfalk Dec 16, 2024
bb1abbd
Fix bookworm typo
royfalk Dec 16, 2024
9132479
Disable rocky Linux due to bug
royfalk Dec 16, 2024
ad0d91e
Fix bookworm libboost-program-options
royfalk Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 23 additions & 53 deletions engine/CMakeLists.txt

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions engine/src/cmd/carrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,13 @@
#include "vs_logging.h"
#include "vega_cast_utils.h"

#include "json.h"

// TODO: find out where this is and maybe refactor
extern int SelectDockPort(Unit *, Unit *parent);
extern void SwitchUnits(Unit *, Unit *);
extern void abletodock(int dock);

// Replace with std:sto* here and at unit_csv.cpp
static double stof(const string &inp, double def = 0) {
if (inp.length() != 0) {
return XMLSupport::parse_float(inp);
}
return def;
}

static int stoi(const string &inp, int def = 0) {
if (inp.length() != 0) {
return XMLSupport::parse_int(inp);
}
return def;
}

// TODO: probably replace with a lambda expression
class CatCompare {
Expand Down
39 changes: 25 additions & 14 deletions engine/src/cmd/controls_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
#include <vector>
#include <string>
#include <map>
#include <boost/json.hpp>

#include "json.h"
#include "drawable.h"
#include "vs_globals.h"
#include "configxml.h"
#include "resource/json_utils.h"

#include "gui/staticdisplay.h"
#include "gui/newbutton.h"
Expand All @@ -55,24 +56,34 @@ std::map<std::string, std::map<std::string, std::string>> parseControlsJSON(VSFi

std::map<std::string, std::map<std::string, std::string>> controls_map;

std::vector<std::string> controls_json = json::parsing::parse_array(json_text.c_str());
// Iterate over root
for (const std::string &control_text : controls_json) {
json::jobject control_json = json::jobject::parse(control_text);
boost::json::value json_value = boost::json::parse(json_text);
boost::json::array root_array = json_value.get_array();

for(boost::json::value& control_value : root_array) {
boost::json::object control = control_value.get_object();
std::map<std::string, std::string> control_attributes;

for (const std::string &key : keys) {
// For some reason, parser adds quotes
if(control_json.has_key(key)) {
const std::string attribute = control_json.get(key);
const std::string stripped_attribute = attribute.substr(1, attribute.size() - 2);
control_attributes[key] = stripped_attribute;
}
}
if(!control.if_contains(key)) {
continue;
}

// Worked in singleson because it saw everything as string.
if(key == "multiline") {
bool multiline = JsonGetWithDefault(control, key, false);
if(multiline) {
control_attributes["multiline"] = "true";
} else {
control_attributes["multiline"] = "false";
}
} else {
const std::string attribute = JsonGetStringWithDefault(control, key, "");
control_attributes[key] = attribute;
}
}

controls_map[control_attributes["name"]] = control_attributes;
}
}

return controls_map;
}
Expand Down
Loading
Loading