Class sac_parser

Inheritance Relationships

Derived Type

Class Documentation

class sac_parser

The sac_parser is a similar to SAX parsers (Simple API for XML, in our case it is Simple API for CIF)

This is a hand crafted, optimised parser for reading cif files, both cif 1.0 and cif 1.1 is supported. But version 2.0 is not. That means that the content of files strictly contains only ASCII characters. Anything else will generate an error.

This class is an abstract base class. Derived classes should implement the produce_ methods.

Subclassed by cif::parser

Public Types

enum CharTraitsMask

The parser only supports ASCII so we can create a table with character properties.

Values:

enumerator kOrdinaryMask

The character is in the Ordinary class.

enumerator kNonBlankMask

The character is in the NonBlank class.

enumerator kTextLeadMask

The character is in the TextLead class.

enumerator kAnyPrintMask

The character is in the AnyPrint class.

Public Functions

bool parse_single_datablock(const std::string &datablock)

Parse only a single datablock in the string datablock The start of the datablock is first located and then data is parsed up until the next start of a datablock or the end of the data.

datablock_index index_datablocks()

Return an index for all the datablocks found, that is the index will contain the names and offsets for each.

bool parse_single_datablock(const std::string &datablock, const datablock_index &index)

Parse the datablock named datablock.

This will first lookup the datablock’s offset in the index index and then start parsing from that location until the next datablock.

Parameters
  • datablock – Name of the datablock to parse

  • index – The index created using index_datablocks

Returns

true If the datablock was found

Returns

false If the datablock was not found

void parse_file()

Parse the file.

Public Static Functions

static inline constexpr bool is_space(int ch)

Return true if the character ch is a space character.

static inline constexpr bool is_white(int ch)

Return true if the character ch is a white character.

static inline constexpr bool is_ordinary(int ch)

Return true if the character ch is a ordinary character.

static inline constexpr bool is_non_blank(int ch)

Return true if the character ch is a non_blank character.

static inline constexpr bool is_text_lead(int ch)

Return true if the character ch is a text_lead character.

static inline constexpr bool is_any_print(int ch)

Return true if the character ch is a any_print character.

static bool is_unquoted_string(std::string_view text)

Return true if the string in text can safely be written without quotation.