The Gaudi Framework  v36r1 (3e2fb5a8)
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 216 of file semantics.py.

216 def extract_template_args(cpp_type):
217  '''
218  Return an iterator over the list of template arguments in a C++ type
219  string.
220 
221  >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
222  >>> list(extract_template_args(t))
223  ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
224  >>> list(extract_template_args('int'))
225  []
226  '''
227  template_level = 0
228  arg_start = -1
229  for p, c in enumerate(cpp_type):
230  if c == ',':
231  if template_level == 1:
232  yield cpp_type[arg_start:p].strip()
233  arg_start = p + 1
234  elif c == '<':
235  template_level += 1
236  if template_level == 1:
237  arg_start = p + 1
238  elif c == '>':
239  template_level -= 1
240  if template_level == 0:
241  yield cpp_type[arg_start:p].strip()
242 
243 

◆ getSemanticsFor()

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

Definition at line 450 of file semantics.py.

450 def getSemanticsFor(cpp_type, name=None):
451  for semantics in SEMANTICS:
452  try:
453  return semantics(cpp_type, name)
454  except TypeError:
455  pass
456  return DefaultSemantics(cpp_type, name)

Variable Documentation

◆ _COMMA_SEPARATION_RE

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

Definition at line 159 of file semantics.py.

◆ _IDENTIFIER_RE

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

Definition at line 157 of file semantics.py.

◆ _log

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

Definition at line 24 of file semantics.py.

◆ _NS_IDENT_RE

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

Definition at line 158 of file semantics.py.

◆ basestring

GaudiConfig2.semantics.basestring = str

Definition at line 22 of file semantics.py.

◆ DefaultSemantics

GaudiConfig2.semantics.DefaultSemantics = PropertySemantics

Definition at line 89 of file semantics.py.

◆ is_64bits

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

Definition at line 25 of file semantics.py.

◆ SEMANTICS

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

Definition at line 444 of file semantics.py.

GaudiConfig2.semantics.extract_template_args
def extract_template_args(cpp_type)
Definition: semantics.py:216
GaudiConfig2.semantics.getSemanticsFor
def getSemanticsFor(cpp_type, name=None)
Definition: semantics.py:450
GaudiConfig2.semantics.DefaultSemantics
DefaultSemantics
Definition: semantics.py:89