STK++ 0.9.13
Fundamental data types

In this subproject we define the fundamental types. More...

Collaboration diagram for Fundamental data types:

Namespaces

namespace  STK::Chrono
 The namespace Chrono is an utility namespace for computing elapsed time during the execution of a program.
 

Classes

class  STK::Proxy< Type >
 The Proxy class allow to surdefine operators and methods for every kind of class without using dynamic_cast. More...
 
class  STK::Proxy< String >
 Specialization of the Proxy class for String. More...
 

Enumerations

enum  STK::Binary { STK::zero_ =0 , STK::one_ =1 , STK::binaryNA_ =INT_MIN }
 STK fundamental type of a binary. More...
 
enum  STK::Sign { STK::negative_ =-1 , STK::positive_ = 1 , STK::signNA_ = INT_MIN }
 STK fundamental type of a sign. More...
 

Functions

Binary STK::stringToBinary (String const &str)
 Convert a String to a Binary.
 
Binary STK::stringToBinary (String const &str, std::map< String, Binary > const &mapping)
 Convert a String to a Binary using a map.
 
String STK::binaryToString (Binary const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
 Convert a Binary to a String.
 
String STK::binaryToString (Binary const &value, std::map< Binary, String > const &mapping)
 Convert a Binary to a String.
 
template<>
Binary STK::stringToType< Binary > (String const &str)
 specialization for Binary
 
template<>
String STK::typeToString< Binary > (Binary const &t, std::ios_base &(*f)(std::ios_base &))
 specialization for Binary
 
void STK::Chrono::start ()
 Start the Chrono.
 
Real STK::Chrono::elapsed ()
 Compute the elapsed time (in second) since last start() call.
 
Integer STK::stringToInt (String const &str)
 Convert a String to an Integer.
 
Integer STK::stringToInt (String const &str, std::map< String, Integer > const &mapping)
 Convert a String to an Integer using a map.
 
String STK::intToString (Integer const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
 Convert an Integer to a String.
 
String STK::intToString (Integer const &value, std::map< Integer, String > const &mapping)
 Convert an Integer to a String.
 
template<>
Integer STK::stringToType< Integer > (String const &s)
 specialization for Integer
 
template<>
String STK::typeToString< Integer > (Integer const &t, std::ios_base &(*f)(std::ios_base &))
 specialization for Integer
 
template<typename Type >
Type STK::sign (Type const &x, Type const &y=Type(1))
 template sign value sign(x) * y: Type should be an integral type
 
Real STK::frand ()
 frand() generate a Real uniform number.
 
bool STK::isOdd (int const &x)
 is x a odd number ?
 
bool STK::isEven (int const &x)
 is x an even number ?
 
Real STK::norm (Real const &x, Real const &y)
 Computation of sqrt(x^2 + y^2) without underflow or overflow.
 
template<int Size_>
ostreamSTK::operator<< (ostream &os, TRange< Size_ > const &I)
 Write a TRange in the form first:last (MATLAB-like form) in an output stream.
 
Range STK::stringToRange (String const &str)
 Convert a String to a Range.
 
template<int Size_>
TRange< Size_STK::stringToRange (String const &str, std::map< String, TRange< Size_ > > const &mapping)
 Convert a String to a Range using a map.
 
template<int Size_>
String STK::rangeToString (TRange< Size_ > const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
 Convert an Range to a String.
 
template<int Size_>
String STK::rangeToString (TRange< Size_ > const &value, std::map< TRange< Size_ >, String > const &mapping)
 Convert a Range to a String.
 
template<>
String STK::typeToString< Range > (Range const &t, std::ios_base &(*f)(std::ios_base &))
 Specialization for Range.
 
Real STK::stringToReal (String const &str)
 Convert a String to a Real.
 
Real STK::stringToReal (String const &str, std::map< String, Real > const &mapping)
 Convert a String to a Real using a map.
 
String STK::realToString (Real const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
 Convert a Real to a String.
 
String STK::realToString (Real const &type, std::map< Real, String > const &mapping)
 Convert a real to a String.
 
template<>
Real STK::stringToType< Real > (String const &str)
 specialization for Real
 
template<>
String STK::typeToString< Real > (Real const &value, std::ios_base &(*f)(std::ios_base &))
 specialization for Real
 
Sign STK::stringToSign (String const &str)
 Convert a String to a Sign.
 
Sign STK::stringToSign (String const &str, std::map< String, Sign > const &mapping)
 Convert a String to a Sign using a map.
 
String STK::signToString (Sign const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
 Convert a Sign to a String.
 
String STK::signToString (Sign const &value, std::map< Sign, String > mapping)
 Convert a Sign to a String.
 
template<>
Sign STK::stringToType< Sign > (String const &str)
 specialization for Sign
 
template<>
String STK::typeToString< Sign > (Sign const &t, std::ios_base &(*f)(std::ios_base &))
 specialization for Sign
 
void STK::setStringNa (String const &na)
 Set a new value to the na String representation and modify stringNaSize accordingly.
 
String constSTK::toUpperString (String &s)
 convert the characters of the String to upper case
 
String STK::toUpperString (String const &s)
 convert the characters of the String to upper case
 
String STK::removeWhiteSpaces (String const &s)
 convert the characters of the String to upper case
 
template<class Type >
bool STK::stringToType (Type &t, String const &s, std::ios_base &(*f)(std::ios_base &)=std::dec)
 convert a String to Type
 
template<class Type >
Type STK::stringToType (String const &s)
 convert a String to Type without error check
 
template<class Type >
String STK::typeToString (Type const &t, std::ios_base &(*f)(std::ios_base &)=std::dec)
 convert a Type to String
 

Variables

String STK::stringNa = String(_T("."))
 Representation of a Not Available value.
 
int STK::stringNaSize = 1
 Size (in number of Char) of a Not Available value.
 

Detailed Description

In this subproject we define the fundamental types.

The Base subproject is composed of

Enumeration Type Documentation

◆ Binary

STK fundamental type of a binary.

The type Binary is a representation of dichotomic variables.

Enumerator
zero_ 

0 value

one_ 

1 value

binaryNA_ 

Not Available value.

Definition at line 48 of file STK_Binary.h.

49{ zero_ =0,
50 one_ =1,
51 binaryNA_=INT_MIN
52};
@ zero_
0 value
Definition STK_Binary.h:49
@ one_
1 value
Definition STK_Binary.h:50
@ binaryNA_
Not Available value.
Definition STK_Binary.h:51

◆ Sign

STK fundamental type of a sign.

The type Signed is an other representation of dichotomic variables

Enumerator
negative_ 

negative sign

positive_ 

positive sign

signNA_ 

Not Available value.

Definition at line 48 of file STK_Sign.h.

49{ negative_ =-1,
50 positive_ = 1,
51 signNA_ = INT_MIN
52};
@ signNA_
Not Available value.
Definition STK_Sign.h:51
@ positive_
positive sign
Definition STK_Sign.h:50
@ negative_
negative sign
Definition STK_Sign.h:49

Function Documentation

◆ binaryToString() [1/2]

String STK::binaryToString ( Binary const value,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)
inline

Convert a Binary to a String.

Parameters
valuethe Binary we want to convert
fformat, by default write every number in decimal
Returns
the string associated to this type.

Definition at line 160 of file STK_Binary.h.

161{
162 if (Arithmetic<Binary>::isNA(value)) return stringNa;
163 ostringstream os;
164 os << f << static_cast<int>(value);
165 return os.str();
166}
String stringNa
Representation of a Not Available value.
std::basic_ostringstream< Char > ostringstream
ostringstream (ostringstream) for Char
Definition STK_Stream.h:65

References STK::stringNa.

Referenced by STK::typeToString< Binary >().

◆ binaryToString() [2/2]

String STK::binaryToString ( Binary const value,
std::map< Binary, String > const mapping 
)
inline

Convert a Binary to a String.

Parameters
valuethe Binary we want to convert
mappingthe mapping between the Binary and the String
Returns
the string associated to this value.

Definition at line 174 of file STK_Binary.h.

175{
176 std::map<Binary, String>::const_iterator it=mapping.find(value);
177 return (it == mapping.end()) ? Arithmetic<String>::NA() : it->second;
178}

References STK::Arithmetic< Type >::NA().

◆ elapsed()

Real STK::Chrono::elapsed ( )
inline

Compute the elapsed time (in second) since last start() call.

Returns
the elapsed time

Definition at line 62 of file STK_Chrono.h.

63 {
64 t_end = clock();
65 return Real(Real(t_end - t_start)/CLOCKS_PER_SEC);
66 }
double Real
STK fundamental type of Real values.

◆ frand()

Real STK::frand ( )
inline

frand() generate a Real uniform number.

This is a very basic method and should only be used when speed is necessary only.

Definition at line 61 of file STK_Misc.h.

62{ return (Real)rand() / (RAND_MAX+1.0);}

◆ intToString() [1/2]

String STK::intToString ( Integer const value,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)
inline

Convert an Integer to a String.

Parameters
valuethe Integer we want to convert
fformat, by default write every number in decimal
Returns
the string associated to this value.

Definition at line 175 of file STK_Integer.h.

176{
177 if (Arithmetic<Integer>::isNA(value)) return stringNa;
178 ostringstream os;
179 os << f << value;
180 return os.str();
181}

References STK::stringNa.

Referenced by STK::typeToString< Integer >().

◆ intToString() [2/2]

String STK::intToString ( Integer const value,
std::map< Integer, String > const mapping 
)
inline

Convert an Integer to a String.

Parameters
valuethe Integer we want to convert
mappingthe mapping between Integer and String
Returns
the String associated to this value.

Definition at line 189 of file STK_Integer.h.

190{
191 std::map<Integer, String>::const_iterator it=mapping.find(value);
192 return (it == mapping.end()) ? stringNa : it->second;
193}

References STK::stringNa.

◆ isEven()

bool STK::isEven ( int const x)
inline

is x an even number ?

This method return true if the rest of the euclidian division of x by 2 is 1.

Parameters
xthe value to test
Returns
true if x is even, false otherwise

Definition at line 83 of file STK_Misc.h.

84{ return( (x%2) == 0 ); }

Referenced by STK::Funct::gamma_raw().

◆ isOdd()

bool STK::isOdd ( int const x)
inline

is x a odd number ?

This method return true if the rest of the euclidian division of x by 2 is 0.

Parameters
xthe value to test
Returns
true if x is odd, false otherwise

Definition at line 72 of file STK_Misc.h.

73{ return( (x%2) == 1 ); }

◆ norm()

Real STK::norm ( Real const x,
Real const y 
)
inline

Computation of sqrt(x^2 + y^2) without underflow or overflow.

Parameters
xfirst value
ysecond value
Returns
the value $ \sqrt(x^2 + y^2) $

Definition at line 93 of file STK_Misc.h.

94{
95 Real absx = std::abs(x), absy = std::abs(y);
96 return (absx > absy) ?
97 (absx * std::sqrt(Real(1.0+(absy/absx)*(absy/absx))))
98 : (absy == 0.0 ? 0.0 : absy * std::sqrt(Real(1.0+(absx/absy)*(absx/absy))));
99}

Referenced by STK::bidiag(), STK::Svd< Array >::diag(), STK::SymEigen< SquareArray >::diagonalize(), STK::gramSchmidt(), STK::leftEliminate(), and STK::Svd< Array >::rightEliminate().

◆ operator<<()

template<int Size_>
ostream & STK::operator<< ( ostream os,
TRange< Size_ > const I 
)

Write a TRange in the form first:last (MATLAB-like form) in an output stream.

Parameters
osoutput stream
IRange to write
Returns
output stream

Definition at line 515 of file STK_Range.h.

516{
517 (Arithmetic< TRange<Size_> >::isNA(I)) ? os << stringNa
518 : os << I.begin() << _T(":") << I.lastIdx();
519 return os;
520}
#define _T(x)
Let x unmodified.

References _T, STK::isNA(), and STK::stringNa.

◆ rangeToString() [1/2]

template<int Size_>
String STK::rangeToString ( TRange< Size_ > const value,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)

Convert an Range to a String.

Parameters
valuethe Range we want to convert
fformat, by default write every number in decimal
Returns
the string associated to this value.

Definition at line 552 of file STK_Range.h.

553{
554 if (Arithmetic<TRange<Size_> >::isNA(value)) return stringNa;
555 ostringstream os;
556 os << f << value;
557 return os.str();
558}

References STK::isNA(), and STK::stringNa.

Referenced by STK::typeToString< Range >().

◆ rangeToString() [2/2]

template<int Size_>
String STK::rangeToString ( TRange< Size_ > const value,
std::map< TRange< Size_ >, String > const mapping 
)

Convert a Range to a String.

Parameters
valuethe Range we want to convert
mappingthe mapping between Range and String
Returns
the String associated to this value.

Definition at line 567 of file STK_Range.h.

568{
569 typename std::map<TRange<Size_> , String>::const_iterator it=mapping.find(value);
570 if (it == mapping.end()) return stringNa;
571 return it->second;
572}
std::basic_string< Char > String
STK fundamental type of a String.

References STK::stringNa.

◆ realToString() [1/2]

String STK::realToString ( Real const type,
std::map< Real, String > const mapping 
)
inline

Convert a real to a String.

Parameters
typethe Real we want to convert
mappingthe mapping between the Real and the String
Returns
the string associated to this type.

Definition at line 195 of file STK_Real.h.

196{
197 std::map<Real, String>::const_iterator it=mapping.find(type);
198 if (it == mapping.end()) return stringNa;
199 return it->second;
200}

References STK::stringNa.

◆ realToString() [2/2]

String STK::realToString ( Real const value,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)
inline

Convert a Real to a String.

Parameters
valuethe Real we want to convert
fformat, by default write every number in decimal
Returns
the string associated to this value.

Definition at line 181 of file STK_Real.h.

182{
183 if (isNA(value)) return stringNa;
184 ostringstream os;
185 os << f << value;
186 return os.str();
187}
bool isNA(Type const &x)
utility method allowing to know if a value is a NA (Not Available) value

References STK::isNA(), and STK::stringNa.

Referenced by STK::typeToString< Real >().

◆ removeWhiteSpaces()

String STK::removeWhiteSpaces ( String const s)
inline

convert the characters of the String to upper case

Parameters
sThe String to convert
Returns
the string converted to upper case

Definition at line 165 of file STK_String.h.

166{
167 // iterate along the String
168 String str = s;
169 str.erase(remove_if(str.begin(), str.end(), isspace), str.end());
170 return str;
171}

Referenced by STK::Law::stringToUnivariateDistribution().

◆ setStringNa()

void STK::setStringNa ( String const na)
inline

Set a new value to the na String representation and modify stringNaSize accordingly.

Definition at line 109 of file STK_String.h.

110{ stringNa = na; stringNaSize = na.size();}
int stringNaSize
Size (in number of Char) of a Not Available value.

References STK::stringNa, and STK::stringNaSize.

◆ sign()

template<typename Type >
Type STK::sign ( Type const x,
Type const y = Type(1) 
)
inline

template sign value sign(x) * y: Type should be an integral type

Parameters
xthe sign value
ythe signed value to return

Definition at line 53 of file STK_Misc.h.

54{ return( (x<0) ? -y : y); }

Referenced by STK::compGivens(), STK::Svd< Array >::diag(), STK::SymEigen< SquareArray >::diagonalize(), STK::ISvd< Derived >::finalize(), STK::ISymEigen< Derived >::finalizeStep(), STK::house(), and STK::RandBase::randGauss().

◆ signToString() [1/2]

String STK::signToString ( Sign const value,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)
inline

Convert a Sign to a String.

Parameters
valuethe Sign we want to convert
fformat, by default write every number in decimal
Returns
the string associated to this value.

Definition at line 169 of file STK_Sign.h.

170{
171 if (Arithmetic<Sign>::isNA(value)) return stringNa;
172 ostringstream os;
173 os << f << static_cast<int>(value);
174 return os.str();
175}

References STK::stringNa.

Referenced by STK::typeToString< Sign >().

◆ signToString() [2/2]

String STK::signToString ( Sign const value,
std::map< Sign, String mapping 
)
inline

Convert a Sign to a String.

Parameters
valuethe Sign we want to convert
mappingthe mapping between the Sign and the String
Returns
the string associated to this type.

Definition at line 183 of file STK_Sign.h.

184{ return mapping.find(value)->second;}

◆ start()

void STK::Chrono::start ( )
inline

Start the Chrono.

Definition at line 57 of file STK_Chrono.h.

57{ t_start = clock(); }

◆ stringToBinary() [1/2]

Binary STK::stringToBinary ( String const str)
inline

Convert a String to a Binary.

Parameters
strthe String we want to convert
Returns
the Binary represented by the String str. If the string does not match any known name, the binaryNA_ value is returned.

Definition at line 134 of file STK_Binary.h.

135{
136 if (toUpperString(str) == toUpperString(_T("0"))) return zero_;
137 if (toUpperString(str) == toUpperString(_T("1"))) return one_;
138 return binaryNA_;
139}
String const & toUpperString(String &s)
convert the characters of the String to upper case
Definition STK_String.h:134

References _T, STK::binaryNA_, STK::one_, STK::toUpperString(), and STK::zero_.

Referenced by STK::stringToType< Binary >().

◆ stringToBinary() [2/2]

Binary STK::stringToBinary ( String const str,
std::map< String, Binary > const mapping 
)
inline

Convert a String to a Binary using a map.

Parameters
strthe String we want to convert
mappingthe mapping between the String and the Binary
Returns
the Binary represented by the String str. If the string does not match any known name, the binaryNA_ type is returned.

Definition at line 148 of file STK_Binary.h.

149{
150 std::map<String, Binary>::const_iterator it=mapping.find(str);
151 return (it == mapping.end()) ? binaryNA_ : it->second;
152}

References STK::binaryNA_.

◆ stringToInt() [1/2]

Integer STK::stringToInt ( String const str)
inline

Convert a String to an Integer.

Parameters
strthe String we want to convert
Returns
the Integer represented by the String str. If the string does not match any known name, the NA value is returned.

Definition at line 149 of file STK_Integer.h.

150{
151 Integer x;
152 istringstream is(str);
153 is >> Proxy<Integer>(x);
154 return x;
155}
int Integer
STK fundamental type of integer values.
std::basic_istringstream< Char > istringstream
istringstream for Char
Definition STK_Stream.h:63

Referenced by STK::stringToType< Integer >().

◆ stringToInt() [2/2]

Integer STK::stringToInt ( String const str,
std::map< String, Integer > const mapping 
)
inline

Convert a String to an Integer using a map.

Parameters
strthe String we want to convert
mappingthe mapping between the string and the Int
Returns
the Int represented by the String type. if the string does not match any known name, the unknown_ type is returned.

Definition at line 163 of file STK_Integer.h.

164{
165 std::map<String, Integer>::const_iterator it=mapping.find(str);
166 return (it == mapping.end()) ? Arithmetic<Integer>::NA() : it->second;
167}

References STK::Arithmetic< Type >::NA().

◆ stringToRange() [1/2]

Range STK::stringToRange ( String const str)
inline

Convert a String to a Range.

Parameters
strthe String we want to convert
Returns
the Range represented by the String str. if the string does not match any known name, the NA value is returned.

Definition at line 528 of file STK_Range.h.

529{ return stringToType<Range>(str);}

◆ stringToRange() [2/2]

template<int Size_>
TRange< Size_ > STK::stringToRange ( String const str,
std::map< String, TRange< Size_ > > const mapping 
)

Convert a String to a Range using a map.

Parameters
strthe String we want to convert
mappingthe mapping between the string and the TRange
Returns
the TRange represented by the String str. if the string does not match any known name, the NA value is returned.

Definition at line 539 of file STK_Range.h.

540{
541 typename std::map<String, TRange<Size_> >::const_iterator it=mapping.find(str);
542 return (it == mapping.end()) ? Arithmetic< TRange<Size_> >::NA() : it->second;
543}

◆ stringToReal() [1/2]

Real STK::stringToReal ( String const str)
inline

Convert a String to a Real.

Parameters
strthe String we want to convert
Returns
the Real

Definition at line 154 of file STK_Real.h.

155{
156 istringstream is(str);
157 Real x;
158 is >> Proxy<Real>(x);
159 return x;
160}

Referenced by STK::stringToType< Real >().

◆ stringToReal() [2/2]

Real STK::stringToReal ( String const str,
std::map< String, Real > const mapping 
)
inline

Convert a String to a Real using a map.

Parameters
strthe String we want to convert
mappingthe mapping between the string and the real
Returns
the real represented by the String str. If the string does not match any known name, the NA value is returned.

Definition at line 169 of file STK_Real.h.

170{
171 std::map<String, Real>::const_iterator it=mapping.find(str);
172 return (it == mapping.end()) ? Arithmetic<Real>::NA() : it->second;
173}

References STK::Arithmetic< Type >::NA().

◆ stringToSign() [1/2]

Sign STK::stringToSign ( String const str)
inline

Convert a String to a Sign.

Parameters
strthe String we want to convert
Returns
the Sign represented by the String type. if the string does not match any known name, the signNA_ value is returned.

Definition at line 142 of file STK_Sign.h.

143{
144 if (toUpperString(str) == toUpperString(_T("-1"))) return negative_;
145 if (toUpperString(str) == toUpperString(_T("1"))) return positive_;
146 return signNA_;
147}

References _T, STK::negative_, STK::positive_, STK::signNA_, and STK::toUpperString().

Referenced by STK::stringToType< Sign >().

◆ stringToSign() [2/2]

Sign STK::stringToSign ( String const str,
std::map< String, Sign > const mapping 
)
inline

Convert a String to a Sign using a map.

Parameters
strthe String we want to convert
mappingthe mapping between the string and the Sign
Returns
the Sign represented by the String type. if the string does not match any known name, the signNA_ value is returned.

Definition at line 156 of file STK_Sign.h.

157{
158 std::map<String, Sign>::const_iterator it=mapping.find(str);
159 if (it == mapping.end()) return signNA_;
160 return it->second;
161}

References STK::signNA_.

◆ stringToType() [1/2]

template<class Type >
Type STK::stringToType ( String const s)

convert a String to Type without error check

This method return the String s converted into a correct Type t without formatting. http://www.codeguru.com/forum/showpost.php?p=678440&postcount=1 http://c.developpez.com/faq/cpp/?page=strings#STRINGS_is_type

Note
if the conversion fail, the method return a NA value if available for this Type.
Parameters
sthe String to convert
Returns
The value to get from the String

Definition at line 216 of file STK_String.h.

217{
218 Type t;
219 istringstream iss(s);
220 iss >> Proxy<Type>(t);
221 return(t);
222}

◆ stringToType() [2/2]

template<class Type >
bool STK::stringToType ( Type &  t,
String const s,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)

convert a String to Type

This method return true if the String s could be converted into a correct Type t. http://www.codeguru.com/forum/showpost.php?p=678440&postcount=1 http://c.developpez.com/faq/cpp/?page=strings#STRINGS_is_type

Note
The operator >> have been overloaded for the Proxy class in order to return a NA value if the conversion fail.
Parameters
t,svalue to get from the String and String to convert
fflags
Returns
true if the conversion succeed, false otherwise

Definition at line 195 of file STK_String.h.

198{ istringstream iss(s);
199 return !( iss >> f >> Proxy<Type>(t)).fail();
200}

Referenced by STK::DManager::readList(), and STK::Option::setValue().

◆ stringToType< Binary >()

template<>
Binary STK::stringToType< Binary > ( String const str)
inline

specialization for Binary

Parameters
strthe String to convert
Returns
The value to get from the String

Definition at line 186 of file STK_Binary.h.

187{ return stringToBinary(str);}
Binary stringToBinary(String const &str)
Convert a String to a Binary.
Definition STK_Binary.h:134

References STK::stringToBinary().

◆ stringToType< Integer >()

template<>
Integer STK::stringToType< Integer > ( String const s)
inline

specialization for Integer

Parameters
sthe String to convert
Returns
The value to get from the String

Definition at line 201 of file STK_Integer.h.

202{ return stringToInt(s);}
Integer stringToInt(String const &str)
Convert a String to an Integer.

References STK::stringToInt().

◆ stringToType< Real >()

template<>
Real STK::stringToType< Real > ( String const str)
inline

specialization for Real

Parameters
strthe String to convert
Returns
The value to get from the String

Definition at line 208 of file STK_Real.h.

209{ return stringToReal(str);}
Real stringToReal(String const &str)
Convert a String to a Real.
Definition STK_Real.h:154

References STK::stringToReal().

◆ stringToType< Sign >()

template<>
Sign STK::stringToType< Sign > ( String const str)
inline

specialization for Sign

Parameters
strthe String to convert
Returns
The value to get from the String

Definition at line 192 of file STK_Sign.h.

193{ return stringToSign(str);}
Sign stringToSign(String const &str)
Convert a String to a Sign.
Definition STK_Sign.h:142

References STK::stringToSign().

◆ toUpperString() [1/2]

◆ toUpperString() [2/2]

String STK::toUpperString ( String const s)
inline

convert the characters of the String to upper case

Parameters
sThe String to convert
Returns
the string converted to upper case

Definition at line 149 of file STK_String.h.

150{
151 // iterate along the String
152 String str = s;
153 for (String::iterator it = str.begin(); it != str.end(); ++it)
154 { *it = std::toupper(*it);}
155 // return upper cased string
156 return str;
157}

◆ typeToString()

template<class Type >
String STK::typeToString ( Type const t,
std::ios_base &(*)(std::ios_base &)  f = std::dec 
)

convert a Type to String

This method return the Type t into a String s.

See also
http://www.codeguru.com/forum/showpost.php?p=678440&postcount=1
http://c.developpez.com/faq/cpp/?page=strings#STRINGS_convertform
Parameters
tThe value to convert to String
fflag, by default write every number in decimal

Definition at line 235 of file STK_String.h.

236{
237 if (Arithmetic<Type>::isNA(t)) return stringNa;
238 ostringstream oss;
239 return static_cast<ostringstream&>(oss << f << Proxy<Type>(t)).str();
240}

References STK::stringNa.

Referenced by STK::ExportToCsv::append(), STK::ExportToCsv::append(), STK::ExportToCsv::append(), STK::ExportToCsv::append(), STK::ExportToCsv::appendData(), STK::ExportToCsv::ExportToCsv(), STK::ExportToCsv::ExportToCsv(), STK::ExportToCsv::ExportToCsv(), STK::ExportToCsv::ExportToCsv(), STK::DataHandler::readDataFromArray(), STK::DataHandler::readDataFromArray2D(), and STK::ExportToCsv::setColumnsNames().

◆ typeToString< Binary >()

template<>
String STK::typeToString< Binary > ( Binary const t,
std::ios_base &(*)(std::ios_base &)  f 
)
inline

specialization for Binary

Parameters
tThe Binary to convert to String
fformat, by default write every number in decimal

Definition at line 195 of file STK_Binary.h.

196{ return binaryToString(t);}
String binaryToString(Binary const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
Convert a Binary to a String.
Definition STK_Binary.h:160

References STK::binaryToString().

◆ typeToString< Integer >()

template<>
String STK::typeToString< Integer > ( Integer const t,
std::ios_base &(*)(std::ios_base &)  f 
)
inline

specialization for Integer

Parameters
tThe Int to convert to String
fformat, by default write every number in decimal

Definition at line 210 of file STK_Integer.h.

211{ return intToString(t, f);}
String intToString(Integer const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
Convert an Integer to a String.

References STK::intToString().

◆ typeToString< Range >()

template<>
String STK::typeToString< Range > ( Range const t,
std::ios_base &(*)(std::ios_base &)  f 
)
inline

Specialization for Range.

Parameters
tThe Range to convert to String
fformat, by default write every number in decimal

Definition at line 580 of file STK_Range.h.

581{ return rangeToString(t, f);}
String rangeToString(TRange< Size_ > const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
Convert an Range to a String.
Definition STK_Range.h:552

References STK::rangeToString().

◆ typeToString< Real >()

template<>
String STK::typeToString< Real > ( Real const value,
std::ios_base &(*)(std::ios_base &)  f 
)
inline

specialization for Real

Parameters
valueThe Real to convert to String
fformat, by default write every number in decimal

Definition at line 217 of file STK_Real.h.

218{ return realToString(value, f);}
String realToString(Real const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
Convert a Real to a String.
Definition STK_Real.h:181

References STK::realToString().

◆ typeToString< Sign >()

template<>
String STK::typeToString< Sign > ( Sign const t,
std::ios_base &(*)(std::ios_base &)  f 
)
inline

specialization for Sign

Parameters
tThe Sign to convert to String
fformat, by default write every number in decimal

Definition at line 201 of file STK_Sign.h.

202{ return signToString(t);}
String signToString(Sign const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
Convert a Sign to a String.
Definition STK_Sign.h:169

References STK::signToString().

Variable Documentation

◆ stringNa

String STK::stringNa = String(_T("."))

Representation of a Not Available value.

By default we represent a Not Available value of any type as a "." (like in (SAS(R))) for the end-user. This value can be overloaded at runtime.

Note
if the value is modified at runtime, the value of stringNaSize have to be modified accordingly. It is safer to use the setStringNa function.

Definition at line 50 of file STK_String.cpp.

Referenced by STK::binaryToString(), STK::Variable< Type_ >::importFromString(), STK::intToString(), STK::intToString(), STK::operator<<(), STK::operator<<(), STK::Variable< Type_ >::pushBackNAValues(), STK::rangeToString(), STK::rangeToString(), STK::TReadWriteCsv< Type >::read(), STK::DataHandler::readDataFromArray(), STK::DataHandler::readDataFromArray2D(), STK::DataHandler::readDataFromCsvFile(), STK::realToString(), STK::realToString(), STK::Option::setDefaultValue(), STK::setStringNa(), STK::signToString(), STK::typeToString(), and STK::TReadWriteCsv< Type >::writeSelection().

◆ stringNaSize

int STK::stringNaSize = 1

Size (in number of Char) of a Not Available value.

We represent a Not Available value of any type as a "." (like in (SAS(R))) for the end-user.

Definition at line 57 of file STK_String.cpp.

Referenced by STK::setStringNa().