Package pygccxml :: Package declarations :: Module templates |

# Source Code for Module pygccxml.declarations.templates

     1  # Copyright 2004-2008 Roman Yakovenko.
     2  # Distributed under the Boost Software License, Version 1.0. (See
     3  # accompanying file LICENSE_1_0.txt or copy at
     4  # http://www.boost.org/LICENSE_1_0.txt)
     5
     6  """
     7  template instantiation parser
     8
     9  This module implements all functionality necessary to parse C++ template
    10  instantiations.In other words this module is able to extract next information from
    11  the string like this C{ std::vector<int> }.
    12      - name ( std::vector )
    13      - list of arguments ( int )
    14
    15  This module also defines few convenience function like L{split} and L{join}.
    16  """
    17
    18  import pattern_parser
    19
    20  __THE_PARSER = pattern_parser.parser_t( '<', '>', ',' )
    21
    22 -def is_instantiation( decl_string ):
    23      """
    24      returns True if decl_string is template instantiation and False otherwise
    25
    26      @param decl_string: string that should be checked for pattern presence
    27      @type decl_string: str
    28
    29      @return: bool
    30      """
    31      global __THE_PARSER
    32      return __THE_PARSER.has_pattern( decl_string )
    33
    34 -def name( decl_string ):
    35      """
    36      returns name of instantiated template
    37
    38      @type decl_string: str
    39      @return: str
    40      """
    41      global __THE_PARSER
    42      return __THE_PARSER.name( decl_string )
    43
    44 -def args( decl_string ):
    45      """
    46      returns list of template arguments
    47
    48      @type decl_string: str
    49      @return: [str]
    50      """
    51      global __THE_PARSER
    52      return __THE_PARSER.args( decl_string )
    53
    54 -def split( decl_string ):
    55      """returns (name, [arguments] )"""
    56      global __THE_PARSER
    57      return __THE_PARSER.split( decl_string )
    58
    59 -def split_recursive( decl_string ):
    60      """returns [(name, [arguments])]"""
    61      global __THE_PARSER
    62      return __THE_PARSER.split_recursive( decl_string )
    63
    64 -def join( name, args ):
    65      """returns name< argument_1, argument_2, ..., argument_n >"""
    66      global __THE_PARSER
    67      return __THE_PARSER.join( name, args )
    68
    69 -def normalize( decl_string ):
    70      """returns decl_string, which contains "normalized" spaces
    71
    72      this functionality allows to implement comparison of 2 different string
    73      which are actually same: x::y< z > and x::y<z>
    74      """
    75      global __THE_PARSER
    76      return __THE_PARSER.normalize( decl_string )
    77