/usr/include/ProjectVersion.hpp is in libxdmf-dev 3.0+git20160803-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #ifndef PROJECT_VERSION_HPP
#define PROJECT_VERSION_HPP
/* Version Suite Class
* Author: Brian Panneton
*/
#include <string>
#include <sstream>
/**
* @brief Version Suite to assist in adding versioning to your project
*
* A simple way to have the library contain its own version.
*/
class ProjectVersion {
public:
/**
* Create a Version class object
*
* @param name of the project
*/
ProjectVersion(std::string iProjectName, int iMajor, int iMinor, int iPatch) {
setProjectName(iProjectName);
setMajor(iMajor);
setMinor(iMinor);
setPatch(iPatch);
}
ProjectVersion(std::string iProjectName,
std::string iMajor, std::string iMinor, std::string iPatch) {
setProjectName(iProjectName);
setMajorStr(iMajor);
setMinorStr(iMinor);
setPatchStr(iPatch);
}
/**
* Get the version string
*
* @return the Version in "ProjectName Major.Minor.Patch" string format
*/
std::string getFull() {
return getProjectName()+std::string(" ")+
getMajorStr()+std::string(".")+
getMinorStr()+std::string(".")+
getPatchStr();
}
/**
* Get the shorter version string
*
* @return the Version in "Major.Minor" string format
*/
std::string getShort() {
return getMajorStr()+std::string(".")+
getMinorStr();
}
/**
* Get the version objects project name
*
* @return the project name in string format
*/
std::string getProjectName() { return ProjectName; }
/**
* Get the Version Major
*
* @return the Version Major in string format
*/
std::string getMajorStr()
{
if(Major != -1) return IntToStr(Major);
return("X");
}
/**
* Get the Version Minor
*
* @return the Version Minor in string format
*/
std::string getMinorStr()
{
if(Minor != -1) return IntToStr(Minor);
return("X");
}
/**
* Get the Version Patch
*
* @return the Version Patch in string format
*/
std::string getPatchStr()
{
if(Patch != -1) return IntToStr(Patch);
return("X");
}
/**
* Get the Version Major
*
* @return the Version Major in int format
*/
int getMajor() { return Major; }
/**
* Get the Version Minor
*
* @return the Version Minor in int format
*/
int getMinor() { return Minor; }
/**
* Get the Version Patch
*
* @return the Version Patch in int format
*/
int getPatch() { return Patch; }
private:
std::string ProjectName;
int Major, Minor, Patch;
std::string IntToStr(int number) {
std::stringstream s;
s << number;
return s.str();
}
int StrToInt(std::string string) {
int i = 0;
std::stringstream s(string);
if(!(s >> i)) return -1;
return i;
}
void setProjectName(std::string iProjectName)
{ ProjectName = iProjectName; }
void setMajor(int iMajor) { Major = iMajor; }
void setMajorStr(std::string iMajor) {
Major = StrToInt(iMajor);
}
void setMinor(int iMinor) { Minor = iMinor; }
void setMinorStr(std::string iMinor) {
Minor = StrToInt(iMinor);
}
void setPatch(int iPatch) { Patch = iPatch; }
void setPatchStr(std::string iPatch) {
Patch = StrToInt(iPatch);
}
};
#endif //PROJECT_VERSION_HPP
|