Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

convert.cpp File Reference

contains function implementations that convert floats into other types More...

Include dependency graph for convert.cpp:

Include dependency graph

Go to the source code of this file.

Functions

double stod (string instring)
 A function that converts a string to a double precision number.

float stof (string instring)
 A function that converts a string to a single precision number.

int stoi (string instring)
 A function that converts a string to an integer.

string remove_leading_blanks (string instring)
 A function that removes the leading blanks of a string.

string remove_trailing_blanks (string instring)
 A function that removes the trailing blanks of a string.

string remove_extra_blanks (string instring)
 A function that removes extra blanks in a string.

string remove_all_blanks (string instring)
 A function that removes all blanks in a string.

vector< string > split (const string &s, const string pattern)
string join (const vector< string > &ls, const string pattern)
 joins a list of strings using "pattern" as glue

string tolower (const string &s)
 A function that lower-cases strings.

string operator * (int i, const string x)
 i copies of a string x pasted together

string center (const string stuff, int len)
 center a string in a field of a certain length

string ljust (const string stuff, int len)
 left justify a string in a field of a certain length

string rjust (string stuff, int len)
 right justify a string in a field of a certain length


Detailed Description

This file contains the set of functions that convert floating point numbers, lifted from files a line at atime into c++ strings, into doubles, floats and integers. Some time was invested for the sake of robustness; these functions have also been written to handle formats that exclude the use of the letter e in the exponent, a local invention/abomination. Also included in this file is a set of functions that remove blanks from string objects.

Definition in file convert.cpp.


Function Documentation

string center const string  stuff,
int  len
 

Definition at line 248 of file convert.cpp.

Referenced by main(), GlobalParameterClass::read_command_line(), and MessageLogger::write().

string join const vector< string > &  ls,
const string  pattern
 

Definition at line 218 of file convert.cpp.

string ljust const string  stuff,
int  len
 

Definition at line 257 of file convert.cpp.

Referenced by MessageLogger::write().

string operator * int  i,
const string  x
 

Definition at line 241 of file convert.cpp.

string remove_all_blanks string  instring  ) 
 

Parameters:
instring The string from which all the blanks will be removed
This function removes all blanks from a string, regardless of where they are located within the string.

Definition at line 184 of file convert.cpp.

Referenced by bdflsClass::read_sections().

string remove_extra_blanks string  instring  ) 
 

Parameters:
instring The string from which the extra blanks will be removed
This function removes "extra" blanks from a string. Leading, trailing and more than one contiguous blank are deleted from the string. The leading and trailing blanks are removed with calls to remove_leading_blanks() and remove_trailing_blanks().

Definition at line 165 of file convert.cpp.

References remove_leading_blanks(), and remove_trailing_blanks().

Referenced by GlobalParameterClass::read_file(), and GlobalParameterClass::set().

string remove_leading_blanks string  instring  ) 
 

Parameters:
instring The string from which the leading blanks will be removed
This function steps through the string from the beginning, removing the blanks until a non-blank character is found.

Definition at line 137 of file convert.cpp.

Referenced by remove_extra_blanks().

string remove_trailing_blanks string  instring  ) 
 

Parameters:
instring The string from which the trailing blanks will be removed
This function steps backward through the string starting from the last character, removing the blanks until a non-blank character is found.

Definition at line 151 of file convert.cpp.

Referenced by remove_extra_blanks().

string rjust string  stuff,
int  len
 

Definition at line 264 of file convert.cpp.

Referenced by operator<<().

vector< string > split const string &  s,
const string  pattern
 

splits a string at all occurances of "pattern" and returns the substrings in a list

Definition at line 199 of file convert.cpp.

Referenced by bdflsClass::read_sections().

double stod string  instring  ) 
 

Parameters:
instring The string to be converted into a double
This function was written as a substitute for the standard function, atof. Many times we need to deal with floating point numbers with a format that excludes the "e" used to delineate the exponent part of the number. This function remedies the situation by scanning for sign of the exponent. It also look for other trivial peculiarities to avoid bombing. Be assured, this function will bomb if you send it nonsense.

Definition at line 41 of file convert.cpp.

References SevereError(), and tolower().

Referenced by read_d(), Kalbach_data::read_data(), read_dd(), read_ddd(), read_dddddd(), read_ddiiii(), read_idiiii(), read_iiiddddd(), read_iiidiiddd(), bdflsClass::read_sections(), stof(), and stoi().

float stof string  instring  ) 
 

Parameters:
instring The string to be converted to a float
This function calls the stod() function. The result is just recast to single precision.

Definition at line 123 of file convert.cpp.

References stod().

Referenced by GlobalParameterClass::Value().

int stoi string  instring  ) 
 

Parameters:
instring The string to be converted to an integer
This function just calls stod() and recasts the result as an integer.

Definition at line 130 of file convert.cpp.

References stod().

Referenced by b6stream::get_MAT_MF_MT_NS(), read_date(), read_ddiiii(), read_idiiii(), read_ii(), read_iiiddddd(), read_iiidiiddd(), and bdflsClass::read_sections().

string tolower const string &  s  ) 
 

Definition at line 232 of file convert.cpp.

Referenced by GlobalParameterClass::Flag(), GlobalParameterClass::set(), stod(), and GlobalParameterClass::Value().


Generated on Thu Sep 7 10:31:11 2006 for fete -- From ENDFB6 To ENDL by doxygen 1.3.4