Graphite  Version 3
An experimental 3D geometry processing program
text_utils.h File Reference

Utilities to manipulate text files. More...

#include <OGF/basic/common/common.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>

Go to the source code of this file.

Classes

class  OGF::TextUtils::Environment
 Manages a set of name-value or name-values pairs, used to manipulate text files. More...
 

Namespaces

 OGF
 Global Graphite namespace.
 

Functions

std::ostream & OGF::TextUtils::operator<< (std::ostream &out, const Environment &env)
 Outputs the contents of an Enviroment to a stream. More...
 
void OGF::TextUtils::read_environment_file (const std::string &file_name, Environment &environment)
 Reads an Environment from a file. More...
 
void OGF::TextUtils::find_and_replace (std::istream &in, std::ostream &out, const Environment &env)
 Performs variables substitution in a stream. More...
 
void OGF::TextUtils::concatenate (std::istream &in, std::ostream &out)
 Copies the content of an input stream to an output stream. More...
 
bool OGF::TextUtils::file_contains_string (const std::string &file_name, const std::string &x)
 Tests whether a file contains an occurence of a string. More...
 

Detailed Description

Utilities to manipulate text files.

Definition in file text_utils.h.

Function Documentation

◆ concatenate()

void OGF::TextUtils::concatenate ( std::istream &  in,
std::ostream &  out 
)

Copies the content of an input stream to an output stream.

Parameters
[in]inthe input stream
[out]outthe output stream

◆ file_contains_string()

bool OGF::TextUtils::file_contains_string ( const std::string &  file_name,
const std::string &  x 
)

Tests whether a file contains an occurence of a string.

Parameters
file_namename of the file
xthe string
Return values
trueif file file_name contains at least an occurence of string x.
falseotherwise

◆ find_and_replace()

void OGF::TextUtils::find_and_replace ( std::istream &  in,
std::ostream &  out,
const Environment env 
)

Performs variables substitution in a stream.

Whenever varname% is encountered in the input stream, if a variable named "varname" exists in the environment, then the string is replaced with its contents, else it is kept as is.

Parameters
[in]inthe input stream
[out]outthe output stream
[in]enva const reference to the environment

◆ operator<<()

std::ostream& OGF::TextUtils::operator<< ( std::ostream &  out,
const Environment env 
)
inline

Outputs the contents of an Enviroment to a stream.

Parameters
[in,out]outthe stream where the contents of the Environment should be output
[in]enva const reference to the Environment
Returns
the new state of the stream

Definition at line 165 of file text_utils.h.

◆ read_environment_file()

void OGF::TextUtils::read_environment_file ( const std::string &  file_name,
Environment environment 
)

Reads an Environment from a file.

Parameters
[in]file_namename of the file
[out]environmentwhere to read the file