OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
TFind.h
Go to the documentation of this file.
1#ifndef OPAL_TFind_HH
2#define OPAL_TFind_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: TFind.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Template function: find<T>(const T table[], const string &name).
13//
14// ------------------------------------------------------------------------
15//
16// $Date: 2000/03/27 09:33:42 $
17// $Author: Andreas Adelmann $
18//
19// ------------------------------------------------------------------------
20
21#include <string>
22
23namespace Expressions {
24
25 // Function find
26 // ----------------------------------------------------------------------
28 // The input table is a C array of structures containing a [b]name[/b]
29 // entry. The result is a pointer to one component of the array or nullptr.
30 // May be replaced by a map<> with suitable parameters.
31
32 template <class T>
33 inline const T* find(const T table[], const std::string& name) {
34 for (const T* x = table; x->name != 0; x++) {
35 if (x->name == name) return x;
36 }
37
38 return 0;
39 }
40
41} // namespace Expressions
42
43#endif // OPAL_TFind_HH
double T
Definition OPALTypes.h:8
Representation objects and parsers for attribute expressions.
const T * find(const T table[], const std::string &name)
Look up name.
Definition TFind.h:33