The Gaudi Framework  master (d98a2936)
GaudiConfig2.semantics Namespace Reference

Classes

class  _DictHelper
 
class  _ListHelper
 
class  _SetHelper
 
class  BoolSemantics
 
class  ComponentHandleSemantics
 
class  ComponentSemantics
 
class  DefaultSemantics
 
class  FloatSemantics
 
class  GaudiHandleArraySemantics
 
class  IntSemantics
 
class  MappingSemantics
 
class  OrderedSetSemantics
 
class  PropertySemantics
 
class  SequenceSemantics
 
class  SetSemantics
 
class  StringSemantics
 

Functions

def extract_template_args (cpp_type)
 
def getSemanticsFor (cpp_type, strict=False)
 

Variables

 _log
 
 is_64bits
 
 _IDENTIFIER_RE
 
 _NS_IDENT_RE
 
 ident
 
 _COMMA_SEPARATION_RE
 
 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 351 of file semantics.py.

351 def extract_template_args(cpp_type):
352  """
353  Return an iterator over the list of template arguments in a C++ type
354  string.
355 
356  >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
357  >>> list(extract_template_args(t))
358  ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
359  >>> list(extract_template_args('int'))
360  []
361  """
362  template_level = 0
363  arg_start = -1
364  for p, c in enumerate(cpp_type):
365  if c == ",":
366  if template_level == 1:
367  yield cpp_type[arg_start:p].strip()
368  arg_start = p + 1
369  elif c == "<":
370  template_level += 1
371  if template_level == 1:
372  arg_start = p + 1
373  elif c == ">":
374  template_level -= 1
375  if template_level == 0:
376  yield cpp_type[arg_start:p].strip()
377 
378 

◆ getSemanticsFor()

def GaudiConfig2.semantics.getSemanticsFor (   cpp_type,
  strict = False 
)
Return semantics for given type. If no type-specific semantics can be found
return DefaultSemantics. In strict mode, raise a TypeError instead.

Definition at line 719 of file semantics.py.

719 def getSemanticsFor(cpp_type, strict=False):
720  """Return semantics for given type. If no type-specific semantics can be found
721  return DefaultSemantics. In strict mode, raise a TypeError instead.
722  """
723 
724  for semantics in SEMANTICS:
725  try:
726  return semantics(cpp_type)
727  except TypeError:
728  pass
729 
730  if strict:
731  raise TypeError(f"No semantics found for {cpp_type}")
732 
733  return DefaultSemantics(cpp_type)

Variable Documentation

◆ _COMMA_SEPARATION_RE

GaudiConfig2.semantics._COMMA_SEPARATION_RE
private

Definition at line 204 of file semantics.py.

◆ _IDENTIFIER_RE

GaudiConfig2.semantics._IDENTIFIER_RE
private

Definition at line 202 of file semantics.py.

◆ _log

GaudiConfig2.semantics._log
private

Definition at line 22 of file semantics.py.

◆ _NS_IDENT_RE

GaudiConfig2.semantics._NS_IDENT_RE
private

Definition at line 203 of file semantics.py.

◆ ident

GaudiConfig2.semantics.ident

Definition at line 203 of file semantics.py.

◆ is_64bits

GaudiConfig2.semantics.is_64bits

Definition at line 23 of file semantics.py.

◆ SEMANTICS

GaudiConfig2.semantics.SEMANTICS

Definition at line 710 of file semantics.py.

GaudiConfig2.semantics.getSemanticsFor
def getSemanticsFor(cpp_type, strict=False)
Definition: semantics.py:719
GaudiConfig2.semantics.extract_template_args
def extract_template_args(cpp_type)
Definition: semantics.py:351