PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
OptionType.cpp File Reference
#include "OptionType.h"
+ Include dependency graph for OptionType.cpp:

Go to the source code of this file.

Functions

PString convertOptionTypeToString (OptionType::OptionType type)
 Convert the OptionType into PString. More...
 
template<>
OptionType::OptionType getOptionTypeFromType< bool > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< char > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< double > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< float > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< int > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< long > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< PString > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< short > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< unsigned char > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< unsigned int > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< unsigned long > ()
 
template<>
OptionType::OptionType getOptionTypeFromType< unsigned short > ()
 
bool isOptionFloatingPoint (OptionType::OptionType type)
 Say if the option type is a floating point. More...
 
bool isOptionInteger (OptionType::OptionType type)
 Say if the option type is an integer. More...
 
bool isOptionSignedInteger (OptionType::OptionType type)
 Say if the option type is a signed integer. More...
 
bool isOptionStringFileDir (OptionType::OptionType type)
 Say if the option is a filename, a drectory, both or a string. More...
 
bool isOptionTypeCompatible (OptionType::OptionType typeFromParam, OptionType::OptionType typeFromType)
 Say if two types are compatible. More...
 
bool isOptionUnsignedInteger (OptionType::OptionType type)
 Say if the option type is an unsigned integer. More...
 

Function Documentation

◆ convertOptionTypeToString()

PString convertOptionTypeToString ( OptionType::OptionType  type)

Convert the OptionType into PString.

Parameters
type: OptionType to be converted
Returns
corresponding PString

Definition at line 69 of file OptionType.cpp.

69  {
70  switch(type){
71  case OptionType::NONE:
72  return "NONE";
73  case OptionType::STRING:
74  return "STRING";
76  return "FILENAME";
78  return "DIRECTORY";
80  return "FILE_OR_DIR";
81  case OptionType::BOOL:
82  return "BOOL";
83  case OptionType::CHAR:
84  return "CHAR";
85  case OptionType::SHORT:
86  return "SHORT";
87  case OptionType::INT:
88  return "INT";
89  case OptionType::LONG:
90  return "LONG";
91  case OptionType::UCHAR:
92  return "UCHAR";
93  case OptionType::USHORT:
94  return "USHORT";
95  case OptionType::UINT:
96  return "UINT";
97  case OptionType::ULONG:
98  return "ULONG";
99  case OptionType::FLOAT:
100  return "FLOAT";
101  case OptionType::DOUBLE:
102  return "DOUBLE";
103  default:
104  return "";
105  }
106 }

References OptionType::BOOL, OptionType::CHAR, OptionType::DIRECTORY, OptionType::DOUBLE, OptionType::FILE_OR_DIR, OptionType::FILENAME, OptionType::FLOAT, OptionType::INT, OptionType::LONG, OptionType::NONE, OptionType::SHORT, OptionType::STRING, OptionType::UCHAR, OptionType::UINT, OptionType::ULONG, and OptionType::USHORT.

Referenced by OptionValue::bashCompletionValue(), Option::checkArgument(), OptionParser::checkOptionType(), OptionValue::checkTypeFromTemplate(), Option::print(), and testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< bool >()

Definition at line 111 of file OptionType.cpp.

111 {return OptionType::BOOL;}

References OptionType::BOOL.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< char >()

Definition at line 113 of file OptionType.cpp.

113 {return OptionType::CHAR;}

References OptionType::CHAR.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< double >()

Definition at line 131 of file OptionType.cpp.

131 {return OptionType::DOUBLE;}

References OptionType::DOUBLE.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< float >()

Definition at line 129 of file OptionType.cpp.

129 {return OptionType::FLOAT;}

References OptionType::FLOAT.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< int >()

Definition at line 117 of file OptionType.cpp.

117 {return OptionType::INT;}

References OptionType::INT.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< long >()

Definition at line 119 of file OptionType.cpp.

119 {return OptionType::LONG;}

References OptionType::LONG.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< PString >()

Definition at line 109 of file OptionType.cpp.

109 {return OptionType::STRING;}

References OptionType::STRING.

◆ getOptionTypeFromType< short >()

Definition at line 115 of file OptionType.cpp.

115 {return OptionType::SHORT;}

References OptionType::SHORT.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< unsigned char >()

template<>
OptionType::OptionType getOptionTypeFromType< unsigned char > ( )

Definition at line 121 of file OptionType.cpp.

121 {return OptionType::UCHAR;}

References OptionType::UCHAR.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< unsigned int >()

template<>
OptionType::OptionType getOptionTypeFromType< unsigned int > ( )

Definition at line 125 of file OptionType.cpp.

125 {return OptionType::UINT;}

References OptionType::UINT.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< unsigned long >()

template<>
OptionType::OptionType getOptionTypeFromType< unsigned long > ( )

Definition at line 127 of file OptionType.cpp.

127 {return OptionType::ULONG;}

References OptionType::ULONG.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ getOptionTypeFromType< unsigned short >()

template<>
OptionType::OptionType getOptionTypeFromType< unsigned short > ( )

Definition at line 123 of file OptionType.cpp.

123 {return OptionType::USHORT;}

References OptionType::USHORT.

Referenced by testOptionType().

+ Here is the caller graph for this function:

◆ isOptionFloatingPoint()

bool isOptionFloatingPoint ( OptionType::OptionType  type)

Say if the option type is a floating point.

Parameters
type: type to be checked
Returns
true if type is a floating point, false otherwise

Definition at line 37 of file OptionType.cpp.

37  {
38  return type >= OptionType::FLOAT && type <= OptionType::DOUBLE;
39 }

References OptionType::DOUBLE, and OptionType::FLOAT.

Referenced by isOptionTypeCompatible(), and testOptionType().

+ Here is the caller graph for this function:

◆ isOptionInteger()

bool isOptionInteger ( OptionType::OptionType  type)

Say if the option type is an integer.

Parameters
type: type to be checked
Returns
true if type is an integer, false otherwise

Definition at line 29 of file OptionType.cpp.

29  {
30  return isOptionSignedInteger(type) || isOptionUnsignedInteger(type);
31 }
bool isOptionSignedInteger(OptionType::OptionType type)
Say if the option type is a signed integer.
Definition: OptionType.cpp:13
bool isOptionUnsignedInteger(OptionType::OptionType type)
Say if the option type is an unsigned integer.
Definition: OptionType.cpp:21

References isOptionSignedInteger(), and isOptionUnsignedInteger().

Referenced by isOptionTypeCompatible(), and testOptionType().

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

◆ isOptionSignedInteger()

bool isOptionSignedInteger ( OptionType::OptionType  type)

Say if the option type is a signed integer.

Parameters
type: type to be checked
Returns
true if type is a signed integer, false otherwise

Definition at line 13 of file OptionType.cpp.

13  {
14  return type >= OptionType::CHAR && type <= OptionType::LONG;
15 }

References OptionType::CHAR, and OptionType::LONG.

Referenced by isOptionInteger(), and testOptionType().

+ Here is the caller graph for this function:

◆ isOptionStringFileDir()

bool isOptionStringFileDir ( OptionType::OptionType  type)

Say if the option is a filename, a drectory, both or a string.

Parameters
type: type to be checked
Returns
true if type is a filename, a drectory, both or a string, false otherwise

Definition at line 45 of file OptionType.cpp.

45  {
46  return type == OptionType::STRING || type == OptionType::FILE_OR_DIR || type == OptionType::FILENAME || type == OptionType::DIRECTORY;
47 }

References OptionType::DIRECTORY, OptionType::FILE_OR_DIR, OptionType::FILENAME, and OptionType::STRING.

Referenced by isOptionTypeCompatible(), and testOptionType().

+ Here is the caller graph for this function:

◆ isOptionTypeCompatible()

bool isOptionTypeCompatible ( OptionType::OptionType  typeFromParam,
OptionType::OptionType  typeFromType 
)

Say if two types are compatible.

Parameters
typeFromParam: type from parameters user
typeFromType: type automatically determined with default value type
Returns
true if the two types are compatible, false otherwise

Definition at line 54 of file OptionType.cpp.

54  {
55  if(typeFromParam == typeFromType){return true;}
56  //If we are waiting for a boolean, but we do not get one, => fail
57  if(typeFromParam == OptionType::BOOL){return false;}
58  if(isOptionStringFileDir(typeFromParam) && isOptionStringFileDir(typeFromType)){return true;}
59 
60  if(isOptionInteger(typeFromParam) && isOptionFloatingPoint(typeFromType)){return false;}
61 
62  return true;
63 }
bool isOptionStringFileDir(OptionType::OptionType type)
Say if the option is a filename, a drectory, both or a string.
Definition: OptionType.cpp:45
bool isOptionInteger(OptionType::OptionType type)
Say if the option type is an integer.
Definition: OptionType.cpp:29
bool isOptionFloatingPoint(OptionType::OptionType type)
Say if the option type is a floating point.
Definition: OptionType.cpp:37

References OptionType::BOOL, isOptionFloatingPoint(), isOptionInteger(), and isOptionStringFileDir().

Referenced by OptionParser::checkOptionType(), and OptionValue::checkTypeFromTemplate().

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

◆ isOptionUnsignedInteger()

bool isOptionUnsignedInteger ( OptionType::OptionType  type)

Say if the option type is an unsigned integer.

Parameters
type: type to be checked
Returns
true if type is an unsigned integer, false otherwise

Definition at line 21 of file OptionType.cpp.

21  {
22  return type >= OptionType::UCHAR && type <= OptionType::ULONG;
23 }

References OptionType::UCHAR, and OptionType::ULONG.

Referenced by isOptionInteger(), and testOptionType().

+ Here is the caller graph for this function: