Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Utils.hpp File Reference

An include file containing the definition of some useful functions not directly linked with the main problem. More...

#include <iostream>
#include <istream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <cmath>

Go to the source code of this file.

Functions

template<typename T>
fromString (const std::string &s)
 read a variable of type T from a string representation s.
template<typename T>
std::string toString (const T &t)
 store the string representation of variable t in string s.
template<typename T>
void ReadVector (istream &is, std::vector< T > &tvec)
template<typename T>
void WriteVector (ostream &os, const std::vector< T > &tvec)
char upper (char c)


Detailed Description

For the moment, it contains some string conversion functions.

Function Documentation

template<typename T>
T fromString const std::string &  s  ) 
 

This is a shortcut to read any type T from a string s. It is a C++ equivalent for sscanf. An example use is :

string s="123";
uint i=fromString<uint>(s); -> i=123
double x=fromSting<double>("3.145"); -> x=3.145

template<typename T>
void ReadVector istream &  is,
std::vector< T > &  tvec
 

Read a vector.

template<typename T>
string toString const T &  t  ) 
 

This is a shortcut to print any type T as a string s. It is a C++ equivalent for sprintf. An example use is :

uint i=123;
string si=toString<uint>(i); -> si="123"
string sd=toString<double>(3.145); -> sd="3.145"

char upper char  c  ) 
 

Convert a character to upper case.

template<typename T>
void WriteVector ostream &  os,
const std::vector< T > &  tvec
 

Write a vector.


Generated on Thu Jan 12 11:54:59 2006 for NEM by  doxygen 1.4.4