strformat.h File Reference

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <set>
#include <cstring>

Go to the source code of this file.

Functions

int wc (const string &str)
bool isnumber (const string &str)
bool isnumber (const string &str, const string dc)
bool isupper (const string &str)
void upper (const char lo[], char *up)
string getLower (const string &str)
void strTolower (string &str)
void strTolower (const string &str1, string &str2)
void strToupper (string &str)
string str2upper (const string &str)
string lc (const string &str)
int cmp_nocase (const string &s1, const string &s2)
bool intersect (vector< string > &s1, vector< string > &s2)
string delall (const string &str, const char c)
string delall (const string &str, const string &c)
string deleteChr (const string &str, char c)
string tr (const string &str, char i, char o)
void trim (string &str)
void trimLeadingSpace (string &str)
void dlc (char a[])
void rmtsp (char a[])
void rmsp (char a[])
void singleSpace (string &str)
void rmsp (const char a[], char b[])
void rmdquote (char a[])
void rpldquote (char a[], const char r)
void newline (istream &ins)
int getNumber (char *&ptr)
int getInt (const string &str)
vector< int > getAllInt (const string &str)
int itoa (unsigned int n, char a[])
string itos (int n)
template<class T>
string toString (const T &val)
template<class T>
string anyToString (const T &val)
vector< int > extractInt (const string &str)
int substr (const char ln[], int s, char sub[])
int substr (const char ln[], int s, int f, char sub[])
void firstwd (const char ln[], char sub[], char term=' ')
string firstword (const string &str, const string &delim=" ,.()")
void lastwd (const char ln[], char wd[], char sep= ' ')
string lastword (const string &str, const string &delim=" ,.()")
string acronym (const string &str, int n=1)
string acronymWithDigit (const string &str, int n=1)
string acronymWithTag (const string &str, int n=1)
void append (char *&head, const char *tail, int &len, int &maxlen, int incr)
void append (char *&head, const char *tail, int &len, int &maxlen)
vector< string > split (const string &str, const char sep='\t')
vector< string > split (const string &str, const char sep[])
vector< string > splitOneOf (const string &str, const string &delims=",. \t")
vector< string > dissect (const string &str, const string &delims=",. \t")
set< string > digest2set (const string &str, const string &delims=",. \t")
pair< string, string > breakString (const string &str, const string &sep)
void writeSequence (const string &seq, ostream &ous, const int width=70)
int isName (char *n)
bool codonIsStop (const string &codon)
bool subseqIsStop (const string &seq, int i)


Function Documentation

string acronym ( const string &  str,
int  n = 1 
)

acronym based on, at most, n letters of each word

string acronymWithDigit ( const string &  str,
int  n = 1 
)

string acronymWithTag ( const string &  str,
int  n = 1 
)

References dissect(), length, and substr().

Referenced by main().

template<class T>
string anyToString ( const T val  )  [inline]

Make a long name so it will be different I tried to use name space but I have a hard time to compile and link!

Referenced by ESTAssembly::ESTAssembly(), ESTModel::ESTModel(), ESTAssembly::setName(), and ESTAssembly::setTitle().

void append ( char *&  head,
const char *  tail,
int &  len,
int &  maxlen 
)

void append ( char *&  head,
const char *  tail,
int &  len,
int &  maxlen,
int  incr 
)

pair<string,string> breakString ( const string &  str,
const string &  sep 
)

break a string into two parts according the the separator sep

Returns:
a pair of strings. if sep is not found inside str, then I will return two empty strings as a pair.

Referenced by Gmapath::Gmapath(), and readandstoreGmap().

int cmp_nocase ( const string &  s1,
const string &  s2 
)

compare to string and ignoring case

Referenced by Aceobj::at(), find(), and feature::isGoodGeneSymbol().

bool codonIsStop ( const string &  codon  ) 

References strToupper().

string delall ( const string &  str,
const string &  c 
)

delete all string c from str

string delall ( const string &  str,
const char  c 
)

delete all character from a string

See also:
also deleteChr
if str is very long, this operation will be slow

Referenced by main(), and feature::makeGeneSymbol().

string deleteChr ( const string &  str,
char  c 
)

alias for delall

Referenced by Gmapath::Gmapath().

set<string> digest2set ( const string &  str,
const string &  delims = ",. \t" 
)

Referenced by deflineBetter().

vector<string> dissect ( const string &  str,
const string &  delims = ",. \t" 
)

anything in delims will be discarded only the none-delims char are left, and packed in the vector more or less digestions same as split, but will use any of the characters as separators leading and trailing separators are discarded

Referenced by acedbinfo::acedbinfo(), feature::acronymWithAllDigits(), acronymWithTag(), dumpFromModel(), getinslen(), dbinfo::init(), Journal::Journal(), main(), feature::makeGeneSymbol(), Refreader::newRef(), Reference::parseJournal(), parseOneFile(), pgdbinfo::pgdbinfo(), gbseq::read(), Matrix::read(), readconf(), and readUnwantedTaxid().

void dlc ( char  a[]  ) 

delete last character from an C-string a

Referenced by head::getHead().

vector<int> extractInt ( const string &  str  ) 

Referenced by main(), and locseg::parse().

void firstwd ( const char  ln[],
char  sub[],
char  term = ' ' 
)

Referenced by head::loadSeqInfo().

string firstword ( const string &  str,
const string &  delim = " ,.()" 
)

vector<int> getAllInt ( const string &  str  ) 

extract all integer numbers in the string

Referenced by Gmapalnseg::Gmapalnseg(), Gmapath::Gmapath(), and readandstoreGmap().

int getInt ( const string &  str  ) 

return the first integer number in the string

Referenced by readandstoreGmap().

string getLower ( const string &  str  ) 

int getNumber ( char *&  ptr  ) 

Conversion to other types such as integer, double

Referenced by Date::gbstr(), and feature::readloc().

bool intersect ( vector< string > &  s1,
vector< string > &  s2 
)

int isName ( char *  n  ) 

References isupper().

bool isnumber ( const string &  str,
const string  dc 
)

bool isnumber ( const string &  str  ) 

bool isupper ( const string &  str  ) 

int itoa ( unsigned int  n,
char  a[] 
)

string itos ( int  n  ) 

void lastwd ( const char  ln[],
char  wd[],
char  sep = ' ' 
)

string lastword ( const string &  str,
const string &  delim = " ,.()" 
)

string lc ( const string &  str  ) 

void newline ( istream ins  ) 

This function is not so good and should be removed in the future

void rmdquote ( char  a[]  ) 

Referenced by head::getHead().

void rmsp ( const char  a[],
char  b[] 
)

remove all spaces

void rmsp ( char  a[]  ) 

References aa, and rmtsp().

void rmtsp ( char  a[]  ) 

Referenced by rmsp().

void rpldquote ( char  a[],
const char  r 
)

Referenced by head::getHead().

void singleSpace ( string &  str  ) 

vector<string> split ( const string &  str,
const char  sep[] 
)

separate str into an array of strings using sep as delimiter sep is a string Same behavior as the char version seprator. Anything in betwee sep will be an array element. For example, if sep is ?? then ??tabc?? will have three elements, the first and the third are empty strings

Parameters:
sep is the delimiter that is a c_string as compare to the single character version.

vector<string> split ( const string &  str,
const char  sep = '\t' 
)

A version of split that will separate a string into elements separated by sep that is a single character. It even returns empty string as elements if nothing is in between sep.

vector<string> splitOneOf ( const string &  str,
const string &  delims = ",. \t" 
)

use one of the separators ( ,.;), no more will discard the leading separators This function should be removed, it is confusing All split functions should not discard leading fields. Needs to redefine.

Referenced by Alnchain::Alnchain().

string str2upper ( const string &  str  ) 

References toupper().

Referenced by mRNAModel::guessStrand().

void strTolower ( const string &  str1,
string &  str2 
)

void strTolower ( string &  str  ) 

void strToupper ( string &  str  ) 

bool subseqIsStop ( const string &  seq,
int  i 
)

seq must be in upper case

Parameters:
i. is the index of the subsequence of 3 nt.

References strToupper().

Referenced by mRNAModel::trimCDSStop(), and mRNAModel::trimCDSTail().

int substr ( const char  ln[],
int  s,
int  f,
char  sub[] 
)

picks non-whitespace substring from s to f returns the length of the substring s starting index, f ending index (inclusive)

int substr ( const char  ln[],
int  s,
char  sub[] 
)

Extraction picks substring from index s to a white space of ln, copy to sub sub is set to the substring without any whitespace at beginning or end. If from s to the end is all whitespace, then return 0 and sub is set to empty C string. returns strlen of the substr, 0 if no substr, or substr is empty s is 0-based index

Referenced by acronymWithTag(), Book::Book(), feature::getTaxid(), head::loadSeqInfo(), main(), Refreader::newRef(), locseg::parse(), Reference::parseJournal(), RangeChain::RangeChain(), Gsubreader::read(), readandstoreSam(), feature::readloc(), feature::RNAdump(), prt::writeAce(), and feature::writeAceDNA().

template<class T>
string toString ( const T val  )  [inline]

this can be used to conver most of the build-in types to string

string tr ( const string &  str,
char  i,
char  o 
)

void trim ( string &  str  ) 

removing trailing spaces if exist

void trimLeadingSpace ( string &  str  ) 

remove all leading spaces

Referenced by readandstoreGmap().

void upper ( const char  lo[],
char *  up 
)

int wc ( const string &  str  ) 

void writeSequence ( const string &  seq,
ostream &  ous,
const int  width = 70 
)


Generated on Wed Aug 10 11:57:02 2011 for Softwares from Orpara by  doxygen 1.5.6