Regina Calculation Engine
Classes | Functions
File I/O

File reading and writing. More...

Classes

class  regina::NFileInfo
 Stores information about a Regina data file, including file type and version. More...
 
class  regina::NGlobalDirs
 Provides global routines that return directories in which various components of Regina are installed on the system. More...
 
class  regina::NXMLCallback
 Provides the callbacks for an XMLParser required to parse an entire file using a series of NXMLElementReader objects. More...
 
class  regina::NXMLElementReader
 Used to read the contents of a single XML element. More...
 
class  regina::NXMLCharsReader
 A reader for an XML element that contains only characters. More...
 

Functions

REGINA_API bool regina::writeXMLFile (const char *fileName, NPacket *subtree, bool compressed=true)
 Writes the subtree with the given packet as matriarch to disk as a complete XML file. More...
 
REGINA_API NPacket * regina::readXMLFile (const char *fileName)
 Reads the packet tree stored in the given XML file. More...
 
REGINA_API NPacket * regina::readFileMagic (const std::string &fileName)
 Reads a packet tree from a file whose format is unknown. More...
 

Detailed Description

File reading and writing.

Function Documentation

REGINA_API NPacket* regina::readFileMagic ( const std::string &  fileName)

Reads a packet tree from a file whose format is unknown.

As of Regina 4.94, old-style binary files are no longer supported. This means that the file must be in XML format (optionally compressed). In other words, this routine now behaves identically to readXMLFile().

If the matriarch of the packet tree could not be read, this routine will return 0. If a lower-level packet could not be read, it (and its descendants) will simply be ignored.

The given file might be opened and closed multiple times during this routine.

Internationalisation:
This routine makes no assumptions about the character encoding used in the given file name, and simply passes it through unchanged to low-level C/C++ file I/O routines.
Parameters
fileNamethe pathname of the file to read from.
Returns
the packet tree read from file, or 0 if problems were encountered or the file could not be opened.
REGINA_API NPacket* regina::readXMLFile ( const char *  fileName)

Reads the packet tree stored in the given XML file.

It does not matter whether the XML file is compressed.

If the matriarch of the packet tree could not be read, this routine will return 0. If a lower-level packet could not be read, it (and its descendants) will simply be ignored.

Internationalisation:
This routine makes no assumptions about the character encoding used in the given file name, and simply passes it through unchanged to low-level C/C++ file I/O routines.
Parameters
fileNamethe pathname of the file to read from.
Returns
the packet tree read from file, or 0 if problems were encountered or the file could not be opened.
REGINA_API bool regina::writeXMLFile ( const char *  fileName,
NPacket *  subtree,
bool  compressed = true 
)

Writes the subtree with the given packet as matriarch to disk as a complete XML file.

The XML file may be optionally compressed.

This is the preferred way of writing a packet tree to file.

Precondition
The given packet does not depend on its parent.
Internationalisation:
This routine makes no assumptions about the character encoding used in the given file name, and simply passes it through unchanged to low-level C/C++ file I/O routines.
Parameters
fileNamethe pathname of the file to write to.
subtreethe matriarch of the packet tree that should be written.
compressedtrue if the XML file should be compressed or false if it should be stored as plain text.
Returns
true if and only if the packet subtree was successfully written.

Copyright © 1999-2013, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).