OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Semver Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Semver.hpp>

Classes

struct  Major
struct  Minor
struct  Patch

Public Member Functions

 Semver ()
 Semver (int major, int minor, int patch, boost::optional< const std::string & > metadata, boost::optional< const std::string & > prerelease)
 Semver (int major, int minor, int patch, const char *metadata=nullptr, const char *prerelease=nullptr)
 Semver (const std::string &str)
 Semver (Semver &&other)
 Semver (const Semver &other)
Semver & operator= (Semver &&other)
Semver & operator= (const Semver &other)
 ~Semver ()
int maj () const
int min () const
int patch () const
const char * prerelease () const
const char * metadata () const
void set_maj (int maj)
void set_min (int min)
void set_patch (int patch)
void set_metadata (boost::optional< const std::string & > meta)
void set_metadata (const char *meta)
void set_prerelease (boost::optional< const std::string & > pre)
void set_prerelease (const char *pre)
bool operator< (const Semver &b) const
bool operator<= (const Semver &b) const
bool operator== (const Semver &b) const
bool operator!= (const Semver &b) const
bool operator>= (const Semver &b) const
bool operator> (const Semver &b) const
bool operator& (const Semver &b) const
bool operator^ (const Semver &b) const
bool in_range (const Semver &low, const Semver &high) const
bool valid () const
std::string to_string () const
std::string to_string_sf () const
Semver & operator+= (const Major &b)
Semver & operator+= (const Minor &b)
Semver & operator+= (const Patch &b)
Semver & operator-= (const Major &b)
Semver & operator-= (const Minor &b)
Semver & operator-= (const Patch &b)
Semver operator+ (const Major &b) const
Semver operator+ (const Minor &b) const
Semver operator+ (const Patch &b) const
Semver operator- (const Major &b) const
Semver operator- (const Minor &b) const
Semver operator- (const Patch &b) const
template<class Archive>
std::string save_minimal (const Archive &) const
template<class Archive>
void load_minimal (const Archive &, const std::string &s)

Static Public Member Functions

static boost::optional< Semver > parse (const std::string &str)
static const Semver zero ()
static const Semver inf ()
static const Semver invalid ()

Private Member Functions

 Semver (semver_t ver)

Static Private Member Functions

static semver_t semver_zero ()
static char * strdup (const std::string &str)

Private Attributes

semver_t ver

Friends

std::ostream & operator<< (std::ostream &os, const Semver &self)

Detailed Description

Constructor & Destructor Documentation

◆ Semver() [1/7]

Slic3r::Semver::Semver ( )
inline
30: ver(semver_zero()) {}
static semver_t semver_zero()
Definition Semver.hpp:216
semver_t ver
Definition Semver.hpp:212

References semver_zero(), and ver.

Referenced by Semver(), Semver(), in_range(), inf(), invalid(), operator!=(), operator&(), operator+(), operator+(), operator+(), operator+=(), operator+=(), operator+=(), operator-(), operator-(), operator-(), operator-=(), operator-=(), operator-=(), operator<(), operator<<, operator<=(), operator=(), operator=(), operator==(), operator>(), operator>=(), operator^(), parse(), and zero().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Semver() [2/7]

Slic3r::Semver::Semver ( int major,
int minor,
int patch,
boost::optional< const std::string & > metadata,
boost::optional< const std::string & > prerelease )
inline
34 : ver(semver_zero())
35 {
36 ver.major = major;
37 ver.minor = minor;
38 ver.patch = patch;
41 }
int patch() const
Definition Semver.hpp:110
void set_prerelease(boost::optional< const std::string & > pre)
Definition Semver.hpp:130
const char * metadata() const
Definition Semver.hpp:112
void set_metadata(boost::optional< const std::string & > meta)
Definition Semver.hpp:118
const char * prerelease() const
Definition Semver.hpp:111

References metadata(), patch(), prerelease(), semver_zero(), set_metadata(), set_prerelease(), and ver.

Here is the call graph for this function:

◆ Semver() [3/7]

Slic3r::Semver::Semver ( int major,
int minor,
int patch,
const char * metadata = nullptr,
const char * prerelease = nullptr )
inline
44 : ver(semver_zero())
45 {
46 ver.major = major;
47 ver.minor = minor;
48 ver.patch = patch;
51 }

References metadata(), patch(), prerelease(), semver_zero(), set_metadata(), set_prerelease(), and ver.

Here is the call graph for this function:

◆ Semver() [4/7]

Slic3r::Semver::Semver ( const std::string & str)
inline
53 : ver(semver_zero())
54 {
55 auto parsed = parse(str);
56 if (! parsed) {
57 throw Slic3r::RuntimeError(std::string("Could not parse version string: ") + str);
58 }
59 ver = parsed->ver;
60 parsed->ver = semver_zero();
61 }
static boost::optional< Semver > parse(const std::string &str)
Definition Semver.hpp:63

References parse(), semver_zero(), and ver.

Here is the call graph for this function:

◆ Semver() [5/7]

Slic3r::Semver::Semver ( Semver && other)
inline
87: ver(other.ver) { other.ver = semver_zero(); }

References Semver(), semver_zero(), and ver.

Here is the call graph for this function:

◆ Semver() [6/7]

Slic3r::Semver::Semver ( const Semver & other)
inline
88: ver(::semver_copy(&other.ver)) {}

References Semver(), and ver.

Here is the call graph for this function:

◆ ~Semver()

Slic3r::Semver::~Semver ( )
inline
105{ ::semver_free(&ver); }

References ver.

◆ Semver() [7/7]

Slic3r::Semver::Semver ( semver_t ver)
inlineprivate
214: ver(ver) {}

References ver.

Member Function Documentation

◆ in_range()

bool Slic3r::Semver::in_range ( const Semver & low,
const Semver & high ) const
inline
154{ return low <= *this && *this <= high; }

References Semver().

Referenced by Slic3r::GUI::Config::Version::is_slic3r_supported().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inf()

const Semver Slic3r::Semver::inf ( )
inlinestatic
76 {
77 static semver_t ver = { std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr, nullptr };
78 return Semver(ver);
79 }
Semver()
Definition Semver.hpp:30

References Semver(), and ver.

Referenced by Slic3r::anonymous_namespace{PresetCacheFormat.cpp}::cache_covers_version(), Slic3r::PresetBundle::read_vendor(), and valid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invalid()

const Semver Slic3r::Semver::invalid ( )
inlinestatic
82 {
83 static semver_t ver = { -1, 0, 0, nullptr, nullptr };
84 return Semver(ver);
85 }

References Semver(), and ver.

Referenced by Slic3r::GUI::Config::Snapshot::clear(), Slic3r::GUI::get_version(), Slic3r::installable_cache_version(), Slic3r::VendorCacheFile::usable_version(), and valid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_minimal()

template<class Archive>
void Slic3r::Semver::load_minimal ( const Archive & ,
const std::string & s )
inline
204 {
205 auto v = Semver::parse(s);
206 if (! v)
207 throw std::runtime_error("Semver: cannot parse serialized version: " + s);
208 *this = std::move(*v);
209 }

References parse().

Here is the call graph for this function:

◆ maj()

int Slic3r::Semver::maj ( ) const
inline

◆ metadata()

const char * Slic3r::Semver::metadata ( ) const
inline
112{ return ver.metadata; }

References ver.

Referenced by Semver(), and Semver().

Here is the caller graph for this function:

◆ min()

int Slic3r::Semver::min ( ) const
inline

◆ operator!=()

bool Slic3r::Semver::operator!= ( const Semver & b) const
inline
147{ return ::semver_compare(ver, b.ver) != 0; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator&()

bool Slic3r::Semver::operator& ( const Semver & b) const
inline
152{ return ::semver_satisfies_patch(ver, b.ver) != 0; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator+() [1/3]

Semver Slic3r::Semver::operator+ ( const Major & b) const
inline
186{ Semver res(*this); return res += b; }

References Semver().

Here is the call graph for this function:

◆ operator+() [2/3]

Semver Slic3r::Semver::operator+ ( const Minor & b) const
inline
187{ Semver res(*this); return res += b; }

References Semver().

Here is the call graph for this function:

◆ operator+() [3/3]

Semver Slic3r::Semver::operator+ ( const Patch & b) const
inline
188{ Semver res(*this); return res += b; }

References Semver().

Here is the call graph for this function:

◆ operator+=() [1/3]

Semver & Slic3r::Semver::operator+= ( const Major & b)
inline
180{ ver.major += b.i; return *this; }

References Semver(), Slic3r::Semver::Major::i, and ver.

Here is the call graph for this function:

◆ operator+=() [2/3]

Semver & Slic3r::Semver::operator+= ( const Minor & b)
inline
181{ ver.minor += b.i; return *this; }

References Semver(), Slic3r::Semver::Minor::i, and ver.

Here is the call graph for this function:

◆ operator+=() [3/3]

Semver & Slic3r::Semver::operator+= ( const Patch & b)
inline
182{ ver.patch += b.i; return *this; }

References Semver(), Slic3r::Semver::Patch::i, and ver.

Here is the call graph for this function:

◆ operator-() [1/3]

Semver Slic3r::Semver::operator- ( const Major & b) const
inline
189{ Semver res(*this); return res -= b; }

References Semver().

Here is the call graph for this function:

◆ operator-() [2/3]

Semver Slic3r::Semver::operator- ( const Minor & b) const
inline
190{ Semver res(*this); return res -= b; }

References Semver().

Here is the call graph for this function:

◆ operator-() [3/3]

Semver Slic3r::Semver::operator- ( const Patch & b) const
inline
191{ Semver res(*this); return res -= b; }

References Semver().

Here is the call graph for this function:

◆ operator-=() [1/3]

Semver & Slic3r::Semver::operator-= ( const Major & b)
inline
183{ ver.major -= b.i; return *this; }

References Semver(), Slic3r::Semver::Major::i, and ver.

Here is the call graph for this function:

◆ operator-=() [2/3]

Semver & Slic3r::Semver::operator-= ( const Minor & b)
inline
184{ ver.minor -= b.i; return *this; }

References Semver(), Slic3r::Semver::Minor::i, and ver.

Here is the call graph for this function:

◆ operator-=() [3/3]

Semver & Slic3r::Semver::operator-= ( const Patch & b)
inline
185{ ver.patch -= b.i; return *this; }

References Semver(), Slic3r::Semver::Patch::i, and ver.

Here is the call graph for this function:

◆ operator<()

bool Slic3r::Semver::operator< ( const Semver & b) const
inline
144{ return ::semver_compare(ver, b.ver) == -1; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator<=()

bool Slic3r::Semver::operator<= ( const Semver & b) const
inline
145{ return ::semver_compare(ver, b.ver) <= 0; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator=() [1/2]

Semver & Slic3r::Semver::operator= ( const Semver & other)
inline
99 {
100 ::semver_free(&ver);
101 ver = ::semver_copy(&other.ver);
102 return *this;
103 }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator=() [2/2]

Semver & Slic3r::Semver::operator= ( Semver && other)
inline
91 {
92 ::semver_free(&ver);
93 ver = other.ver;
94 other.ver = semver_zero();
95 return *this;
96 }

References Semver(), semver_zero(), and ver.

Here is the call graph for this function:

◆ operator==()

bool Slic3r::Semver::operator== ( const Semver & b) const
inline
146{ return ::semver_compare(ver, b.ver) == 0; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator>()

bool Slic3r::Semver::operator> ( const Semver & b) const
inline
149{ return ::semver_compare(ver, b.ver) == 1; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator>=()

bool Slic3r::Semver::operator>= ( const Semver & b) const
inline
148{ return ::semver_compare(ver, b.ver) >= 0; }

References Semver(), and ver.

Here is the call graph for this function:

◆ operator^()

bool Slic3r::Semver::operator^ ( const Semver & b) const
inline
153{ return ::semver_satisfies_caret(ver, b.ver) != 0; }

References Semver(), and ver.

Here is the call graph for this function:

◆ parse()

boost::optional< Semver > Slic3r::Semver::parse ( const std::string & str)
inlinestatic
64 {
65 semver_t ver = semver_zero();
66 if (::semver_parse(str.c_str(), &ver) == 0) {
67 return Semver(ver);
68 } else {
69 return boost::none;
70 }
71 }

References Semver(), semver_zero(), and ver.

Referenced by Semver(), Slic3r::_BBS_3MF_Importer::_extract_project_embedded_presets_from_archive(), Slic3r::_3MF_Importer::_generate_volumes(), Slic3r::_3MF_Importer::_handle_end_metadata(), Slic3r::_BBS_3MF_Importer::_handle_end_metadata(), Slic3r::PresetCollection::add_detached_preset(), Slic3r::anonymous_namespace{PresetCacheFormat.cpp}::cache_covers_version(), Slic3r::GUI::GUI_App::check_bundle_updates(), Slic3r::GUI::GUI_App::check_privacy_update(), Slic3r::GUI::GUI_App::check_update(), Slic3r::GUI::compare_plugin_version(), Slic3r::GUI::PresetBundleDialog::CompareVer(), Slic3r::GUI::GUI_App::download_plugin(), Slic3r::PresetUpdater::priv::get_config_updates(), Slic3r::GUI::Newer3mfVersionDialog::get_msg_sizer(), Slic3r::GUI::get_version(), Slic3r::get_version_from_json(), Slic3r::PresetBundle::import_json_presets(), Slic3r::installable_cache_version(), Slic3r::anonymous_namespace{PluginManager.cpp}::is_cloud_version_newer(), Slic3r::AppConfig::load(), Slic3r::GUI::Config::Index::load(), Slic3r::GUI::Plater::priv::load_files(), Slic3r::GUI::Config::Snapshot::load_ini(), load_minimal(), Slic3r::PresetCollection::load_user_preset(), Slic3r::GUI::parse_semver_from_ini(), Slic3r::PresetBundle::parse_vendor_json(), Slic3r::PresetUpdater::priv::parse_version_string(), Slic3r::PresetCollection::resolve_user_preset(), Slic3r::CLI::run(), Slic3r::GUI::GUI_App::sync_bundle(), and Slic3r::VendorCacheFile::usable_version().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ patch()

int Slic3r::Semver::patch ( ) const
inline
110{ return ver.patch; }

References ver.

Referenced by Semver(), Semver(), set_patch(), Slic3r::PresetUpdater::priv::sync_plugins(), Slic3r::PresetUpdater::priv::sync_printer_config(), and Slic3r::PresetUpdater::priv::sync_resources().

Here is the caller graph for this function:

◆ prerelease()

const char * Slic3r::Semver::prerelease ( ) const
inline
111{ return ver.prerelease; }

References ver.

Referenced by Semver(), Semver(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::Config::Version::is_slic3r_supported(), and Slic3r::GUI::should_dialog_be_shown().

Here is the caller graph for this function:

◆ save_minimal()

template<class Archive>
std::string Slic3r::Semver::save_minimal ( const Archive & ) const
inline
202{ return to_string_sf(); }
std::string to_string_sf() const
Definition Semver.hpp:169

References to_string_sf().

Here is the call graph for this function:

◆ semver_zero()

semver_t Slic3r::Semver::semver_zero ( )
inlinestaticprivate
216{ return { 0, 0, 0, nullptr, nullptr }; }

Referenced by Semver(), Semver(), Semver(), Semver(), Semver(), operator=(), parse(), and zero().

Here is the caller graph for this function:

◆ set_maj()

void Slic3r::Semver::set_maj ( int maj)
inline
115{ ver.major = maj; }
int maj() const
Definition Semver.hpp:108

References maj(), and ver.

Here is the call graph for this function:

◆ set_metadata() [1/2]

void Slic3r::Semver::set_metadata ( boost::optional< const std::string & > meta)
inline
119 {
120 if (ver.metadata)
121 free(ver.metadata);
122 ver.metadata = meta ? strdup(*meta) : nullptr;
123 }
static char * strdup(const std::string &str)
Definition Semver.hpp:217

References strdup(), and ver.

Referenced by Semver(), and Semver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_metadata() [2/2]

void Slic3r::Semver::set_metadata ( const char * meta)
inline
125 {
126 if (ver.metadata)
127 free(ver.metadata);
128 ver.metadata = meta ? strdup(meta) : nullptr;
129 }

References strdup(), and ver.

Here is the call graph for this function:

◆ set_min()

void Slic3r::Semver::set_min ( int min)
inline
116{ ver.minor = min; }
int min() const
Definition Semver.hpp:109

References min(), and ver.

Here is the call graph for this function:

◆ set_patch()

void Slic3r::Semver::set_patch ( int patch)
inline
117{ ver.patch = patch; }

References patch(), and ver.

Here is the call graph for this function:

◆ set_prerelease() [1/2]

void Slic3r::Semver::set_prerelease ( boost::optional< const std::string & > pre)
inline
131 {
132 if (ver.prerelease)
133 free(ver.prerelease);
134 ver.prerelease = pre ? strdup(*pre) : nullptr;
135 }

References strdup(), and ver.

Referenced by Semver(), and Semver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_prerelease() [2/2]

void Slic3r::Semver::set_prerelease ( const char * pre)
inline
137 {
138 if (ver.prerelease)
139 free(ver.prerelease);
140 ver.prerelease = pre ? strdup(pre) : nullptr;
141 }

References strdup(), and ver.

Here is the call graph for this function:

◆ strdup()

char * Slic3r::Semver::strdup ( const std::string & str)
inlinestaticprivate
217{ return ::semver_strdup(str.data()); }

Referenced by set_metadata(), set_metadata(), set_prerelease(), and set_prerelease().

Here is the caller graph for this function:

◆ to_string()

std::string Slic3r::Semver::to_string ( ) const
inline
158 {
159 //BBS: version format
160 std::string res;
161 int patch_1 = ver.patch/100;
162 int patch_2 = ver.patch%100;
163 res = (boost::format("%1%.%2%.%3%.%4%") % ver.major % ver.minor % patch_1 % patch_2).str();
164
165 if (ver.prerelease != nullptr) { res += '-'; res += ver.prerelease; }
166 if (ver.metadata != nullptr) { res += '+'; res += ver.metadata; }
167 return res;
168 }

References ver.

Referenced by Slic3r::_BBS_3MF_Exporter::_add_project_embedded_presets_to_archive(), Slic3r::GUI::GuideFrame::BuildProfileDataFromVendors(), Slic3r::PresetUpdater::priv::check_installed_vendor_profiles(), Slic3r::PresetUpdater::priv::check_new_vendors(), Slic3r::PresetUpdater::config_update(), Slic3r::GUI::GUI_App::download_plugin(), Slic3r::PresetBundle::export_current_configs(), Slic3r::GUI::get_config_json(), Slic3r::PresetUpdater::priv::get_config_updates(), Slic3r::GUI::Newer3mfVersionDialog::get_msg_sizer(), Slic3r::GUI::Plater::priv::load_files(), operator<<, Slic3r::PresetBundle::parse_vendor_json(), Slic3r::CLI::run(), and Slic3r::PresetUpdater::priv::sync_resources().

Here is the caller graph for this function:

◆ to_string_sf()

std::string Slic3r::Semver::to_string_sf ( ) const
inline
169 {
170 //BBS: version format
171 std::string res;
172 res = (boost::format("%1%.%2%.%3%") % ver.major % ver.minor % ver.patch).str();
173
174 if (ver.prerelease != nullptr) { res += '-'; res += ver.prerelease; }
175 if (ver.metadata != nullptr) { res += '+'; res += ver.metadata; }
176 return res;
177 }

References ver.

Referenced by Slic3r::GUI::GUI_App::check_new_version_sf(), Slic3r::GUI::Plater::priv::load_files(), and save_minimal().

Here is the caller graph for this function:

◆ valid()

bool Slic3r::Semver::valid ( ) const
inline
155{ return *this != zero() && *this != inf() && *this != invalid(); }
static const Semver zero()
Definition Semver.hpp:73
static const Semver inf()
Definition Semver.hpp:75
static const Semver invalid()
Definition Semver.hpp:81

References inf(), invalid(), and zero().

Referenced by Slic3r::GUI::GuideFrame::BuildProfileDataFromVendors(), Slic3r::cache_covers(), Slic3r::anonymous_namespace{PresetCacheFormat.cpp}::cache_covers_version(), Slic3r::GUI::GUI_App::check_new_version_sf(), Slic3r::PresetUpdater::priv::get_config_updates(), Slic3r::is_vendor_installed(), Slic3r::PresetCollection::load_preset(), Slic3r::PresetBundle::parse_vendor_json(), and Slic3r::resource_vendor_version().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zero()

const Semver Slic3r::Semver::zero ( )
inlinestatic
73{ return Semver(semver_zero()); }

References Semver(), and semver_zero().

Referenced by valid(), and Slic3r::GUI::Config::Index::version().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Semver & self )
friend
194 {
195 os << self.to_string();
196 return os;
197 }

References Semver(), and to_string().

Member Data Documentation

◆ ver


The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Semver.hpp