Package pygccxml :: Package parser :: Module source_reader :: Class source_reader_t |

# ClassType source_reader_t

source code

    This class reads C++ source code and returns declarations tree.

    This class is the only class that have an intime knowledge about GCC-XML.
    It has only one responsibility: it calls GCC-XML with a source file specified
    by user and creates declarations tree. The implementation of this class is split
    to 2 classes:

    1. L{scanner_t} - this class scans the "XML" file, generated by GCC-XML and
       creates `pygccxml`_ declarations and types classes. After the xml file has
       been processed declarations and type class instances keeps references to
       each other using GCC-XML generated id's.

    2. L{linker_t} - this class contains logic for replacing GCC-XML generated
       ids with references to declarations or type class instances.

Instance Methods
__init__(self, config, cache=None, decl_factory=None) | source code
create_xml_file(self, header, destination=None) This function will return the file name of the file, created by GCC-XML for "header" file. | source code
create_xml_file_from_string(self, content, destination=None) Creates XML file from text. | source code
read_file(self, source_file) | source code
read_gccxml_file(self, source_file) Reads C++ source file and returns declarations tree | source code
read_xml_file(self, gccxml_created_file) Reads GCC-XML generated XML file. | source code
read_string(self, content) Reads Python string, that contains valid C++ code, and returns declarations tree. | source code
read_synopsis_file(self, source_file) | source code

Method Details

### __init__(self, config, cache=None, decl_factory=None) (Constructor) | source code
Parameters: `config` (config_t) - instance of config_t class, that contains GCC-XML configuration `cache` - reference to cache object, that will be updated after file has been parsed. `cache` - instance of class, that derives from {cache_base_t} `decl_factory` - declarations factory, if not given default declarations factory decl_factory_t will be used

### create_xml_file(self, header, destination=None) | source code
This function will return the file name of the file, created by GCC-XML for "header" file. If destination_file_path is not None, then this file path will be used and returned. Parameters: `header` (str) - path to source file, that should be parsed `destination` (str) - if given, will be used as target file/path for GCC-XML generated file. Returns: path to GCC-XML generated file

### create_xml_file_from_string(self, content, destination=None) | source code
Creates XML file from text. Parameters: `content` (str) - C++ source code `destination` (str) - file name for GCC-XML generated file Returns: returns file name of GCC-XML generated file

### read_gccxml_file(self, source_file) | source code
Reads C++ source file and returns declarations tree Parameters: `source_file` (str) - path to C++ source file

### read_xml_file(self, gccxml_created_file) | source code
Reads GCC-XML generated XML file. Parameters: `gccxml_created_file` (str) - path to GCC-XML generated file Returns: declarations tree