The Gaudi Framework  v36r3 (83a1ddab)
GaudiConfig2.semantics Namespace Reference

Classes

class  _DictHelper
 
class  _ListHelper
 
class  BoolSemantics
 
class  ComponentSemantics
 
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
 
 DefaultSemantics = PropertySemantics
 
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 237 of file semantics.py.

237 def extract_template_args(cpp_type):
238  """
239  Return an iterator over the list of template arguments in a C++ type
240  string.
241 
242  >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
243  >>> list(extract_template_args(t))
244  ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
245  >>> list(extract_template_args('int'))
246  []
247  """
248  template_level = 0
249  arg_start = -1
250  for p, c in enumerate(cpp_type):
251  if c == ",":
252  if template_level == 1:
253  yield cpp_type[arg_start:p].strip()
254  arg_start = p + 1
255  elif c == "<":
256  template_level += 1
257  if template_level == 1:
258  arg_start = p + 1
259  elif c == ">":
260  template_level -= 1
261  if template_level == 0:
262  yield cpp_type[arg_start:p].strip()
263 
264 

◆ getSemanticsFor()

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

Definition at line 474 of file semantics.py.

474 def getSemanticsFor(cpp_type, name=None):
475  for semantics in SEMANTICS:
476  try:
477  return semantics(cpp_type, name)
478  except TypeError:
479  pass
480  return DefaultSemantics(cpp_type, name)

Variable Documentation

◆ _COMMA_SEPARATION_RE

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

Definition at line 168 of file semantics.py.

◆ _IDENTIFIER_RE

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

Definition at line 166 of file semantics.py.

◆ _log

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

Definition at line 26 of file semantics.py.

◆ _NS_IDENT_RE

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

Definition at line 167 of file semantics.py.

◆ basestring

GaudiConfig2.semantics.basestring = str

Definition at line 24 of file semantics.py.

◆ DefaultSemantics

GaudiConfig2.semantics.DefaultSemantics = PropertySemantics

Definition at line 93 of file semantics.py.

◆ is_64bits

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

Definition at line 27 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 is not PropertySemantics
7 ]

Definition at line 465 of file semantics.py.

GaudiConfig2.semantics.extract_template_args
def extract_template_args(cpp_type)
Definition: semantics.py:237
GaudiConfig2.semantics.getSemanticsFor
def getSemanticsFor(cpp_type, name=None)
Definition: semantics.py:474
GaudiConfig2.semantics.DefaultSemantics
DefaultSemantics
Definition: semantics.py:93