src/slic3r/GUI/DeviceCore/DevUtil.h:49:36: error: ‘BOOST_LOG_TRIVIAL’ was not declared in this scope
49 | BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
| ^
(cherry picked from commit 6c830d11e9066bc1afeb1f321f47e8e95931cb4a)
72 lines
1.7 KiB
C++
72 lines
1.7 KiB
C++
/**
|
|
* @file DevUtil.h
|
|
* @brief Provides common static utility methods for general use.
|
|
*
|
|
* This class offers a collection of static helper functions such as string manipulation,
|
|
* file operations, and other frequently used utilities.
|
|
*/
|
|
|
|
#pragma once
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
|
|
#include <boost/log/trivial.hpp>
|
|
#include "nlohmann/json.hpp"
|
|
|
|
namespace Slic3r
|
|
{
|
|
|
|
class DevUtil
|
|
{
|
|
public:
|
|
DevUtil() = delete;
|
|
DevUtil(const DevUtil&) = delete;
|
|
DevUtil& operator=(const DevUtil&) = delete;
|
|
|
|
public:
|
|
static int get_flag_bits(std::string str, int start, int count = 1);
|
|
static int get_flag_bits(int num, int start, int count = 1, int base = 10);
|
|
|
|
static float string_to_float(const std::string& str_value);
|
|
|
|
static std::string convertToIp(long long ip);
|
|
};
|
|
|
|
|
|
class DevJsonValParser
|
|
{
|
|
public:
|
|
template<typename T>
|
|
static void ParseVal(const nlohmann::json& j, const std::string& key, T& val)
|
|
{
|
|
try
|
|
{
|
|
if (j.contains(key)) { val = j[key].get<T>(); }
|
|
}
|
|
catch (const nlohmann::json::exception& e)
|
|
{
|
|
assert(0 && __FUNCTION__);
|
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
static void ParseVal(const nlohmann::json& j, const std::string& key, T& val, T default_val)
|
|
{
|
|
try
|
|
{
|
|
j.contains(key) ? (val = j[key].get<T>()) : (val = default_val);
|
|
}
|
|
catch (const nlohmann::json::exception& e)
|
|
{
|
|
assert(0 && __FUNCTION__);
|
|
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
|
|
}
|
|
}
|
|
|
|
public:
|
|
static std::string get_longlong_val(const nlohmann::json& j);
|
|
};
|
|
|
|
}; // namespace Slic3r
|