pygccxml.parser.project_reader module

class COMPILATION_MODE

Bases: object

ALL_AT_ONCE = 'all at once'
FILE_BY_FILE = 'file by file'
create_cached_source_fc(header, cached_source_file)

Creates parser.file_configuration_t instance, configured to contain path to GCC-XML generated XML file and C++ source file. If XML file does not exists, it will be created and used for parsing. If XML file exists, it will be used for parsing.

Parameters
  • header (str) – path to C++ source file

  • cached_source_file (str) – path to GCC-XML generated XML file

Return type

parser.file_configuration_t

create_gccxml_fc(xml_file)

Creates parser.file_configuration_t instance, configured to contain path to GCC-XML generated XML file.

Parameters

xml_file (str) – path to GCC-XML generated XML file

Return type

parser.file_configuration_t

create_source_fc(header)

Creates parser.file_configuration_t instance, configured to contain path to C++ source file

Parameters

header (str) – path to C++ source file

Return type

parser.file_configuration_t

create_text_fc(text)

Creates parser.file_configuration_t instance, configured to contain Python string, that contains valid C++ code

Parameters

text (str) – C++ code

Return type

parser.file_configuration_t

class file_configuration_t(data, start_with_declarations=None, content_type='standard source file', cached_source_file=None)

Bases: object

source code location configuration.

The class instance uses “variant” interface to represent the following data:

  1. path to a C++ source file

  2. path to GCC-XML generated XML file

  3. path to a C++ source file and path to GCC-XML generated file

    In this case, if XML file does not exists, it will be created. Next time you will ask to parse the source file, the XML file will be used instead.

    Small tip: you can setup your makefile to delete XML files every time, the relevant source file was changed.

  4. Python string, that contains valid C++ code

There are few functions, that will help you to construct file_configuration_t object:

class CONTENT_TYPE

Bases: object

CACHED_SOURCE_FILE = 'cached source file'
GCCXML_GENERATED_FILE = 'gccxml generated file'
STANDARD_SOURCE_FILE = 'standard source file'
TEXT = 'text'
property cached_source_file
property content_type
property data
property start_with_declarations
class project_reader_t(config, cache=None, decl_factory=None)

Bases: object

parses header files and returns the contained declarations

static get_os_file_names(files)

returns file names

Parameters

files (list) – list of strings andor file_configuration_t instances.

read_files(files, compilation_mode='file by file')

parses a set of files

Parameters
  • files (list) – list of strings andor file_configuration_t instances.

  • compilation_mode (COMPILATION_MODE) – determines whether the files are parsed individually or as one single chunk

Return type

[declaration_t]

read_string(content)

Parse a string containing C/C++ source code.

Parameters

content (str) – C/C++ source code.

Return type

Declarations

read_xml(file_configuration)

parses C++ code, defined on the file_configurations and returns GCCXML generated file content

property xml_generator_from_xml_file

Configuration object containing information about the xml generator read from the xml file.

Returns

configuration object

Return type

utils.xml_generators