Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xdmf
Xdmf
Commits
413c4279
Commit
413c4279
authored
Dec 08, 2010
by
Brian Panneton
Browse files
FIX: Cleaned up Version Suite and added the version into XdmfWriter.
parent
7560d548
Changes
7
Hide whitespace changes
Inline
Side-by-side
CMake/VersionSuite/ProjectVersion.hpp
0 → 100644
View file @
413c4279
#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
)
{
setProjectName
(
iProjectName
);
setMajor
(
iMajor
);
setMinor
(
iMinor
);
}
/**
* Get the version string
*
* @return the Version in "ProjectName Major.Minor" string format
*/
std
::
string
getFull
()
{
return
getProjectName
()
+
std
::
string
(
" "
)
+
getMajorStr
()
+
std
::
string
(
"."
)
+
getMinorStr
();
}
/**
* 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
()
{
return
IntToStr
(
Major
);
}
/**
* Get the Version Minor
*
* @return the Version Minor in string format
*/
std
::
string
getMinorStr
()
{
return
IntToStr
(
Minor
);
}
/**
* 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
;
}
private:
std
::
string
ProjectName
;
int
Major
,
Minor
;
std
::
string
IntToStr
(
int
number
)
{
std
::
stringstream
s
;
s
<<
number
;
return
s
.
str
();
}
void
setProjectName
(
std
::
string
iProjectName
)
{
ProjectName
=
iProjectName
;
}
void
setMajor
(
int
iMajor
)
{
Major
=
iMajor
;
}
void
setMinor
(
int
iMinor
)
{
Minor
=
iMinor
;
}
};
#endif //PROJECT_VERSION_HPP
CMake/VersionSuite/SetUpVersion.cmake
View file @
413c4279
...
...
@@ -15,6 +15,13 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/CMake/VersionSuite)
SET
(
vMajor
"0"
)
SET
(
vMinor
"0"
)
# This Macro allows you to set up the Version in a one liner
MACRO
(
VersionCreate versionName versionMajor
)
VersionMajorSet
(
${
versionMajor
}
)
VersionCalculate
()
VersionWrite
(
${
versionName
}
)
ENDMACRO
(
VersionCreate versionName versionMajor
)
# This Macro allows you to set the rewrite number
MACRO
(
VersionMajorSet versionMajor
)
SET
(
vMajor
${
versionMajor
}
)
...
...
@@ -32,11 +39,13 @@ MACRO(VersionCalculate)
ENDMACRO
(
VersionCalculate
)
# This Macro writes your hpp file
MACRO
(
VersionWrite versionProjectName
)
FILE
(
WRITE
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
versionProjectName
}
Version.hpp
"/*Current Version of
${
versionProjectName
}
*/
\#
define VersionMajor
${
vMajor
}
\#
define VersionMinor
${
vMinor
}
\#
include
\"
Version.hpp
\"\n
"
MACRO
(
VersionWrite vProjectName
)
FILE
(
WRITE
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
vProjectName
}
Version.hpp
"
\#
ifndef
${
vProjectName
}
_VERSION_HPP
\#
define
${
vProjectName
}
_VERSION_HPP
/* Current Version of
${
vProjectName
}
*/
\#
include
\"
ProjectVersion.hpp
\"
ProjectVersion
${
vProjectName
}
Version = ProjectVersion(
\"
${
vProjectName
}
\"
,
${
vMajor
}
,
${
vMinor
}
);
\#
endif
\n
"
)
ENDMACRO
(
VersionWrite
)
CMake/VersionSuite/Version.hpp
deleted
100644 → 0
View file @
7560d548
/* 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
Version
{
public:
/**
* Create a Version class object
*
* @param name of the project
*/
Version
(
std
::
string
cProjectName
)
{
setProjectName
(
cProjectName
);
setMajor
(
VersionMajor
);
setMinor
(
VersionMinor
);
}
/**
* Get the version string
*
* @return the Version in "ProjectName Major.Minor" string format
*/
std
::
string
getVersion
()
{
return
getProjectName
()
+
std
::
string
(
" "
)
+
getMajorStr
()
+
std
::
string
(
"."
)
+
getMinorStr
();
}
/**
* Get the shorter version string
*
* @return the Version in "Major.Minor" string format
*/
std
::
string
getVersionShort
()
{
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
()
{
return
IntToStr
(
Major
);
}
/**
* Get the Version Minor
*
* @return the Version Minor in string format
*/
std
::
string
getMinorStr
()
{
return
IntToStr
(
Minor
);
}
/**
* 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
;
}
private:
std
::
string
ProjectName
;
int
Major
,
Minor
;
std
::
string
IntToStr
(
int
number
)
{
std
::
stringstream
s
;
s
<<
number
;
return
s
.
str
();
}
void
setProjectName
(
std
::
string
iProjectName
)
{
ProjectName
=
iProjectName
;
}
void
setMajor
(
int
iMajor
)
{
Major
=
iMajor
;
}
void
setMinor
(
int
iMinor
)
{
Minor
=
iMinor
;
}
};
core/CMakeLists.txt
View file @
413c4279
...
...
@@ -3,9 +3,7 @@ cmake_minimum_required(VERSION 2.6)
include
(
SetUpVersion
)
if
(
VERSION_CONTROL_AUTOUPDATE
)
VersionMajorSet
(
"2"
)
VersionCalculate
()
VersionWrite
(
"Xdmf"
)
VersionCreate
(
"Xdmf"
"2"
)
endif
(
VERSION_CONTROL_AUTOUPDATE
)
set
(
BUILD_SHARED_LIBS true
)
...
...
core/XdmfVersion.hpp
View file @
413c4279
/*Current Version of Xdmf*/
#define VersionMajor 2
#define VersionMinor 0
#include
"Version.hpp"
#ifndef Xdmf_VERSION_HPP
#define Xdmf_VERSION_HPP
/* Current Version of Xdmf */
#include
"ProjectVersion.hpp"
ProjectVersion
XdmfVersion
=
ProjectVersion
(
"Xdmf"
,
2
,
0
);
#endif
core/XdmfWriter.cpp
View file @
413c4279
...
...
@@ -10,6 +10,7 @@
#include
"XdmfItem.hpp"
#include
"XdmfSystemUtils.hpp"
#include
"XdmfWriter.hpp"
#include
"XdmfVersion.hpp"
/**
* PIMPL
...
...
@@ -31,7 +32,7 @@ public:
mXMLFilePath
(
XdmfSystemUtils
::
getRealPath
(
xmlFilePath
)),
mXPathCount
(
0
),
mXPathString
(
""
),
mVersionString
(
"2.0"
)
mVersionString
(
XdmfVersion
.
getShort
()
)
{
};
...
...
core/tests/Cxx/TestXdmfVersion.cpp
View file @
413c4279
...
...
@@ -2,12 +2,7 @@
#include
"XdmfVersion.hpp"
int
main
()
{
Version
*
v
=
new
Version
(
"Xdmf"
);
if
(
v
->
getVersion
()
==
""
)
exit
(
-
1
);
if
(
v
->
getVersionShort
()
==
""
)
exit
(
-
1
);
std
::
cout
<<
v
->
getVersion
()
<<
std
::
endl
;
std
::
cout
<<
v
->
getVersionShort
();
std
::
cout
<<
XdmfVersion
.
getFull
()
<<
std
::
endl
;
std
::
cout
<<
XdmfVersion
.
getShort
()
<<
std
::
endl
;
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment