Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
LUPI::FormatVersion Class Reference

#include <LUPI.hpp>

Public Member Functions

 FormatVersion ()
 FormatVersion (std::string const &a_formatVersion)
 FormatVersion (FormatVersion const &a_formatVersion)
FormatVersionoperator= (FormatVersion const &a_rhs)
std::string const & format () const
int major () const
int minor () const
std::string const & patch () const
bool setFormat (std::string const &a_formatVersion)
bool supported () const

Detailed Description

Class to store GNDS format.

Definition at line 60 of file LUPI.hpp.

Constructor & Destructor Documentation

◆ FormatVersion() [1/3]

LUPI::FormatVersion::FormatVersion ( )

Definition at line 23 of file LUPI_formatVersion.cc.

23 :
24 m_format( "" ),
25 m_major( -1 ),
26 m_minor( -1 ),
27 m_patch( "" ) {
28
29}

Referenced by FormatVersion(), and operator=().

◆ FormatVersion() [2/3]

LUPI::FormatVersion::FormatVersion ( std::string const & a_formatVersion)
Parameters
a_formatVersion[in] The GNDS format.

Definition at line 35 of file LUPI_formatVersion.cc.

35 :
36 m_format( a_formatVersion ),
37 m_major( -1 ),
38 m_minor( -1 ),
39 m_patch( "" ) {
40
41 setFormat( a_formatVersion );
42}
bool setFormat(std::string const &a_formatVersion)

◆ FormatVersion() [3/3]

LUPI::FormatVersion::FormatVersion ( FormatVersion const & a_formatVersion)
Parameters
a_formatVersion[in] The GNDS format.

Definition at line 48 of file LUPI_formatVersion.cc.

48 :
49 m_format( a_formatVersion.format( ) ),
50 m_major( a_formatVersion.major( ) ),
51 m_minor( a_formatVersion.minor( ) ),
52 m_patch( a_formatVersion.patch( ) ) {
53
54}

Member Function Documentation

◆ format()

std::string const & LUPI::FormatVersion::format ( ) const
inline

◆ major()

int LUPI::FormatVersion::major ( ) const
inline

Definition at line 75 of file LUPI.hpp.

75{ return( m_major ); }

Referenced by FormatVersion(), and operator=().

◆ minor()

int LUPI::FormatVersion::minor ( ) const
inline

Definition at line 76 of file LUPI.hpp.

76{ return( m_minor ); }

Referenced by FormatVersion(), and operator=().

◆ operator=()

FormatVersion & LUPI::FormatVersion::operator= ( FormatVersion const & a_rhs)

The assignment operator. This method sets the members of this to those of a_rhs except for those not set by base classes.

Parameters
a_rhs[in] Instance whose member are used to set the members of this.

Definition at line 63 of file LUPI_formatVersion.cc.

63 {
64
65 if( this != &a_rhs ) {
66 m_format = a_rhs.format( );
67 m_major = a_rhs.major( );
68 m_minor = a_rhs.minor( );
69 m_patch = a_rhs.patch( );
70 }
71
72 return( *this );
73}

◆ patch()

std::string const & LUPI::FormatVersion::patch ( ) const
inline

Definition at line 77 of file LUPI.hpp.

77{ return( m_patch ); }

Referenced by FormatVersion(), and operator=().

◆ setFormat()

bool LUPI::FormatVersion::setFormat ( std::string const & a_formatVersion)

Set the format to a_formatVersion and parse its components.

Parameters
a_formatVersion[in] The GNDS format.
Returns
true if format of the form "MAJOR.MINOR[.PATCH]" where MAJOR and MINOR are integers. Otherwise returns false.

Definition at line 83 of file LUPI_formatVersion.cc.

83 {
84
85 m_format = a_formatVersion;
86
87 std::vector<std::string> formatItems = Misc::splitString( a_formatVersion, '.' );
88
89 if( ( formatItems.size( ) < 2 ) || ( formatItems.size( ) > 3 ) ) goto err;
90
91 if( !Misc::stringToInt( formatItems[0], m_major ) ) goto err;
92 if( !Misc::stringToInt( formatItems[1], m_minor ) ) goto err;
93
94 if( formatItems.size( ) == 3 ) m_patch = formatItems[2];
95
96 return( true );
97
98err:
99 m_major = -1;
100 m_minor = -1;
101 m_patch = "";
102 return( false );
103}
std::vector< std::string > splitString(std::string const &a_string, char a_delimiter, bool a_strip=false)
Definition LUPI_misc.cc:103
bool stringToInt(std::string const &a_string, int &a_value)
Definition LUPI_misc.cc:260

Referenced by GIDI::Fluxes::addFile(), GIDI::Groups::addFile(), and FormatVersion().

◆ supported()

bool LUPI::FormatVersion::supported ( ) const

Returns true if m_format is a supported format and false otherwise;

Returns
true if format is supported and false otherwise.

Definition at line 111 of file LUPI_formatVersion.cc.

111 {
112
113 if( m_format == GNDS_formatVersion_1_10Chars ) return( true );
114 if( m_format == GNDS_formatVersion_2_0Chars ) return( true );
115 if( m_format == GNDS_formatVersion_2_0_LLNL_4Chars ) return( true );
116 if( m_format == GNDS_formatVersion_2_1Chars ) return( true );
117
118 return( false );
119}
#define GNDS_formatVersion_2_0Chars
Definition LUPI.hpp:49
#define GNDS_formatVersion_1_10Chars
Definition LUPI.hpp:48
#define GNDS_formatVersion_2_0_LLNL_4Chars
Definition LUPI.hpp:50
#define GNDS_formatVersion_2_1Chars
Definition LUPI.hpp:51

Referenced by GIDI::Fluxes::addFile(), GIDI::Groups::addFile(), and PoPI::supportedFormat().


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