OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
profile_include_dump.cpp File Reference
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/Preset.hpp"
#include "libslic3r/Utils.hpp"
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/nowide/fstream.hpp>
#include "nlohmann/json.hpp"
#include <algorithm>
#include <cstddef>
#include <exception>
#include <iostream>
#include "libslic3r/Config.hpp"
#include <map>
#include <set>
#include <stdexcept>
#include <string>
#include <vector>
#include "libslic3r/PrintConfig.hpp"
Include dependency graph for profile_include_dump.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{profile_include_dump.cpp}::Entry

Namespaces

namespace  anonymous_namespace{profile_include_dump.cpp}

Typedefs

using anonymous_namespace{profile_include_dump.cpp}::Sections = std::map<std::string, std::map<std::string, Entry>>

Functions

json anonymous_namespace{profile_include_dump.cpp}::read_json (const fs::path &path)
Sections anonymous_namespace{profile_include_dump.cpp}::read_vendor (const fs::path &dir, const std::string &vendor)
const PresetCollection & anonymous_namespace{profile_include_dump.cpp}::presets_of (const PresetBundle &bundle, const std::string &section)
size_t anonymous_namespace{profile_include_dump.cpp}::dump (const PresetBundle &bundle, const Sections &sections, std::ostream &out)
void anonymous_namespace{profile_include_dump.cpp}::load_vendor (PresetBundle &bundle, const std::string &dir, const std::string &vendor, bool from_cache)
int main (int argc, char *argv[])

Class Documentation

◆ anonymous_namespace{profile_include_dump.cpp}::Entry

struct anonymous_namespace{profile_include_dump.cpp}::Entry
Collaboration diagram for anonymous_namespace{profile_include_dump.cpp}::Entry:
Class Members
vector< string > includes
string inherits
vector< string > keys

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )
168{
169 const char *usage = "Usage: profile_include_dump -p <profiles dir> -o <dump file> [-v <vendor>] [-l <log level>] [-c]\n"
170 " -v vendor to dump, BBL if omitted\n"
171 " -l log level, 0 (fatal) to 5 (trace); 1 if omitted\n"
172 " -c load the presets from the vendor's preset cache, generated first, not the JSON\n";
173 std::string dir, output, vendor = "BBL";
174 unsigned log_level = 1;
175 bool from_cache = false;
176 for (int i = 1; i < argc; ++i) {
177 const std::string arg = argv[i];
178 if (arg == "-c") {
179 from_cache = true;
180 continue;
181 }
182 if (i + 1 == argc) {
183 std::cerr << usage;
184 return 1;
185 }
186 const std::string value = argv[++i];
187 if (arg == "-p")
188 dir = value;
189 else if (arg == "-o")
190 output = value;
191 else if (arg == "-v")
192 vendor = value;
193 else if (arg == "-l" && value.size() == 1 && value[0] >= '0' && value[0] <= '5')
194 log_level = unsigned(value[0] - '0');
195 else {
196 std::cerr << usage;
197 return 1;
198 }
199 }
200 if (dir.empty() || output.empty() || !fs::is_directory(dir)) {
201 std::cerr << usage;
202 return 1;
203 }
204 set_logging_level(log_level);
205
206 try {
207 PresetBundle bundle;
208 load_vendor(bundle, dir, vendor, from_cache);
209 boost::nowide::ofstream out(output);
210 if (!out)
211 throw std::runtime_error("Cannot write " + output);
212 const size_t dumped = dump(bundle, read_vendor(dir, vendor), out);
213 out.close();
214 if (!out)
215 throw std::runtime_error("Failed writing " + output);
216 std::cerr << "Dumped " << dumped << " " << vendor << " presets that include a template\n";
217 } catch (const std::exception &ex) {
218 std::cerr << ex.what() << "\n";
219 return 1;
220 }
221 return 0;
222}
Definition PresetBundle.hpp:210
void set_logging_level(unsigned int level)
Definition utils.cpp:171
void load_vendor(PresetBundle &bundle, const std::string &dir, const std::string &vendor, bool from_cache)
Definition profile_include_dump.cpp:134
Sections read_vendor(const fs::path &dir, const std::string &vendor)
Definition profile_include_dump.cpp:57
size_t dump(const PresetBundle &bundle, const Sections &sections, std::ostream &out)
Definition profile_include_dump.cpp:96

References anonymous_namespace{profile_include_dump.cpp}::dump(), anonymous_namespace{profile_include_dump.cpp}::load_vendor(), anonymous_namespace{profile_include_dump.cpp}::read_vendor(), and Slic3r::set_logging_level().

Here is the call graph for this function: