Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
remainder
src
Teuchos_StringToIntMap.hpp
1
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef TEUCHOS_STRING_TO_INT_MAP_HPP
11
#define TEUCHOS_STRING_TO_INT_MAP_HPP
12
13
#include "Teuchos_Assert.hpp"
14
#include <map>
15
#include <string>
16
17
namespace
Teuchos
{
18
65
class
StringToIntMap
{
66
public
:
67
69
class
AlreadyExists :
public
std::logic_error
70
{
public
: AlreadyExists(
const
std::string& what_arg) : std::logic_error(what_arg) {}};
71
73
class
DoesNotExist :
public
std::logic_error
74
{
public
: DoesNotExist(
const
std::string& what_arg) : std::logic_error(what_arg) {}};
75
77
StringToIntMap
(
const
std::string&
defaultGroupName
,
int
n,
const
char
* strings[] );
78
80
int
get
(
const
std::string& option,
const
std::string& groupName =
""
)
const
;
81
83
template
<
class
EnumType>
84
EnumType
get
(
const
std::string& option,
const
std::string& groupName =
""
)
const
;
85
87
const
std::string&
defaultGroupName
()
const
;
88
89
private
:
90
91
typedef
std::map< std::string, int > map_t;
// all share implementation.
92
std::string defaultGroupName_;
93
map_t map_;
94
95
std::string validSelections()
const
;
96
97
// not defined and not to be called.
98
StringToIntMap
();
99
100
};
// end class StringToIntMap
101
105
template
<
class
EnumType>
106
inline
107
EnumType
get
(
108
StringToIntMap
const
& theMap
109
,std::string
const
& option
110
,std::string
const
& groupName =
""
111
)
112
{
113
return
static_cast<
EnumType
>
(theMap.
get
(option,groupName));
114
}
115
116
// ////////////////////////////////////////////
117
// Inline declarations
118
119
template
<
class
EnumType>
120
inline
121
EnumType
StringToIntMap::get
(
const
std::string& option,
const
std::string& groupName )
const
122
{
123
return
static_cast<
EnumType
>
(
get
(option,groupName));
124
}
125
126
inline
127
const
std::string&
StringToIntMap::defaultGroupName
()
const
128
{
129
return
defaultGroupName_;
130
}
131
132
}
// end namespace Teuchos
133
134
#endif
// TEUCHOS_STRING_TO_INT_MAP_HPP
Teuchos::StringToIntMap::StringToIntMap
StringToIntMap(const std::string &defaultGroupName, int n, const char *strings[])
Definition
Teuchos_StringToIntMap.cpp:14
Teuchos::StringToIntMap::get
EnumType get(StringToIntMap const &theMap, std::string const &option, std::string const &groupName="")
Nonmember get function.
Definition
Teuchos_StringToIntMap.hpp:107
Teuchos::StringToIntMap::get
int get(const std::string &option, const std::string &groupName="") const
Definition
Teuchos_StringToIntMap.cpp:29
Teuchos::StringToIntMap::defaultGroupName
const std::string & defaultGroupName() const
Definition
Teuchos_StringToIntMap.hpp:127
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0