tlx
index_of.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/string/index_of.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2007-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_INDEX_OF_HEADER
12 #define TLX_STRING_INDEX_OF_HEADER
13 
14 #include <string>
15 #include <vector>
16 
17 namespace tlx {
18 
19 //! \addtogroup tlx_string
20 //! \{
21 
22 /*!
23  * Attempts to find str in the list and return the index. Throws a
24  * std::runtime_error if it is not found.
25  */
26 size_t index_of(const std::vector<std::string>& list, const char* str);
27 
28 /*!
29  * Attempts to find str in the list and return the index. Throws a
30  * std::runtime_error if it is not found.
31  */
32 size_t index_of(const std::vector<std::string>& list, const std::string& str);
33 
34 /*!
35  * Attempts to find str in the list and return the index using case-insensitive
36  * comparisons. Throws a std::runtime_error if it is not found.
37  */
38 size_t index_of_icase(const std::vector<std::string>& list, const char* str);
39 
40 /*!
41  * Attempts to find str in the list and return the index using case-insensitive
42  * comparisons. Throws a std::runtime_error if it is not found.
43  */
44 size_t
45 index_of_icase(const std::vector<std::string>& list, const std::string& str);
46 
47 //! \}
48 
49 } // namespace tlx
50 
51 #endif // !TLX_STRING_INDEX_OF_HEADER
52 
53 /******************************************************************************/
size_t index_of_icase(const std::vector< std::string > &list, const char *str)
Attempts to find str in the list and return the index using case-insensitive comparisons.
Definition: index_of.cpp:39
size_t index_of(const std::vector< std::string > &list, const char *str)
Attempts to find str in the list and return the index.
Definition: index_of.cpp:19