mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 13:17:54 -06:00
Ported PlaceholderParser::apply_env_variables() to XS
This commit is contained in:
parent
724e668a94
commit
f361d8ad43
4 changed files with 22 additions and 17 deletions
|
@ -2,14 +2,16 @@
|
|||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <unistd.h> // provides **environ
|
||||
|
||||
extern char **environ;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
PlaceholderParser::PlaceholderParser()
|
||||
{
|
||||
this->_single["version"] = SLIC3R_VERSION;
|
||||
// TODO: port these methods to C++, then call them here
|
||||
// this->apply_env_variables();
|
||||
this->apply_env_variables();
|
||||
this->update_timestamp();
|
||||
}
|
||||
|
||||
|
@ -76,6 +78,21 @@ void PlaceholderParser::apply_config(DynamicPrintConfig &config)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
PlaceholderParser::apply_env_variables()
|
||||
{
|
||||
for (char** env = environ; *env; env++) {
|
||||
if (strncmp(*env, "SLIC3R_", 7) == 0) {
|
||||
std::stringstream ss(*env);
|
||||
std::string key, value;
|
||||
std::getline(ss, key, '=');
|
||||
ss >> value;
|
||||
|
||||
this->set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PlaceholderParser::set(const std::string &key, const std::string &value)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue