Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Semver Class Reference

#include <src/libslic3r/Semver.hpp>

+ Collaboration diagram for Slic3r::Semver:

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)
 
Semveroperator= (Semver &&other)
 
Semveroperator= (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
 
Semveroperator+= (const Major &b)
 
Semveroperator+= (const Minor &b)
 
Semveroperator+= (const Patch &b)
 
Semveroperator-= (const Major &b)
 
Semveroperator-= (const Minor &b)
 
Semveroperator-= (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
 

Static Public Member Functions

static boost::optional< Semverparse (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
25: ver(semver_zero()) {}
static semver_t semver_zero()
Definition Semver.hpp:184
semver_t ver
Definition Semver.hpp:180

Referenced by inf(), invalid(), parse(), and zero().

+ 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
29 : ver(semver_zero())
30 {
31 ver.major = major;
32 ver.minor = minor;
33 ver.patch = patch;
36 }
int patch() const
Definition Semver.hpp:105
void set_prerelease(boost::optional< const std::string & > pre)
Definition Semver.hpp:125
const char * metadata() const
Definition Semver.hpp:107
void set_metadata(boost::optional< const std::string & > meta)
Definition Semver.hpp:113
const char * prerelease() const
Definition Semver.hpp:106
int minor
Definition semver.h:25
int patch
Definition semver.h:26
int major
Definition semver.h:24

References semver_version_s::major, metadata(), semver_version_s::minor, patch(), semver_version_s::patch, prerelease(), 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
39 : ver(semver_zero())
40 {
41 ver.major = major;
42 ver.minor = minor;
43 ver.patch = patch;
46 }

References semver_version_s::major, metadata(), semver_version_s::minor, patch(), semver_version_s::patch, prerelease(), 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
48 : ver(semver_zero())
49 {
50 auto parsed = parse(str);
51 if (! parsed) {
52 throw Slic3r::RuntimeError(std::string("Could not parse version string: ") + str);
53 }
54 ver = parsed->ver;
55 parsed->ver = semver_zero();
56 }
static boost::optional< Semver > parse(const std::string &str)
Definition Semver.hpp:58

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

+ Here is the call graph for this function:

◆ Semver() [5/7]

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

References semver_zero().

+ Here is the call graph for this function:

◆ Semver() [6/7]

Slic3r::Semver::Semver ( const Semver other)
inline
83: ver(::semver_copy(&other.ver)) {}
semver_t semver_copy(const semver_t *ver)
Definition semver.c:636

◆ ~Semver()

Slic3r::Semver::~Semver ( )
inline
100{ ::semver_free(&ver); }
void semver_free(semver_t *x)
Definition semver.c:474

References semver_free(), and ver.

+ Here is the call graph for this function:

◆ Semver() [7/7]

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

Member Function Documentation

◆ in_range()

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

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

+ Here is the caller graph for this function:

◆ inf()

static const Semver Slic3r::Semver::inf ( )
inlinestatic
71 {
72 static semver_t ver = { std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr, nullptr };
73 return Semver(ver);
74 }
Semver()
Definition Semver.hpp:25
Definition semver.h:23

References Semver(), and ver.

Referenced by Slic3r::PresetUpdater::config_update(), Slic3r::GUI::generate_html_row(), and valid().

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

◆ invalid()

static const Semver Slic3r::Semver::invalid ( )
inlinestatic
77 {
78 static semver_t ver = { -1, 0, 0, nullptr, nullptr };
79 return Semver(ver);
80 }

References Semver(), and ver.

Referenced by Slic3r::GUI::Config::Snapshot::clear(), Slic3r::GUI::parse_version_string(), Slic3r::AppConfig::reset(), and valid().

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

◆ maj()

int Slic3r::Semver::maj ( ) const
inline
103{ return ver.major; }

References semver_version_s::major, and ver.

Referenced by Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), set_maj(), and Slic3r::GUI::should_dialog_be_shown().

+ Here is the caller graph for this function:

◆ metadata()

const char * Slic3r::Semver::metadata ( ) const
inline
107{ return ver.metadata; }
char * metadata
Definition semver.h:27

References semver_version_s::metadata, and ver.

Referenced by Semver(), and Semver().

+ Here is the caller graph for this function:

◆ min()

int Slic3r::Semver::min ( ) const
inline
104{ return ver.minor; }

References semver_version_s::minor, and ver.

Referenced by Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), set_min(), and Slic3r::GUI::should_dialog_be_shown().

+ Here is the caller graph for this function:

◆ operator!=()

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

References ver.

◆ operator&()

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

References ver.

◆ operator+() [1/3]

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

◆ operator+() [2/3]

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

◆ operator+() [3/3]

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

◆ operator+=() [1/3]

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

References semver_version_s::major, and ver.

◆ operator+=() [2/3]

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

References semver_version_s::minor, and ver.

◆ operator+=() [3/3]

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

References semver_version_s::patch, and ver.

◆ operator-() [1/3]

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

◆ operator-() [2/3]

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

◆ operator-() [3/3]

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

◆ operator-=() [1/3]

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

References semver_version_s::major, and ver.

◆ operator-=() [2/3]

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

References semver_version_s::minor, and ver.

◆ operator-=() [3/3]

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

References semver_version_s::patch, and ver.

◆ operator<()

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

References ver.

◆ operator<=()

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

References ver.

◆ operator=() [1/2]

Semver & Slic3r::Semver::operator= ( const Semver other)
inline
94 {
96 ver = ::semver_copy(&other.ver);
97 return *this;
98 }

References semver_copy(), semver_free(), and ver.

+ Here is the call graph for this function:

◆ operator=() [2/2]

Semver & Slic3r::Semver::operator= ( Semver &&  other)
inline
86 {
88 ver = other.ver;
89 other.ver = semver_zero();
90 return *this;
91 }

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

+ Here is the call graph for this function:

◆ operator==()

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

References ver.

◆ operator>()

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

References ver.

◆ operator>=()

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

References ver.

◆ operator^()

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

References ver.

◆ parse()

static boost::optional< Semver > Slic3r::Semver::parse ( const std::string &  str)
inlinestatic
59 {
61 if (::semver_parse(str.c_str(), &ver) == 0) {
62 return Semver(ver);
63 } else {
64 return boost::none;
65 }
66 }
int semver_parse(const char *str, semver_t *ver)
Definition semver.c:142

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

Referenced by Semver(), Slic3r::GUI::GUI_App::app_updater(), Slic3r::GUI::Config::Index::load(), Slic3r::AppConfig::load(), Slic3r::GUI::Config::Snapshot::load_ini(), Slic3r::GUI::GUI_App::on_init_inner(), Slic3r::GUI::GUI_App::on_version_read(), Slic3r::GUI::parse_semver_from_ini(), Slic3r::AppUpdater::priv::parse_version_string(), and Slic3r::PresetUpdater::slic3r_update_notify().

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

◆ patch()

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

References semver_version_s::patch, and ver.

Referenced by Semver(), Semver(), and set_patch().

+ Here is the caller graph for this function:

◆ prerelease()

const char * Slic3r::Semver::prerelease ( ) const
inline
106{ return ver.prerelease; }
char * prerelease
Definition semver.h:28

References semver_version_s::prerelease, and ver.

Referenced by Slic3r::GUI::MsgUpdateSlic3r::MsgUpdateSlic3r(), 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:

◆ semver_zero()

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

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

+ Here is the caller graph for this function:

◆ set_maj()

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

References maj(), semver_version_s::major, 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
114 {
115 if (ver.metadata)
117 ver.metadata = meta ? strdup(*meta) : nullptr;
118 }
static char * strdup(const std::string &str)
Definition Semver.hpp:185
void free(void *)

References free(), semver_version_s::metadata, strdup(), and ver.

Referenced by Semver(), Semver(), and Slic3r::AppConfig::load().

+ 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
120 {
121 if (ver.metadata)
123 ver.metadata = meta ? strdup(meta) : nullptr;
124 }

References free(), semver_version_s::metadata, strdup(), and ver.

+ Here is the call graph for this function:

◆ set_min()

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

References min(), semver_version_s::minor, and ver.

+ Here is the call graph for this function:

◆ set_patch()

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

References patch(), semver_version_s::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
126 {
127 if (ver.prerelease)
129 ver.prerelease = pre ? strdup(*pre) : nullptr;
130 }

References free(), semver_version_s::prerelease, 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
132 {
133 if (ver.prerelease)
135 ver.prerelease = pre ? strdup(pre) : nullptr;
136 }

References free(), semver_version_s::prerelease, strdup(), and ver.

+ Here is the call graph for this function:

◆ strdup()

static char * Slic3r::Semver::strdup ( const std::string &  str)
inlinestaticprivate
185{ 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()

◆ valid()

bool Slic3r::Semver::valid ( ) const
inline
150{ return *this != zero() && *this != inf() && *this != invalid(); }
static const Semver zero()
Definition Semver.hpp:68
static const Semver inf()
Definition Semver.hpp:70
static const Semver invalid()
Definition Semver.hpp:76

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

Referenced by Slic3r::GUI::GUI_App::on_init_inner(), and Slic3r::VendorProfile::valid().

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

◆ zero()

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

References Semver(), and semver_zero().

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

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

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Semver self 
)
friend
175 {
176 os << self.to_string();
177 return os;
178 }

Member Data Documentation

◆ ver


The documentation for this class was generated from the following file: