/** ** Copyright (c) 2007-2010 Illumina, Inc. ** ** This software is covered by the "Illumina Genome Analyzer Software ** License Agreement" and the "Illumina Source Code License Agreement", ** and certain third party copyright/licenses, and any user of this ** source file is bound by the terms therein (see accompanying files ** Illumina_Genome_Analyzer_Software_License_Agreement.pdf and ** Illumina_Source_Code_License_Agreement.pdf and third party ** copyright/license notices). ** ** This file is part of the Consensus Assessment of Sequence And VAriation ** (CASAVA) software package. ** ** \file include/common/StringUtil.h ** ** \brief String utilities ** ** String utilities ** ** \author Lukasz Szajkowski **/ #ifndef _STRING_UTIL_H #define _STRING_UTIL_H #include #include using namespace std; /* * Convert input string into vector of string tokens * strin string to be parsed * delims list of delimiters. */ std::vector tokenize_str(const std::string & strin, const std::string & delims=", \t"); /* * The procedures tokenizes str string. seperate memory for each token is alocated. * Memory in tokenList should be dealocated */ void fastTokenizer(const char* str, char delim, vector& tokenList); /* * The procedures tokenizes str string using str memory (the str str is changed) * The procedure is faster version of fastTokenizer */ void fastTokenizerInPlace(char* str, char delim, vector& tokenList); /* * Replaces maching characters in the string with given new characters. * return number of characters replaced. */ int replaceTR( std::string & strin, const std::string & findChars, const std::string & replCHars); /* * Returns a ptr to a newly allocated C-string that is a copy of the supplied * string. */ char* copy_to_new_cstr(const std::string& str); /// replace old_suffix in str with new_suffix and place result in /// new_str return false if old_suffix is not a suffix of str /// bool replace_suffix(const std::string& str, const std::string& old_suffix, const std::string& new_suffix, std::string& new_str); /// \brief get the number of w/s separated columns in str /// unsigned GetStringColCount(const char* str); #endif /* _STRING_UTIL_H */