OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
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 
23 
24 namespace Expressions {
25 
26  // Function find
27  // ----------------------------------------------------------------------
29  // The input table is a C array of structures containing a [b]name[/b]
30  // entry. The result is a pointer to one component of the array or NULL.
31  // May be replaced by a map<> with suitable parameters.
32 
33  template <class T> inline
34  const T *find(const T table[], const std::string &name) {
35  for(const T *x = table; x->name != 0; x++) {
36  if(x->name == name) return x;
37  }
38 
39  return 0;
40  }
41 
42 }
43 
44 #endif // OPAL_TFind_HH
const std::string name
Representation objects and parsers for attribute expressions.
Definition: Expressions.h:64
const T * find(const T table[], const std::string &name)
Look up name.
Definition: TFind.h:34