00001 #ifndef DV_UTIL_SPLITSTRING_H 00002 #define DV_UTIL_SPLITSTRING_H 00003 // $Id: splitstring.h,v 1.2 2007/11/27 11:42:21 dvermeir Exp $ 00004 00005 #include <string> 00006 #include <vector> 00007 00008 namespace Dv { 00009 namespace Util { 00010 /** Split a string consisting of substrings separated by a separator character. 00011 * The substrings will be appended to the output vector. 00012 * @param input string, e.g. 'abcXdefX1234' (with 'X' the separator character) 00013 * @param separator char, e.g. 'X' in the above example 00014 * @param output vector, e.g. { 'abc', 'def', '1234' } 00015 * @return the number of strings added to output, e.g. 3 00016 * 00017 * Some borderline cases (each time with '/' as separator): 00018 * @code 00019 * '/abc/def' yields { '', 'abc', 'def' } 00020 * 'abc/def/1234' yields { 'abc', 'def', '1234' } 00021 * 'abc/def/' yields { 'abc', 'def', '' } 00022 * @endcode 00023 */ 00024 size_t split_string(const std::string& input, const char separator, 00025 std::vector<std::string>& output) throw(); 00026 } 00027 } 00028 00029 00030 #endif
dvutil-1.0.10 | [ 5 December, 2009] |