te::common Namespace Reference

Namespace for the Common module of TerraLib. More...

Namespaces

 lx
 
 uri
 
 win
 

Classes

class  AbstractFactory
 This class defines the interface of abstract factories without initializing parameters. More...
 
class  AbstractParameters
 Abstract parameters base interface. More...
 
class  AbstractProgressViewer
 A class that defines the interface of an abstract progress viewer. More...
 
class  ApplicationSettings
 A class for managing application settings. More...
 
class  BaseVisitable
 The root of all hierarchies that can be visited. More...
 
class  BaseVisitor
 A general root class for a visitor hierarchy. More...
 
class  CharEncodingConv
 This class deals with character encoding/decoding. More...
 
class  ClassLevelLockable
 This policy assures a class-level locking scheme for a derived class. More...
 
class  ConsoleProgressViewer
 
class  Counted
 A counted class keeps track of how many abstract instances are pointing to it. More...
 
class  Decorator
 
class  Distance
 A given distance has a measurement and a unit-of-measure. More...
 
class  Exception
 This class is designed to declare objects to be thrown as exceptions by TerraLib. More...
 
class  FactoryDictionary
 This class represents a dictionary of factories. More...
 
class  Globals
 An static class with global definitions. More...
 
struct  Holder
 An auxiliary data structure for helping to control the garbage collection of C++ objects. More...
 
struct  LessCmp
 It implements several compare functions. More...
 
struct  LessCmp< const char * >
 
struct  LessCmp< T * >
 
class  Library
 A class for handling shared libraries (DLLs, SO, DyLibs). More...
 
class  LibraryManager
 A singleton that can be used to observe the available libraries in the system. More...
 
class  LoggedException
 A class that automatically logs the exception message. More...
 
class  Module
 This singleton defines an entry in the Platform for the TerraLib Common Runtime module. More...
 
struct  NodeT
 Struct that represents a node in the Queue. More...
 
class  NonLockable
 This policy doesn't actually perform a lock. More...
 
class  ObjectLevelLockable
 This policy assures an object-level locking scheme for a derived class. More...
 
class  ParameterizedAbstractFactory
 This class defines the basic interface of an abstract factory that makes use of parameters to construct the objects. More...
 
class  ProgressManager
 A singleton class used to manage tasks progresses and their viewers. More...
 
class  ProgressTimer
 The ProgressTimer is a utility class that can be used to calculate the estimated time to finish a task. More...
 
struct  QueueT
 Struct that implements the generic queue. More...
 
class  Singleton
 Template support for singleton pattern. More...
 
class  Static
 A base type for static classes. More...
 
class  SystemApplicationSettings
 A singleton for managing application settings applied to the whole system (all users). More...
 
class  TaskProgress
 This class can be used to inform the progress of a task. More...
 
class  TreeItem
 This abstract class describes a basic item to be organized in a tree-oriented way. More...
 
class  UnitOfMeasure
 A class to represent units of measure. More...
 
class  UnitsOfMeasureManager
 A singleton class for dealing with units of measure in the TerraLib environment. More...
 
class  URL
 A class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine. This class is based on the MIT code uripp http://uripp.sourceforge.net/ . More...
 
class  UserApplicationSettings
 A singleton for managing application settings applied to a single user. More...
 
class  Version
 
class  Visitor
 A generic class for visitors. More...
 

Typedefs

typedef boost::shared_ptr< LibraryLibraryPtr
 
typedef boost::intrusive_ptr< TreeItemTreeItemPtr
 
typedef boost::shared_ptr< UnitOfMeasureUnitOfMeasurePtr
 

Enumerations

enum  {
  UOM_Metre = 9001, UOM_Foot = 9002, UOM_NauticalMile = 9030, UOM_Kilometre = 9036,
  UOM_Yard = 9096, UOM_Radian = 9101, UOM_Degree = 9102, UOM_Unity = 9201
}
 Defines some known UOM (Unit of Measure) codes. More...
 
enum  { UNKNOWN_EXCEPTION = 0, NO_CONNECTION_AVAILABLE = 1 }
 Common TerraLib Exception Codes. More...
 
enum  { LAST_COMMON_EXCEPTION_CODE = NO_CONNECTION_AVAILABLE }
 An anonymous union that marks the last common TerraLib Exception Code. More...
 
enum  AccessPolicy { NoAccess = 0, RAccess = 1, WAccess = 2, RWAccess = 3 }
 Supported data access policies (can be used as bitfield). More...
 
enum  CharEncoding {
  UTF8, CP1250, CP1251, CP1252,
  CP1253, CP1254, CP1257, LATIN1,
  UNKNOWN_CHAR_ENCODING
}
 Supported charsets (character encoding). More...
 
enum  Hemisphere { NorthHem = 0, SouthHem = 1 }
 
enum  LoggerConfigurationType { LOGGER_XML_CONFIG, LOGGER_TXT_CONFIG }
 Each enumerated type tells TerraLib how the configuration is done for a logger. More...
 
enum  MachineByteOrder { XDR = 0, NDR = 1 }
 Endianness. More...
 
enum  MeasureType {
  Length, Area, Volume, Angle,
  Scale, Time, Speed
}
 Defines the possible types of unit of measurements. More...
 
enum  TraverseType { FORWARDONLY = 0, BIDIRECTIONAL = 1, RANDOM = 2 }
 A dataset can be traversed in two ways: More...
 

Functions

char * Binary2Hex (const char *s, std::size_t size)
 Each char from the array of characters in binary format is converted into a pair of hex characters. The final string is NULL terminated. More...
 
void Binary2Hex (const char *s, std::size_t size, char *outBuff)
 Each char from the array of characters in binary format is converted into a pair of hex characters. The final string is NULL terminated. More...
 
void Char2Hex (unsigned char c, char *r)
 It converts the character to a hex representation. More...
 
template<class T >
void Clone (const std::vector< T * > &src, std::vector< T * > &dst)
 This function can be applied to a vector of pointers. More...
 
template<class T >
bool Contains (const std::vector< T > &src, const T &value)
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::map< std::string, std::string > &dict)
 Converts a property tree node into a std::map<std::string, std::string>. More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< std::pair< std::string, std::string > > &vp)
 Converts a property tree node into a std::vector<std::pair<std::string, std::string> > More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< std::string > &vect)
 Converts a property tree node into a std::vector<std::string>. More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< unsigned char > &vectd)
 Converts a property tree node into a std::vector<unsigned char>. More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< double > &vectd)
 Converts a property tree node into a std::vector<double>. More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< size_t > &vectd)
 Converts a property tree node into a std::vector<size_t>. More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< std::vector< double > > &vect)
 Converts a property tree node into a std::vector<vector<std::string> >. More...
 
TECOMMONEXPORT void Convert (const boost::property_tree::ptree &p, std::vector< std::map< std::string, std::string > > &vectm)
 Converts a property tree node into a std::vector<std::map<std::string, std::string> >. More...
 
std::string Convert2LCase (const std::string &value)
 It converts a string to lower case. More...
 
std::string Convert2String (boost::int16_t value)
 It converts a short integer value to a string. More...
 
std::string Convert2String (boost::uint16_t value)
 It converts a unsigned short integer value to a string. More...
 
std::string Convert2String (boost::int32_t value)
 It converts an integer value to a string. More...
 
std::string Convert2String (boost::uint32_t value)
 It converts an unsigned integer value to a string. More...
 
std::string Convert2String (boost::int64_t value)
 It converts a long value to a string. More...
 
std::string Convert2String (boost::uint64_t value)
 It converts a unsigned long value to a string. More...
 
std::string Convert2String (float value)
 It converts a double value to a string. More...
 
std::string Convert2String (double value)
 It converts a double value to a string. More...
 
std::string Convert2String (double value, int precision)
 It converts a double value to a string with a precision. More...
 
std::string Convert2UCase (const std::string &value)
 It converts a string to upper case. More...
 
void Convert2UCaseInPlace (std::string &value)
 It converts a string to upper case in place (it doesn't allocate an auxiliar buffer). More...
 
TECOMMONEXPORT std::string ConvertLatin1UTFString (const std::string &data, const bool &toUtf=true)
 Converts a string from latin1 to utf8 and vice-versa. More...
 
template<class T >
void Copy (const std::vector< T * > &src, std::vector< T * > &dst)
 This function can be applied to a vector of pointers. It will copy element by element through its copy constructor supposing a vector of pointers. More...
 
char * CreateCString (const std::string &s)
 It converts the C++ string to a C-string. More...
 
char ** CreateCStringArray (const std::vector< std::string * > &vs)
 It converts the C++ vector of string pointers to a C array os strings. More...
 
char ** CreateCStringArray (const std::vector< std::string > &vs)
 It converts the C++ vector of string pointers to a C array os strings. More...
 
template<class T >
bool EigenVectors (const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &eigenVectorsMatrix, boost::numeric::ublas::matrix< T > &eigenValuesMatrix)
 Computes the eigenvectors of a given matrix. More...
 
void ExtractKVP (const std::string &kvpStr, std::map< std::string, std::string > &kvp, const std::string &kvpDelimiter="&", const std::string &kvDelimiter="=", bool toUpper=false)
 It extracts a key-value map from a string. More...
 
TECOMMONEXPORT std::string FindInTerraLibPath (const std::string &p)
 Returns the path relative to a directory or file in the context of TerraLib. More...
 
template<class T >
void Free (std::vector< T * > *v)
 This function can be applied to a pointer to a vector of pointers. More...
 
void Free (char **carray)
 It releases the char array. More...
 
template<class T >
void Free (T **a, std::size_t s)
 It releases the given array. More...
 
template<class T >
void FreeContents (const std::vector< T * > &v)
 This function can be applied to a vector of pointers. It will delete each pointer in the vector. More...
 
template<class K , class V >
void FreeContents (boost::unordered_map< K, V * > &m)
 This function can be applied to a map of pointers. It will delete each pointer in the map. More...
 
template<class T >
void FreeContents (std::list< T * > &l)
 This function can be applied to a list of pointers. It will delete each pointer in the vector. More...
 
template<class K , class V >
void FreeContents (std::map< K, V * > &m)
 This function can be applied to a map of pointers. It will delete each pointer in the map. More...
 
template<class V , class C >
void FreeContents (std::set< V *, C > &m)
 This function can be applied to a map of pointers. It will delete each pointer in the map. More...
 
template<class IT >
void FreeContents (IT it, IT itend)
 This function can be applied to a vector of pointers. It will delete each pointer in the vector. More...
 
TECOMMONEXPORT void GetAccentuatedLowerVector (std::vector< std::string > &vecLowerIn, std::vector< std::string > &vecLowerOut)
 It build two string vectors with special lower case characters and the his respective normal characters. More...
 
TECOMMONEXPORT void GetAccentuatedUpperVector (std::vector< std::string > &vecUpperIn, std::vector< std::string > &vecUpperOut)
 It build two string vectors with special upper case characters and the his respective normal characters. More...
 
unsigned char GetDecimalFromHexLCase (char hexValue)
 It returns the decimal value in a char from a given hex value (for example: 'a' => 10, '8' => 8). More...
 
unsigned char GetDecimalFromHexNotCS (unsigned char hexValue)
 It returns the decimal value in a char from a given hex value (for example: 'A' => 10, '8' => 8). More...
 
unsigned char GetDecimalFromHexUCase (char hexValue)
 It returns the decimal value in a char from a given hex value (for example: 'A' => 10, '8' => 8). More...
 
TECOMMONEXPORT void GetDecompostedLDPathEnvVar (std::vector< std::string > &paths)
 Returns the system LD_LIBRARY_PATH enviroment variable, decomposed into directory names, or an empty vector if no values were found. More...
 
TECOMMONEXPORT void GetDecompostedPathEnvVar (std::vector< std::string > &paths)
 Returns the system PATH enviroment variable, decomposed into directory names, or an empty vector if no values were found. More...
 
template<class T >
bool GetDeterminant (const boost::numeric::ublas::matrix< T > &inputMatrix, T &determinant)
 Get the Matrix determinant value. More...
 
TECOMMONEXPORT void GetEspecialCharsFixVector (std::vector< std::string > &especialIn, std::vector< std::string > &especialOut)
 It build two string vectors with special characters and the his respective normal characters. More...
 
TECOMMONEXPORT unsigned long int GetFreePhysicalMemory ()
 Returns the amount of free physical memory (bytes). More...
 
template<class T >
bool GetInverseMatrix (const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &outputMatrix)
 Matrix inversion. More...
 
TECOMMONEXPORT unsigned int GetPhysProcNumber ()
 Returns the number of physical processors. More...
 
template<class K , class V >
V ** GetPPValue (std::map< K, V * > &m, const K &k)
 It finds for a given key in the map and returns a pointer if something is found or NULL otherwise. More...
 
template<class T >
bool GetPseudoInverseMatrix (const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &outputMatrix)
 Pseudo matrix inversion. More...
 
template<class K , class V >
V * GetPValue (const std::map< K, V * > &m, const K &k)
 It finds for a given key in the map and returns a pointer if something is found or NULL otherwise. More...
 
template<class K , class C >
K * GetPValue (const std::set< K *, C > &m, K *k)
 It finds for a given key in the map and returns a pointer if something is found or NULL otherwise. More...
 
TECOMMONEXPORT unsigned long int GetTotalPhysicalMemory ()
 Returns the amount of total physical memory (bytes). More...
 
TECOMMONEXPORT unsigned long int GetTotalVirtualMemory ()
 Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physical + swapped). More...
 
TECOMMONEXPORT unsigned long int GetUsedVirtualMemory ()
 Returns the amount of used virtual memory (bytes) for the current process (physical + swapped). More...
 
char * Hex2Binary (const char *hex)
 It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary format. More...
 
void Hex2Binary (const char *hex, std::size_t hSize, char *outBuff)
 It converts each pair of hex characters from an input string of hex characters into a binary format. More...
 
char * Hex2Binary2 (const char *hex)
 It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary format. More...
 
void Hex2Binary2 (const char *hex, std::size_t hSize, char *outBuff)
 It converts each pair of hex characters from an input string of hex characters into a binary format. More...
 
char Hex2Char (const char *hex)
 It converts the character from a hex representation to a byte. More...
 
unsigned char Hex2Char2 (const char *hex)
 It converts the character from a hex representation to a byte. More...
 
void intrusive_ptr_add_ref (Counted *p)
 
void intrusive_ptr_release (Counted *p)
 
std::ostream & operator<< (const Exception &e, std::ostream &o)
 It serializes the exception and sends it to the output stream. More...
 
TECOMMONEXPORT std::string ReplaceSpecialChars (const std::string &str, bool &changed)
 It replace special characters of a string. More...
 
template<class T >
void Swap2Bytes (T &v)
 It swaps two bytes in local. More...
 
void Swap2Bytes (char *v)
 It swaps an array of two bytes in local. More...
 
template<class T >
void Swap4Bytes (T &v)
 It swaps four bytes in local. More...
 
void Swap4Bytes (char *v)
 It swaps an array of four bytes in local. More...
 
void Swap8Bytes (char *v)
 It swaps an array of eight bytes in local. More...
 
template<class T >
void SwapBytes (T &v)
 It swaps the bytes in local. More...
 
template<>
void SwapBytes (boost::int16_t &v)
 It swaps 2 bytes in local. More...
 
template<>
void SwapBytes (boost::int32_t &v)
 It swaps four bytes in local. More...
 
template<>
void SwapBytes (boost::uint32_t &v)
 It swaps four bytes in local. More...
 
template<>
void SwapBytes (float &v)
 It swaps four bytes in local. More...
 
void Tokenize (const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
 It tokenizes a given string with a delimiter of your own choice. More...
 

Detailed Description

Namespace for the Common module of TerraLib.

Typedef Documentation

typedef boost::shared_ptr<Library> te::common::LibraryPtr

Definition at line 184 of file Library.h.

typedef boost::intrusive_ptr<TreeItem> te::common::TreeItemPtr

Definition at line 44 of file TreeItem.h.

typedef boost::shared_ptr<UnitOfMeasure> te::common::UnitOfMeasurePtr

Definition at line 213 of file UnitOfMeasure.h.

Enumeration Type Documentation

anonymous enum

Defines some known UOM (Unit of Measure) codes.

Note
Values from 9001 to 9302 coincide with EPSG codes.
Enumerator
UOM_Metre 
UOM_Foot 
UOM_NauticalMile 
UOM_Kilometre 
UOM_Yard 
UOM_Radian 
UOM_Degree 
UOM_Unity 

Definition at line 92 of file Enums.h.

anonymous enum

Common TerraLib Exception Codes.

Enumerator
UNKNOWN_EXCEPTION 
NO_CONNECTION_AVAILABLE 

Definition at line 123 of file Enums.h.

anonymous enum

An anonymous union that marks the last common TerraLib Exception Code.

Enumerator
LAST_COMMON_EXCEPTION_CODE 

Definition at line 130 of file Enums.h.

Supported data access policies (can be used as bitfield).

Enumerator
NoAccess 

No access allowed

RAccess 

Read-only access allowed

WAccess 

Write-only access allowed

RWAccess 

Read and write access allowed

Definition at line 40 of file Enums.h.

Supported charsets (character encoding).

As described in Wikipedia (http://en.wikipedia.org/wiki/Character_encoding), the terms character encoding, character set (charset), and sometimes character map or code page are used interchangeably.

Enumerator
UTF8 

UTF-8 encoding.

CP1250 

CP1250 encoding.

CP1251 

CP1251 encoding.

CP1252 

CP1252 encoding.

CP1253 

CP1253 encoding.

CP1254 

CP1254 encoding.

CP1257 

CP1257 encoding.

LATIN1 

ISO-8859-1 encoding (Latin1).

UNKNOWN_CHAR_ENCODING 

Unknown encoding.

Definition at line 45 of file CharEncodingConv.h.

Enumerator
NorthHem 

North hemisphere.

SouthHem 

South hemisphere.

Definition at line 105 of file Enums.h.

Each enumerated type tells TerraLib how the configuration is done for a logger.

Enumerator
LOGGER_XML_CONFIG 

It indicates the use of a XML based configuration for a logger.

LOGGER_TXT_CONFIG 

It indicates the use of a plain text file based configuration for a logger.

Definition at line 65 of file Enums.h.

Endianness.

Enumerator
XDR 

Big endian.

NDR 

Little endian.

Definition at line 116 of file Enums.h.

Defines the possible types of unit of measurements.

Enumerator
Length 

Refers to lenght measurements.

Area 

Refers to area measurements.

Volume 

Refers to volume measurements.

Angle 

Refers to angular measurements.

Scale 

Refers to scale measurements.

Time 

Refers to time measurements.

Speed 

Refers to speed measurements.

Definition at line 76 of file Enums.h.

A dataset can be traversed in two ways:

Enumerator
FORWARDONLY 

Used when the dataset is only able to move forward.

BIDIRECTIONAL 

Used when the dataset is able to move forward and backward.

RANDOM 

Used when the dataset is able to move to any item.

Definition at line 53 of file Enums.h.

Function Documentation

char* te::common::Binary2Hex ( const char *  s,
std::size_t  size 
)
inline

Each char from the array of characters in binary format is converted into a pair of hex characters. The final string is NULL terminated.

Parameters
sAn array of characters in binary format.
sizeThe size of the string of characters (not including the trailing '\0').
Note
The caller of this function will take the ownership of the returned pointer, so it must delete it. Use delete [] returned_pointer.
The returned buffer size is: 2 * size + 1.

Definition at line 602 of file HexUtils.h.

References Char2Hex().

void te::common::Binary2Hex ( const char *  s,
std::size_t  size,
char *  outBuff 
)
inline

Each char from the array of characters in binary format is converted into a pair of hex characters. The final string is NULL terminated.

Parameters
sAn array of characters in binary format.
sizeThe size of the string of characters (not including the trailing '\0').
outBuffA pointer to a pre-allocated buffer where to output the binary version. It must have at least 2*size+1 bytes.

Definition at line 623 of file HexUtils.h.

References Char2Hex().

void te::common::Char2Hex ( unsigned char  c,
char *  r 
)
inline

It converts the character to a hex representation.

Parameters
cThe byte to be transformed to hex representation.
rThe resulting hex encoding will be write in the r pointer.
Note
It is used by Binary2Hex function.

Definition at line 248 of file HexUtils.h.

Referenced by Binary2Hex().

template<class T >
void te::common::Clone ( const std::vector< T * > &  src,
std::vector< T * > &  dst 
)
inline

This function can be applied to a vector of pointers.

It will clone element by element supposing a vector of pointers.

Parameters
srcThe source vector with pointers to be cloned.
dstThe target vector with cloned pointers.
Note
The type T must implement a method called clone().

Definition at line 237 of file STLUtils.h.

template<class T >
bool te::common::Contains ( const std::vector< T > &  src,
const T &  value 
)
inline

Definition at line 265 of file STLUtils.h.

TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::map< std::string, std::string > &  dict 
)

Converts a property tree node into a std::map<std::string, std::string>.

Parameters
pA node that can be converted to a std::map<std::string, std::string>.
dictThe dictionary to output the key-value pairs.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< std::pair< std::string, std::string > > &  vp 
)

Converts a property tree node into a std::vector<std::pair<std::string, std::string> >

Parameters
pA node that can be converted to a std::vector<std::pair<std::string, std::string> >.
vpThe vector of pairs returned.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< std::string > &  vect 
)

Converts a property tree node into a std::vector<std::string>.

Parameters
pA node that can be converted to a std::vector<std::string>.
vectThe vector to output the values.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< unsigned char > &  vectd 
)

Converts a property tree node into a std::vector<unsigned char>.

Parameters
pA node that can be converted to a std::vector<unsigned char>.
vectdThe vector to output the values.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< double > &  vectd 
)

Converts a property tree node into a std::vector<double>.

Parameters
pA node that can be converted to a std::vector<double>.
vectdThe vector to output the values.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< size_t > &  vectd 
)

Converts a property tree node into a std::vector<size_t>.

Parameters
pA node that can be converted to a std::vector<size_t>.
vectdThe vector to output the values.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< std::vector< double > > &  vect 
)

Converts a property tree node into a std::vector<vector<std::string> >.

Parameters
pA node that can be converted to a std::vector<vector<std::string> >.
vectThe vector to output the values.
TECOMMONEXPORT void te::common::Convert ( const boost::property_tree::ptree &  p,
std::vector< std::map< std::string, std::string > > &  vectm 
)

Converts a property tree node into a std::vector<std::map<std::string, std::string> >.

Parameters
pA node that can be converted to a std::vector<std::map<std::string, std::string> >.
vectThe vector to output the values.
std::string te::common::Convert2LCase ( const std::string &  value)
inline

It converts a string to lower case.

Parameters
valueThe string value to be converted.
Returns
The converted string.

Definition at line 200 of file StringUtils.h.

std::string te::common::Convert2String ( boost::int16_t  value)
inline

It converts a short integer value to a string.

Returns
The integer value converted to a string.

Definition at line 54 of file StringUtils.h.

Referenced by te::pgis::Convert2PostGIS(), te::map::GroupingByEqualSteps(), te::map::GroupingByQuantil(), and te::map::GroupingByStdDeviation().

std::string te::common::Convert2String ( boost::uint16_t  value)
inline

It converts a unsigned short integer value to a string.

Returns
The integer value converted to a string.

Definition at line 66 of file StringUtils.h.

std::string te::common::Convert2String ( boost::int32_t  value)
inline

It converts an integer value to a string.

Returns
The integer value converted to a string.

Definition at line 78 of file StringUtils.h.

std::string te::common::Convert2String ( boost::uint32_t  value)
inline

It converts an unsigned integer value to a string.

Returns
The unsigned integer value converted to a string.

Definition at line 90 of file StringUtils.h.

std::string te::common::Convert2String ( boost::int64_t  value)
inline

It converts a long value to a string.

Returns
The long value converted to a string.

Definition at line 102 of file StringUtils.h.

std::string te::common::Convert2String ( boost::uint64_t  value)
inline

It converts a unsigned long value to a string.

Returns
The unsigned long value converted to a string.

Definition at line 114 of file StringUtils.h.

std::string te::common::Convert2String ( float  value)
inline

It converts a double value to a string.

Returns
The double value converted to a string.

Definition at line 126 of file StringUtils.h.

std::string te::common::Convert2String ( double  value)
inline

It converts a double value to a string.

Returns
The double value converted to a string.

Definition at line 138 of file StringUtils.h.

std::string te::common::Convert2String ( double  value,
int  precision 
)
inline

It converts a double value to a string with a precision.

Returns
The double value converted with the given precision to a string.
Warning
Max allowed precision is 20.

Definition at line 152 of file StringUtils.h.

std::string te::common::Convert2UCase ( const std::string &  value)
inline

It converts a string to upper case.

Parameters
valueThe string value to be converted.
Returns
The converted string.

Definition at line 166 of file StringUtils.h.

void te::common::Convert2UCaseInPlace ( std::string &  value)
inline

It converts a string to upper case in place (it doesn't allocate an auxiliar buffer).

Parameters
valueThe string value to be converted.
Returns
The converted string.

Definition at line 185 of file StringUtils.h.

Referenced by ExtractKVP().

TECOMMONEXPORT std::string te::common::ConvertLatin1UTFString ( const std::string &  data,
const bool &  toUtf = true 
)

Converts a string from latin1 to utf8 and vice-versa.

Parameters
dataThe string to be translated.
toUtfIf true converts a Latin1 string to UTF-8 string, else converts from a UTF-8 string to a Latin1 string.
template<class T >
void te::common::Copy ( const std::vector< T * > &  src,
std::vector< T * > &  dst 
)
inline

This function can be applied to a vector of pointers. It will copy element by element through its copy constructor supposing a vector of pointers.

Parameters
srcThe source vector with pointers to be cloned.
dstThe target vector with cloned pointers.
Note
The type T must implement the copy constructor method.

Definition at line 255 of file STLUtils.h.

char* te::common::CreateCString ( const std::string &  s)
inline

It converts the C++ string to a C-string.

Parameters
sThe C++ string to be converted to a char*.
Returns
A C-string. The caller will take the ownership of the returned string and must use 'delete [] pointer' to release it when necessary.

Definition at line 310 of file StringUtils.h.

char** te::common::CreateCStringArray ( const std::vector< std::string * > &  vs)
inline

It converts the C++ vector of string pointers to a C array os strings.

Parameters
vsThe C++ vector of string pointers to be converted to a char**.
Returns
A C array os strings NULL terminated. The caller will take the ownership of the returned array.

Definition at line 324 of file StringUtils.h.

char** te::common::CreateCStringArray ( const std::vector< std::string > &  vs)
inline

It converts the C++ vector of string pointers to a C array os strings.

Parameters
vsThe C++ vector of string pointers to be converted to a char**.
Returns
A C array os strings NULL terminated. The caller will take the ownership of the returned array.

Definition at line 349 of file StringUtils.h.

template<class T >
bool te::common::EigenVectors ( const boost::numeric::ublas::matrix< T > &  inputMatrix,
boost::numeric::ublas::matrix< T > &  eigenVectorsMatrix,
boost::numeric::ublas::matrix< T > &  eigenValuesMatrix 
)

Computes the eigenvectors of a given matrix.

Parameters
inputMatrixThe input matrix.
eigenVectorsMatrixThe matrix where the eigenvectors will be stored.
eigenValuesMatrixThe matrix where the eigenvalues will be stored.
Returns
true if ok, false on errors.

Definition at line 211 of file MatrixUtils.h.

void te::common::ExtractKVP ( const std::string &  kvpStr,
std::map< std::string, std::string > &  kvp,
const std::string &  kvpDelimiter = "&",
const std::string &  kvDelimiter = "=",
bool  toUpper = false 
)
inline

It extracts a key-value map from a string.

Parameters
kvpStrA string with key-value-pairs to be splitted.
kvpA map to output the pairs: (parameter-name, parameter-value).
kvpDelimiterThe character used to delimit the key-value-pairs.
kvDelimiterThe character used to delimit a key from its value.
toUpperIf true the key will be converted to upper-case. The value case will not be touched.
Precondition
The kvpStr must already be cleaned if necessary (see CleanQueryString function if needed).

Definition at line 254 of file StringUtils.h.

References Convert2UCaseInPlace(), and Tokenize().

TECOMMONEXPORT std::string te::common::FindInTerraLibPath ( const std::string &  p)

Returns the path relative to a directory or file in the context of TerraLib.

Parameters
pA path to be searched in the TerraLib context.
Returns
A complete path to the file or directory if it is found, otherwise returns an empty string.
template<class T >
void te::common::Free ( std::vector< T * > *  v)
inline

This function can be applied to a pointer to a vector of pointers.

It will delete each pointer in the vector and then delete the pointer to the vector.

Parameters
vA pointer to a vector of pointers to be cleaned.

Definition at line 131 of file STLUtils.h.

void te::common::Free ( char **  carray)
inline

It releases the char array.

Parameters
carrayA NULL terminated array of characters pointers.

Definition at line 149 of file STLUtils.h.

template<class T >
void te::common::Free ( T **  a,
std::size_t  s 
)
inline

It releases the given array.

Parameters
aThe array that will be released.
sThe array size.

Definition at line 163 of file STLUtils.h.

template<class T >
void te::common::FreeContents ( const std::vector< T * > &  v)
inline

This function can be applied to a vector of pointers. It will delete each pointer in the vector.

Parameters
vThe vector of pointers to be cleaned.
Note
It will not clear the vector at the end of the cleanup.

Definition at line 49 of file STLUtils.h.

template<class K , class V >
void te::common::FreeContents ( boost::unordered_map< K, V * > &  m)
inline

This function can be applied to a map of pointers. It will delete each pointer in the map.

Parameters
mThe map of pointers to be cleaned.
Note
It will not clear the map at the end of the cleanup.

Definition at line 55 of file BoostUtils.h.

Referenced by te::rst::BandIteratorWindow< T >::BandIteratorWindow(), te::rst::BandIteratorWindow< T >::operator=(), and te::rst::BandIteratorWindow< T >::~BandIteratorWindow().

template<class T >
void te::common::FreeContents ( std::list< T * > &  l)
inline

This function can be applied to a list of pointers. It will delete each pointer in the vector.

Parameters
lThe list of pointers to be cleaned.
Note
It will not clear the list at the end of the cleanup.

Definition at line 64 of file STLUtils.h.

template<class K , class V >
void te::common::FreeContents ( std::map< K, V * > &  m)
inline

This function can be applied to a map of pointers. It will delete each pointer in the map.

Parameters
mThe map of pointers to be cleaned.
Note
It will not clear the map at the end of the cleanup.

Definition at line 77 of file STLUtils.h.

template<class V , class C >
void te::common::FreeContents ( std::set< V *, C > &  m)
inline

This function can be applied to a map of pointers. It will delete each pointer in the map.

Parameters
mThe map of pointers to be cleaned.
Note
It will not clear the map at the end of the cleanup.

Definition at line 96 of file STLUtils.h.

template<class IT >
void te::common::FreeContents ( IT  it,
IT  itend 
)
inline

This function can be applied to a vector of pointers. It will delete each pointer in the vector.

Parameters
vThe vector of pointers to be cleaned.
Note
It will not clear the vector at the end of the cleanup.

Definition at line 115 of file STLUtils.h.

TECOMMONEXPORT void te::common::GetAccentuatedLowerVector ( std::vector< std::string > &  vecLowerIn,
std::vector< std::string > &  vecLowerOut 
)

It build two string vectors with special lower case characters and the his respective normal characters.

Parameters
vecUpperInThe vector with lower case special characters.
vecUpperOutThe vector with lower case normal characters.
TECOMMONEXPORT void te::common::GetAccentuatedUpperVector ( std::vector< std::string > &  vecUpperIn,
std::vector< std::string > &  vecUpperOut 
)

It build two string vectors with special upper case characters and the his respective normal characters.

Parameters
vecUpperInThe vector with upper case special characters.
vecUpperOutThe vector with upper case normal characters.
unsigned char te::common::GetDecimalFromHexLCase ( char  hexValue)
inline

It returns the decimal value in a char from a given hex value (for example: 'a' => 10, '8' => 8).

Parameters
hexValueThe hex value we want to extract the decimal value.
Returns
The decimal value in a char from a given hex value (for example: 'a' => 10, '8' => 8).
Note
This version is lower case sensitive, i. e., 'a' will return 10 and 'A' will return a wrong value.

Definition at line 185 of file HexUtils.h.

unsigned char te::common::GetDecimalFromHexNotCS ( unsigned char  hexValue)
inline

It returns the decimal value in a char from a given hex value (for example: 'A' => 10, '8' => 8).

Parameters
hexValueThe hex value we want to extract the decimal value.
Returns
The decimal value in a char from a given hex value (for example: 'A' => 10, '8' => 8).
Note
This version is not case sensitive, i. e., 'A' and 'a' will return 10.

Definition at line 49 of file HexUtils.h.

Referenced by te::color::RGBAColor::setColor().

unsigned char te::common::GetDecimalFromHexUCase ( char  hexValue)
inline

It returns the decimal value in a char from a given hex value (for example: 'A' => 10, '8' => 8).

Parameters
hexValueThe hex value we want to extract the decimal value.
Returns
The decimal value in a char from a given hex value (for example: 'A' => 10, '8' => 8).
Note
This version is upper case sensitive, i. e., 'A' will return 10 and 'a' will return a wrong value.

Definition at line 119 of file HexUtils.h.

TECOMMONEXPORT void te::common::GetDecompostedLDPathEnvVar ( std::vector< std::string > &  paths)

Returns the system LD_LIBRARY_PATH enviroment variable, decomposed into directory names, or an empty vector if no values were found.

Parameters
pathsThe decomposed PATH.
TECOMMONEXPORT void te::common::GetDecompostedPathEnvVar ( std::vector< std::string > &  paths)

Returns the system PATH enviroment variable, decomposed into directory names, or an empty vector if no values were found.

Parameters
pathsThe decomposed PATH.
template<class T >
bool te::common::GetDeterminant ( const boost::numeric::ublas::matrix< T > &  inputMatrix,
T &  determinant 
)

Get the Matrix determinant value.

Parameters
inputMatrixInput matrix.
Returns
true if ok, false on errors.

Definition at line 57 of file MatrixUtils.h.

References te::gm::A.

TECOMMONEXPORT void te::common::GetEspecialCharsFixVector ( std::vector< std::string > &  especialIn,
std::vector< std::string > &  especialOut 
)

It build two string vectors with special characters and the his respective normal characters.

Parameters
especialInThe vector with special characters.
especialOutThe vector with normal characters.
TECOMMONEXPORT unsigned long int te::common::GetFreePhysicalMemory ( )

Returns the amount of free physical memory (bytes).

Returns
The amount of free physical memory (bytes).
template<class T >
bool te::common::GetInverseMatrix ( const boost::numeric::ublas::matrix< T > &  inputMatrix,
boost::numeric::ublas::matrix< T > &  outputMatrix 
)

Matrix inversion.

Parameters
inputMatrixInput matrix.
outputMatrixOutput matrix.
Returns
true if ok, false on errors.

Definition at line 104 of file MatrixUtils.h.

References te::gm::A.

Referenced by GetPseudoInverseMatrix().

TECOMMONEXPORT unsigned int te::common::GetPhysProcNumber ( )

Returns the number of physical processors.

Returns
The number of physical processors.
template<class K , class V >
V** te::common::GetPPValue ( std::map< K, V * > &  m,
const K &  k 
)
inline

It finds for a given key in the map and returns a pointer if something is found or NULL otherwise.

Parameters
mThe map of pointers where the key will be searched.
kThe key.
Returns
A pointer if something is found or NULL otherwise.

Definition at line 217 of file STLUtils.h.

template<class T >
bool te::common::GetPseudoInverseMatrix ( const boost::numeric::ublas::matrix< T > &  inputMatrix,
boost::numeric::ublas::matrix< T > &  outputMatrix 
)

Pseudo matrix inversion.

Parameters
inputMatrixInput matrix.
outputMatrixOutput matrix.
Returns
true if ok, false on errors.
Note
PinvX = Inv( Xt * X ) * Xt, where Inv=Inverse and Xt is the transposed matrix of X.
A* = inv(trasnp(A) * A) * transp(A) (i>j)
A* = transp(A) * inv(A * trasnp(A)) (i<j)

Definition at line 152 of file MatrixUtils.h.

References GetInverseMatrix().

template<class K , class V >
V* te::common::GetPValue ( const std::map< K, V * > &  m,
const K &  k 
)
inline

It finds for a given key in the map and returns a pointer if something is found or NULL otherwise.

Parameters
mThe map of pointers where the key will be searched.
kThe key.
Returns
A pointer if something is found or NULL otherwise.

Definition at line 179 of file STLUtils.h.

template<class K , class C >
K* te::common::GetPValue ( const std::set< K *, C > &  m,
K *  k 
)
inline

It finds for a given key in the map and returns a pointer if something is found or NULL otherwise.

Parameters
mThe map of pointers where the key will be searched.
kThe key.
Returns
A pointer if something is found or NULL otherwise.

Definition at line 197 of file STLUtils.h.

TECOMMONEXPORT unsigned long int te::common::GetTotalPhysicalMemory ( )

Returns the amount of total physical memory (bytes).

Returns
The amount of total physical memory (bytes).

Referenced by te::rp::Matrix< TemplateElementType >::reset().

TECOMMONEXPORT unsigned long int te::common::GetTotalVirtualMemory ( )

Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physical + swapped).

Returns
The amount of total virtual memory (bytes).

Referenced by te::rp::Matrix< TemplateElementType >::reset().

TECOMMONEXPORT unsigned long int te::common::GetUsedVirtualMemory ( )

Returns the amount of used virtual memory (bytes) for the current process (physical + swapped).

Returns
The amount of free virtual memory (bytes).

Referenced by te::rp::Matrix< TemplateElementType >::reset().

char* te::common::Hex2Binary ( const char *  hex)
inline

It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary format.

This function can be used, for example, to decode the returned geometry from PostGIS.

Parameters
hexA NULL-terminated string of hexadecimal characters.
Returns
An array of binary characters in binary format.
Note
The size of the returned array is the half of the input array.
The caller of this function will take the ownership of the returned pointer, so it must delete it. Use delete [] returned_pointer.

Definition at line 469 of file HexUtils.h.

void te::common::Hex2Binary ( const char *  hex,
std::size_t  hSize,
char *  outBuff 
)
inline

It converts each pair of hex characters from an input string of hex characters into a binary format.

This version can be used for those who wants to pre-allocate the memory where the parsed version will be output.

Parameters
hexA string of hexadecimal characters.
hSizeThe number of bytes in the input string. Remember that it must be a multiple of 2.
outBuffA pointer to a pre-allocated buffer where to output the binary version. It must have at least hSize/2 bytes.
Note
The size of the input buffer (outBuff) must be at least the half of the input array.
The outBuff can be the same as the input buffer; in this case the input will be overwritten.

Definition at line 515 of file HexUtils.h.

char* te::common::Hex2Binary2 ( const char *  hex)
inline

It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary format.

This function can be used, for example, to decode the returned geometry from PostGIS.

Parameters
hexA NULL-terminated string of hexadecimal characters.
Returns
An array of binary characters in binary format.
Note
The size of the returned array is the half of the input array.
The caller of this function will take the ownership of the returned pointer, so it must delete it. Use delete [] returned_pointer.
Warning
In our tests, this version was slower than the other equivalent.

Definition at line 557 of file HexUtils.h.

References Hex2Char2().

void te::common::Hex2Binary2 ( const char *  hex,
std::size_t  hSize,
char *  outBuff 
)
inline

It converts each pair of hex characters from an input string of hex characters into a binary format.

This version can be used for those who wants to pre-allocate the memory where the parsed version will be output.

Parameters
hexA string of hexadecimal characters.
hSizeThe number of bytes in the input string. Remember that it must be a multiple of 2.
outBuffA pointer to a pre-allocated buffer where to output the binary version. It must have at least hSize/2 bytes.
Note
The size of the input buffer (outBuff) must be at least the half of the input array.

Definition at line 583 of file HexUtils.h.

References Hex2Char2().

char te::common::Hex2Char ( const char *  hex)
inline

It converts the character from a hex representation to a byte.

Parameters
hAt least a pair of bytes to be transformed from a hex representation.
Note
It is used by Hex2Binary function.
Returns
A byte representation from a two bytes hex representation.

Definition at line 270 of file HexUtils.h.

unsigned char te::common::Hex2Char2 ( const char *  hex)
inline

It converts the character from a hex representation to a byte.

Parameters
hAt least a pair of bytes to be transformed from a hex representation.
Note
It is used by Hex2Binary function.
Returns
A byte representation from a two bytes hex representation.
Warning
In our tests, this version was slower than the other.

Definition at line 301 of file HexUtils.h.

Referenced by Hex2Binary2().

void te::common::intrusive_ptr_add_ref ( Counted p)
inline

Definition at line 69 of file Counted.h.

References te::common::Counted::attach().

void te::common::intrusive_ptr_release ( Counted p)
inline

Definition at line 74 of file Counted.h.

References te::common::Counted::detach().

std::ostream& te::common::operator<< ( const Exception e,
std::ostream &  o 
)

It serializes the exception and sends it to the output stream.

Parameters
eAn exception object.
oAn output stream.
Returns
The output stream.
TECOMMONEXPORT std::string te::common::ReplaceSpecialChars ( const std::string &  str,
bool &  changed 
)

It replace special characters of a string.

Parameters
strThe string that will be verify.
changedBoolean that records whether there was a change.
template<class T >
void te::common::Swap2Bytes ( T &  v)
inline

It swaps two bytes in local.

Parameters
vThe value we want to swap.
Note
Requirements: The type T must have a sizeof(T) == 2.

Definition at line 51 of file ByteSwapUtils.h.

Referenced by SwapBytes().

void te::common::Swap2Bytes ( char *  v)
inline

It swaps an array of two bytes in local.

Parameters
vThe value we want to swap.

Definition at line 68 of file ByteSwapUtils.h.

template<class T >
void te::common::Swap4Bytes ( T &  v)
inline

It swaps four bytes in local.

Parameters
vThe value we want to swap.
Note
Requirements: The type T must have a sizeof(T) == 4.

Definition at line 82 of file ByteSwapUtils.h.

Referenced by SwapBytes().

void te::common::Swap4Bytes ( char *  v)
inline

It swaps an array of four bytes in local.

Parameters
vThe value we want to swap.

Definition at line 101 of file ByteSwapUtils.h.

void te::common::Swap8Bytes ( char *  v)
inline

It swaps an array of eight bytes in local.

Parameters
vThe value we want to swap.

Definition at line 139 of file ByteSwapUtils.h.

template<class T >
void te::common::SwapBytes ( T &  v)
inline

It swaps the bytes in local.

Parameters
vThe value we want to swap.
Note
Generic version: swap n-bytes.

Definition at line 119 of file ByteSwapUtils.h.

template<>
void te::common::SwapBytes ( boost::int16_t &  v)
inline

It swaps 2 bytes in local.

Parameters
vThe value we want to swap.

Definition at line 163 of file ByteSwapUtils.h.

References Swap2Bytes().

template<>
void te::common::SwapBytes ( boost::int32_t &  v)
inline

It swaps four bytes in local.

Parameters
vThe value we want to swap.

Definition at line 173 of file ByteSwapUtils.h.

References Swap4Bytes().

template<>
void te::common::SwapBytes ( boost::uint32_t &  v)
inline

It swaps four bytes in local.

Parameters
vThe value we want to swap.

Definition at line 183 of file ByteSwapUtils.h.

References Swap4Bytes().

template<>
void te::common::SwapBytes ( float &  v)
inline

It swaps four bytes in local.

Parameters
vThe value we want to swap.

Definition at line 193 of file ByteSwapUtils.h.

References Swap4Bytes().

void te::common::Tokenize ( const std::string &  str,
std::vector< std::string > &  tokens,
const std::string &  delimiters = " " 
)
inline

It tokenizes a given string with a delimiter of your own choice.

Parameters
strThe string to be tokenize.
tokensThe output vector with the tokens.
delimitersThe character delimiters.

Definition at line 219 of file StringUtils.h.

Referenced by ExtractKVP().