tlx
split_words.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * tlx/string/split_words.hpp
3 *
4 * Part of tlx - http://panthema.net/tlx
5 *
6 * Copyright (C) 2016-2017 Timo Bingmann <tb@panthema.net>
7 *
8 * All rights reserved. Published under the Boost Software License, Version 1.0
9 ******************************************************************************/
10
11#ifndef TLX_STRING_SPLIT_WORDS_HEADER
12#define TLX_STRING_SPLIT_WORDS_HEADER
13
14#include <string>
15#include <vector>
16
17namespace tlx {
18
19//! \addtogroup tlx_string
20//! \{
21
22/*!
23 * Split the given string by whitespaces into distinct words. Multiple
24 * consecutive whitespaces are considered as one split point. Whitespaces are
25 * space, tab, newline and carriage-return.
26 *
27 * \param str string to split
28 * \param limit maximum number of parts returned
29 * \return vector containing each split substring
30 */
31std::vector<std::string> split_words(
32 const std::string& str, std::string::size_type limit = std::string::npos);
33
34//! \}
35
36} // namespace tlx
37
38#endif // !TLX_STRING_SPLIT_WORDS_HEADER
39
40/******************************************************************************/
std::vector< std::string > split_words(const std::string &str, std::string::size_type limit)
Split the given string by whitespaces into distinct words.
Definition: split_words.cpp:15