PLearn 0.1
|
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <plearn/base/lexical_cast.h>
Go to the source code of this file.
Namespaces | |
namespace | PLearn |
< for swap | |
Defines | |
#define | slash "/" |
#define | slash_char '/' |
Functions | |
string | PLearn::left (const string &s, size_t width, char padding=' ') |
aligns the given string in a cell having the given width | |
string | PLearn::right (const string &s, size_t width, char padding) |
string | PLearn::center (const string &s, size_t width, char padding) |
string | PLearn::removeblanks (const string &s) |
removes starting and ending blanks '\n','\r',' ','\t' | |
string | PLearn::removeallblanks (const string &s) |
removes all blanks '\n','\r',' ','\t' | |
string | PLearn::removenewline (const string &s) |
removes any trailing '\n' and/or '\r' | |
string | PLearn::removequotes (const string &s) |
remove exactly one pair of matching leading and trailing '\'' and '"'; if there is none, return the string unmodified | |
string | PLearn::quote_string (const string &s) |
Quote the provided string 's'. | |
string | PLearn::lowerstring (const string &s) |
convert a string to all lowercase | |
string | PLearn::upperstring (const string &s) |
convert a string to all uppercase | |
string | PLearn::pgetline (istream &in=cin) |
returns the next line read from the stream, after removing any trailing '\r' and/or '\n' | |
bool | PLearn::isBlank (const string &s) |
returns true if s is a blank line (containing only space, tab, until end of line or a # comment-character is reached | |
bool | PLearn::isParagraphBlank (const string &s) |
returns true if s is a blank paragraph (containing only space, tab, until end of **string**) | |
void | PLearn::parseBaseAndParameters (const string &s, string &base, map< string, string > ¶ms, map< string, string > *added=0, map< string, string > *backup=0, const string &delimiter="::") |
From a string s = "base_string::arg1=val1::arg2=val2::arg3=val3", fill 'base' with 'base_string', and add to 'params' mappings argX -> valX. | |
string | PLearn::space_to_underscore (string str) |
replaces all characters <= ' ' (i.e. newline, tab, space, etc...) by '_' | |
string | PLearn::underscore_to_space (string str) |
replaces all underscores by a single space character | |
string | PLearn::backslash_to_slash (string str) |
replaces all backslashes with slash | |
bool | PLearn::string_begins_with (const string &s, const string &beginning) |
Return true iff string 's' begins with string 'beginning'. | |
bool | PLearn::string_ends_with (const string &s, const string &end) |
Return true iff string 's' ends with string 'end'. | |
int | PLearn::search_replace (string &text, const string &searchstr, const string &replacestr) |
replaces all occurences of searchstr in the text by replacestr returns the number of matches that got replaced | |
vector< string > | PLearn::split_from_string (const string &s, const string &delimiter) |
Split a string along occurences of the substring 'delimiter'. | |
vector< string > | PLearn::split (const string &s, char delimiter) |
splits a string along occurences of the delimiters. | |
vector< string > | PLearn::split (const string &s, const string &delimiters, bool keep_delimiters) |
vector< string > | PLearn::split_all (const string &s, const string &delimiters) |
vector< string > | PLearn::split_quoted_delimiter (const string &s, char delimiter, const string &double_quote) |
vector< string > | PLearn::split_quoted_delimiter (const string &s, char delimiter, char double_quote) |
vector< string > | PLearn::split_quoted_delimiter (const string &s, const string &delimiters, const string &double_quote) |
void | PLearn::split_on_first (const string &s, const string &delimiters, string &left, string &right) |
pair< string, string > | PLearn::split_on_first (const string &s, const string &delimiters) |
string | PLearn::join (const vector< string > &s, const string &separator=" ") |
makes a single string from a vector of strings | |
vector< string > | PLearn::addprepostfix (const string &prefix, const vector< string > &names, const string &postfix) |
returns the list of names, but with a prepended prefix and an appended postfix | |
vector< string > | PLearn::addprefix (const string &prefix, const vector< string > &names) |
returns the list of names, but with a prepended prefix | |
vector< string > | PLearn::addpostfix (const vector< string > &names, const string &postfix) |
returns the list of names, but with an appended postfix | |
string | PLearn::addprepostfix (const string &prefix, const string &text, const string &postfix) |
Returns a string with the prefix prepended and the postfix appended to each *line* of the text string. | |
string | PLearn::addprefix (const string &prefix, const string &text) |
Returns a string with the prefix prepended to each *line* of the text string. | |
string | PLearn::addpostfix (const string &text, const string &postfix) |
Returns a string with the postfix appended to each *line* of the text string. | |
vector< string > | PLearn::stringvector (int argc, char **argv) |
makes a C++ style vector of strings from a C style vectr of strings Note: this may be useful in conjunction with get_option. | |
string | PLearn::get_option (const vector< string > &command_line, const string &option, const string &default_value) |
bool | PLearn::find (const vector< string > &command_line, const string &option) |
int | PLearn::findpos (const vector< string > &v, string element) |
return index of element in v, or -1 if not found | |
vector< string > | PLearn::remove (const vector< string > &v, string element) |
return vector with all instances of element removed | |
int | PLearn::universal_compare (const string &x, const string &y) |
"Universal compare". | |
string | PLearn::extract_filename (const string &filepath) |
** File path manipulation functions ** | |
string | PLearn::extract_directory (const string &filepath) |
Returns everything before the last '/' including the '/' (if there's no '/' it returns "./") | |
string | PLearn::extract_extension (const string &filepath) |
Returns everything after the last '. | |
string | PLearn::remove_extension (const string &filename) |
Return the filename withoug the extension (i.e. removing the last. | |
string | PLearn::remove_trailing_slash (const string &path) |
removes any trailing '/' from the path | |
string | PLearn::append_slash (const string &path) |
appends a trailing slash to path if there isn't already one | |
string | PLearn::extract_filename_without_extension (const string &filepath) |
Returns everything before the last '.' of the filename, excluding the '.' (if there's no '.' in the filename it returns the whole filename) | |
void | PLearn::remove_comments (string &text, const string &commentstart="#") |
In a multiline text, removes everything starting at commentstart pattern until the end of line. | |
vector< string > | PLearn::getNonBlankLines (const string &in) |
Returns a vector of string containing only non-empty lines, as you guessed it. | |
string * | PLearn::data_filename_2_filenames (const string &filename, int &nb_files) |
take a filename containing the name of a file per line, and return theses names as a string* of length nb_files | |
ostream & | PLearn::operator<< (ostream &out, const vector< string > &vs) |
formatted printing of vector<string> prints strings separated by a ", " | |
template<class U , class V > | |
ostream & | PLearn::operator<< (ostream &out, const pair< U, V > &p) |
Formatted printing of a pair<U,V> as U:V. |
Definition in file stringutils.h.
#define slash "/" |
Definition at line 74 of file stringutils.h.
Referenced by PLearn::append_slash(), PLearn::VVMatrix::createPreproVMat(), PLearn::extract_directory(), PLearn::extract_filename(), PLearn::VVMatrix::generateVMatIndex(), PLearn::VVMatrix::getPrecomputedDataName(), PLearn::PDateTime::info(), PLearn::PDate::info(), PLearn::VVMatrix::isPrecomputedAndUpToDate(), PLearn::PTester::perform(), PLearn::Experiment::run(), and PLearn::SimpleDB< KeyType, QueryResult >::SimpleDB().
#define slash_char '/' |
Definition at line 75 of file stringutils.h.
Referenced by PLearn::append_slash(), PLearn::VVMatrix::createPreproVMat(), PLearn::VVMatrix::extractSourceMatrix(), PLearn::VVMatrix::getDateOfVMat(), and PLearn::remove_trailing_slash().