tlx
contains_word.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/string/contains_word.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_CONTAINS_WORD_HEADER
12 #define TLX_STRING_CONTAINS_WORD_HEADER
13 
14 #include <string>
15 
16 namespace tlx {
17 
18 //! \addtogroup tlx_string
19 //! \{
20 
21 /******************************************************************************/
22 // contains_word()
23 
24 /*!
25  * Search the given string for a whitespace-delimited word. It works as if the
26  * str was split_words() and the resulting vector checked for a given
27  * word. However this function does not create a vector, it scans the string
28  * directly. Whitespace is space, tab, newline or carriage-return.
29  *
30  * \param str whitespace-delimited string to check
31  * \param word word to find
32  * \return true if the word was found
33  */
34 bool contains_word(const std::string& str, const char* word);
35 
36 /*!
37  * Search the given string for a whitespace-delimited word. It works as if the
38  * str was split_words() and the resulting vector checked for a given
39  * word. However this function does not create a vector, it scans the string
40  * directly. Whitespace is space, tab, newline or carriage-return.
41  *
42  * \param str whitespace-delimited string to check
43  * \param word word to find
44  * \return true if the word was found
45  */
46 bool contains_word(const std::string& str, const std::string& word);
47 
48 //! \}
49 
50 } // namespace tlx
51 
52 #endif // !TLX_STRING_CONTAINS_WORD_HEADER
53 
54 /******************************************************************************/
bool contains_word(const std::string &str, const char *word)
Search the given string for a whitespace-delimited word.