include/EDoc/utils.h File Reference


Detailed Description

This file provides some useful utilities that make using the STL containers a little simpler throughout the EDoc library.

Definition in file utils.h.

#include <string>
#include <vector>
#include <list>

Go to the source code of this file.

Namespaces

namespace  EDoc

Defines

#define EDOC_FOREACH(ContainerType, IteratorName, ContainerObject)
 A macro that can be used to loop for each element of a stl container.
#define EDOC_FOREACH_CONST(ContainerType, IteratorName, ContainerObject)
 A macro that can be used to loop for each element of a const stl container.
#define EDOC_UNUSED(Param)
 A macro for marking function parameters as unused.

Functions

std::string EDoc::GetFileExtension (std::string name)
 Returns the extension of the given file name.
std::pair< std::string, std::string > EDoc::SplitFileExtension (std::string name)
 Returns both the extension and the base name of the given file name.
std::string EDoc::CreateTempFilename (std::string base="EDoctmp")
 Creates a new temporary file.
template<typename T>
bool EDoc::ListContains (const T &cont, typename T::const_reference item)
 Returns true if the given STL container contains an item.
template<typename T>
T::iterator EDoc::VecFind (T &cont, typename T::const_reference item)
 Returns an iterator for the item that matches.
template<typename T>
void EDoc::PushBackUnique (T &cont, typename T::const_reference item)
 Pushes item to the back of the STL container if it does not already exist in the container.
template<typename T>
void EDoc::AppendUnique (T &cont1, const T &cont2)
 Appends items from one STL container to the back of a seccond STL container if the items are not already in the second container.
template<typename T>
T & EDoc::Append (T &cont1, const T &cont2)
 Appends contents of STL container cont2 to the end of cont1.
template<typename T>
void EDoc::Erase (T &cont)
 Erases all items from the given container.
std::vector< std::string > EDoc::Split (std::string str, char sep= ' ')
 Splits the given string into a vector of strings using sep as a seperator.
int EDoc::RunProgram (std::string command_in)
 Executes the given command and returns its exit status.
int EDoc::RunProgramRedirect (std::string &out, std::string &err, std::string command)
 Executes the given command and returns its exit status.
void EDoc::MkDirs (std::string dir)
 Creates a directory structure if it does not exist.
void EDoc::CopyFile (std::string source, std::string destination)
 Copies source file to destination file.
bool EDoc::FileExists (std::string filename)
 Returns true if the specified filename exists as a file.
std::string EDoc::TrimWhitespace (const std::string &str)
 Trims all whitespace from the beginning and end of the string.
std::string EDoc::MakeTemporaryFile (std::string prefix="", std::string suffix="", std::string directory="/tmp")
 Creates a temporary file on the system using the given template.

Variables

static char const *const EDoc::INDENT_STR = "\t"
 used in a number of places within the Print() functions to provide indentation.


Define Documentation

#define EDOC_FOREACH ( ContainerType,
IteratorName,
ContainerObject   ) 

Value:

for(ContainerType::iterator IteratorName = (ContainerObject).begin(); \
      IteratorName != (ContainerObject).end(); ++IteratorName)
A macro that can be used to loop for each element of a stl container.

May be used like:

 typedef std::map<int, Blah> BlahMap;
 BlahMap mymap;
 ...
 EDOC_FOREACH(BlahMap, it, mymap)
 {
    ... do stuff with it->second ...
 }

Important to note is that the typedef above is necessary in the EDOC_FOREACH otherwise the macro will assume the comma in the map type is a sperator for the macro. It is not necessary however for use with std::list and std::vector

Definition at line 48 of file utils.h.

Referenced by EDoc::AddExceptions(), EDoc::AddPException(), EDoc::AddRethrow(), EDoc::Dictionary::CalculateCallComplexity(), EDoc::CalculateTotalFunctionCalls(), EDoc::ManagedObject::EraseAll(), EDoc::Dictionary::EraseAll(), EDoc::Dictionary::ErasePropogatingExceptions(), EDoc::Dictionary::ExpandCallGraph(), EDoc::CodeBlock::ExpandCallGraph(), EDoc::CodeBlock::GetAllCodeBlocks(), EDoc::SpecificManagedObject< EDoc::Type >::GetItems(), EDoc::Function::GetPropogatingExceptions(), EDoc::Dictionary::HandleCircularCallgraph(), EDoc::Type::Merge(), EDoc::Dictionary::PostProcessExceptions(), EDoc::Dictionary::ProcessCodeBlock(), EDoc::Dictionary::ProcessTryBlock(), EDoc::Dictionary::Read(), EDoc::Persistence::ReadExtract(), EDoc::Persistence::ReadOpen(), EDoc::Type::ReplaceReferences(), EDoc::ManagedObject::ReplaceReferences(), EDoc::Function::ReplaceReferences(), EDoc::CodeBlock::ReplaceReferences(), EDoc::Dictionary::UpdateFunctionAddressLists(), EDoc::VecFind(), and EDoc::Persistence::WriteOpen().

#define EDOC_FOREACH_CONST ( ContainerType,
IteratorName,
ContainerObject   ) 

Value:

for(ContainerType::const_iterator IteratorName = (ContainerObject).begin(); \
      IteratorName != (ContainerObject).end(); ++IteratorName)
A macro that can be used to loop for each element of a const stl container.

Definition at line 56 of file utils.h.

Referenced by EDoc::AppendUnique(), EDoc::ManagedFile::GetFileNameRep(), EDoc::Function::GetRefInFilesString(), EDoc::Function::GetVisiblePropExceptions(), EDoc::ListContains(), EDoc::Type::Merge(), EDoc::Function::Merge(), EDoc::Dictionary::Merge(), EDoc::Type::operator=(), EDoc::Function::operator=(), EDoc::CodeBlock::operator=(), EDoc::PropogatingException::Print(), EDoc::ManagedObject::Print(), EDoc::Function::Print(), EDoc::CodeBlock::Print(), EDoc::Dictionary::ProcessFunction(), EDoc::PropogatingException::ReplaceReferences(), EDoc::Dictionary::ReplaceReferences(), EDoc::Type::Validate(), EDoc::PropogatingException::Validate(), EDoc::ManagedObject::Validate(), EDoc::Function::Validate(), EDoc::CodeBlock::Validate(), EDoc::Type::Write(), EDoc::Function::Write(), EDoc::Dictionary::Write(), and EDoc::CodeBlock::Write().

#define EDOC_UNUSED ( Param   ) 

A macro for marking function parameters as unused.

This is used to eliminate the GCC warning for unused parameters when compiled with that option.

Definition at line 66 of file utils.h.


Generated on Tue Jan 20 18:26:08 2009 for EDoc-0.2.1 by  doxygen 1.5.1