Rosetta 3.3
Namespaces | Functions
src/utility/string_util.hh File Reference

Some std::string helper functions. More...

#include <utility/vector1.hh>
#include <utility/stream_util.hh>
#include <boost/algorithm/string/erase.hpp>
#include <list>
#include <sstream>
#include <string>
#include <vector>

Namespaces

namespace  utility
 

unresizable vector whose size is known at compile time, which may be allocated on the stack, and which indexes from 1.


Functions

void utility::ReadFromFileOrDie (const std::string &filename, std::string *contents)
 Reads the contents of <filename> into <contents>, preserving newline characters. Aborts if an error is encoutered.
std::vector< std::string > utility::split (const std::string &s)
 split given std::string using ' ' symbol.
std::string utility::join (utility::vector1< std::string > const &s, std::string const &connector)
 combine strings with anything
std::string utility::join (std::vector< std::string > const &s, std::string const &connector)
 combine strings with anything
std::string utility::join (std::string const &string_w_spaces, std::string const &connector)
 join space separations in a string with a connector such as '_'
std::list< std::string > utility::split_to_list (const std::string &s)
std::vector< std::string > utility::string_split (std::string const &in, char splitchar)
float utility::string2float (std::string st)
int utility::string2int (std::string st)
void utility::string2uint (const std::string &x, unsigned int *y)
bool utility::startswith (std::string const &haystack, std::string const &needle)
 True iff haystack starts with needle.
bool utility::endswith (std::string const &haystack, std::string const &needle)
 True iff haystack ends with needle.
void utility::slurp (std::istream &in, std::string &out)
void utility::trim (std::string &s, const std::string &drop)
std::string utility::trim (std::string const &s, std::string const &drop=" ")
 create a new string that drops all the unwanted substrings of the original string.
bool utility::trimmed_compare (std::string const &s1, std::string const &s2)
void utility::add_spaces_left_align (std::string &st, std::size_t const newlen)
 adds spaces to a left aligned string until a given length is reached
void utility::add_spaces_right_align (std::string &st, std::size_t const newlen)
 adds spaces to a right aligned string until a given length is reached
bool utility::is_string_numeric (std::string const &input)
std::string utility::file_contents (std::string const &file_name)
 Read the entire contents of a file into a string. All end-of-line characters are replaced by "\n". Throws a utility::excn::EXCN_msg_exception if the file cannot be opened.
std::string utility::file_basename (const std::string &full_path)
std::string utility::filename (const std::string &path)
std::string utility::pathname (const std::string &path)
std::string utility::replace_environment_variables (std::string input)
 find all environment variables with the form ${VARIABLE} and replace with the contents of that environment variable. if the environment variable does not exist, return string::npos
bool utility::same_ignoring_spaces (std::string const &s1, std::string const &s2)
 Compares two strings, ignoring spaces. Useful for comparing atom name strings which have pdb-alignment built into them. Slightly dangerous if you consider the fact that atom names in the PDB are different for different indentation rules: ' CA ' is c-alpha. 'CA ' is calcium.
void utility::replace_in (std::string &s, const char from, const char *to)
template<class T >
std::string utility::to_string (const T &t)
template<class T >
T const utility::from_string (std::string const &s, T)

Detailed Description

Some std::string helper functions.

Author:
Sergey Lyskov
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines