The Gaudi Framework  v36r7 (7f57a304)
GaudiConfig2.semantics Namespace Reference

Classes

class  _DictHelper
 
class  _ListHelper
 
class  BoolSemantics
 
class  ComponentSemantics
 
class  DefaultSemantics
 
class  FloatSemantics
 
class  IntSemantics
 
class  MappingSemantics
 
class  OrderedSetSemantics
 
class  PropertySemantics
 
class  SequenceSemantics
 
class  StringSemantics
 

Functions

def extract_template_args (cpp_type)
 
def getSemanticsFor (cpp_type, name=None)
 

Variables

 basestring = str
 
 _log = logging.getLogger(__name__)
 
int is_64bits = sys.maxsize > 2**32
 
string _IDENTIFIER_RE = r"[a-zA-Z_][a-zA-Z0-9_]*"
 
string _NS_IDENT_RE = r"{ident}(::{ident})*".format(ident=_IDENTIFIER_RE)
 
string _COMMA_SEPARATION_RE = r"{exp}(,{exp})*"
 
list SEMANTICS
 

Function Documentation

◆ extract_template_args()

def GaudiConfig2.semantics.extract_template_args (   cpp_type)
Return an iterator over the list of template arguments in a C++ type
string.

>>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
>>> list(extract_template_args(t))
['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
>>> list(extract_template_args('int'))
[]

Definition at line 270 of file semantics.py.

270 def extract_template_args(cpp_type):
271  """
272  Return an iterator over the list of template arguments in a C++ type
273  string.
274 
275  >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
276  >>> list(extract_template_args(t))
277  ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
278  >>> list(extract_template_args('int'))
279  []
280  """
281  template_level = 0
282  arg_start = -1
283  for p, c in enumerate(cpp_type):
284  if c == ",":
285  if template_level == 1:
286  yield cpp_type[arg_start:p].strip()
287  arg_start = p + 1
288  elif c == "<":
289  template_level += 1
290  if template_level == 1:
291  arg_start = p + 1
292  elif c == ">":
293  template_level -= 1
294  if template_level == 0:
295  yield cpp_type[arg_start:p].strip()
296 
297 

◆ getSemanticsFor()

def GaudiConfig2.semantics.getSemanticsFor (   cpp_type,
  name = None 
)

Definition at line 510 of file semantics.py.

510 def getSemanticsFor(cpp_type, name=None):
511  for semantics in SEMANTICS:
512  try:
513  return semantics(cpp_type, name)
514  except TypeError:
515  pass
516  return DefaultSemantics(cpp_type, name)

Variable Documentation

◆ _COMMA_SEPARATION_RE

string GaudiConfig2.semantics._COMMA_SEPARATION_RE = r"{exp}(,{exp})*"
private

Definition at line 201 of file semantics.py.

◆ _IDENTIFIER_RE

string GaudiConfig2.semantics._IDENTIFIER_RE = r"[a-zA-Z_][a-zA-Z0-9_]*"
private

Definition at line 199 of file semantics.py.

◆ _log

GaudiConfig2.semantics._log = logging.getLogger(__name__)
private

Definition at line 27 of file semantics.py.

◆ _NS_IDENT_RE

string GaudiConfig2.semantics._NS_IDENT_RE = r"{ident}(::{ident})*".format(ident=_IDENTIFIER_RE)
private

Definition at line 200 of file semantics.py.

◆ basestring

GaudiConfig2.semantics.basestring = str

Definition at line 25 of file semantics.py.

◆ is_64bits

int GaudiConfig2.semantics.is_64bits = sys.maxsize > 2**32

Definition at line 28 of file semantics.py.

◆ SEMANTICS

list GaudiConfig2.semantics.SEMANTICS
Initial value:
1 = [
2  c
3  for c in globals().values()
4  if isinstance(c, type)
5  and issubclass(c, PropertySemantics)
6  and c not in (PropertySemantics, DefaultSemantics)
7 ]

Definition at line 501 of file semantics.py.

GaudiConfig2.semantics.extract_template_args
def extract_template_args(cpp_type)
Definition: semantics.py:270
GaudiConfig2.semantics.getSemanticsFor
def getSemanticsFor(cpp_type, name=None)
Definition: semantics.py:510