PIP 5.5.3
Platform-Independent Primitives
Classes | Functions
pistring.h File Reference

Regular expression. More...

#include "pibytearray.h"
#include "piconstchars.h"

Classes

class  PIString
 String class. More...
 

Functions

template<typename P >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIString &v)
 Store operator.
 
template<typename P >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIString &v)
 Restore operator.
 
PIString operator+ (const PIString &str, const PIString &f)
 Returns concatenated string.
 
PIString operator+ (const PIString &f, const char *str)
 Returns concatenated string.
 
PIString operator+ (const char *str, const PIString &f)
 Returns concatenated string.
 
PIString operator+ (const char c, const PIString &f)
 Returns concatenated string.
 
PIString operator+ (const PIString &f, const char c)
 Returns concatenated string.
 
int versionCompare (const PIString &v0, const PIString &v1, int components=6)
 Compare two version strings in free notation and returns 0, -1 or 1. More...
 
PIString versionNormalize (const PIString &v)
 Converts version string in free notation to classic view. More...
 
template<typename T >
PIString piStringify (const T &v)
 Returns string representation of "v", using PICout operator<<(T)
 

Detailed Description

Regular expression.

String class.

Function Documentation

◆ versionCompare()

int versionCompare ( const PIString v0,
const PIString v1,
int  components = 6 
)

Compare two version strings in free notation and returns 0, -1 or 1.

This function parse version to number codes and labels. Then it compare no more than "components" codes. If there is no difference, compare labels. Each label has corresponding integer value, so "prealpha" < "alpha" < "prebeta" < "beta" < "rc[N]" < "" < "r[N]". Example:

piCout << versionCompare("1.0.0_rc2-999", "1.0.1_rc2-999"); // -1, <
piCout << versionCompare("1.0.0", "0.9.2"); // 1, >
piCout << versionCompare("1.0.0_r1", "1.0.0"); // 1, >
piCout << versionCompare("1.0.0_r1", "1.0.0", 3); // 0, =
piCout << versionCompare("1.0.0_r2", "1.0.0", 3); // 0, =
piCout << versionCompare(".2-alpha", "0.2_alpha"); // 0, =
piCout << versionCompare("1_prebeta", "1.0_alpha"); // 1, >
int versionCompare(const PIString &v0, const PIString &v1, int components)
Compare two version strings in free notation and returns 0, -1 or 1.
Definition: pistring.cpp:1982
#define piCout
Macro used for conditional (piDebug) output to PICout(StdOut)
Definition: picout.h:35
Returns
  • 0 - equal
  • 1 - v0 > v1
  • -1 - v0 < v1

◆ versionNormalize()

PIString versionNormalize ( const PIString v)

Converts version string in free notation to classic view.

Parse version as described in versionCompare() and returns classic view of codes and labels: major.minor.revision[-build][_label]. Example:

piCout << versionNormalize(""); // 0.0.0
piCout << versionNormalize("1"); // 1.0.0
piCout << versionNormalize("1.2"); // 1.2.0
piCout << versionNormalize("1.2.3"); // 1.2.3
piCout << versionNormalize("1.2+rc1.99"); // 1.2.99_rc1
piCout << versionNormalize("1.2-alpha"); // 1.2.0_alpha
piCout << versionNormalize("1..4_rc2-999"); // 1.0.4-999_rc2
PIString versionNormalize(const PIString &v)
Converts version string in free notation to classic view.
Definition: pistring.cpp:2030