MLBookProc 1.3
Loading...
Searching...
No Matches
FormatAnnotation Class Reference

The FormatAnnotation class. More...

#include <FormatAnnotation.h>

Public Member Functions

 FormatAnnotation (const std::shared_ptr< AuxFunc > &af)
 FormatAnnotation constructor.
virtual ~FormatAnnotation ()
 FormatAnnotation destructor.
void remove_escape_sequences (std::string &annotation)
 Removes escape sequences from annotation.
void removeEscapeSequences (std::string &annotation)
 Removes escape sequences from annotation.
void replace_tags (std::string &annotation)
 Replaces XML tags.
void replaceTags (std::string &annotation)
 Replaces XML tags.
void final_cleaning (std::string &annotation)
 Cleans some sequences from annotation.
void finalCleaning (std::string &annotation)
 Cleans some sequences from annotation.
void removeAllTags (std::string &annotation)
 Simply removes all XML tags.
void setTagReplacementTable (const std::vector< ReplaceTagItem > &replacement_table, const std::vector< std::tuple< std::string, std::string > > &symbols_replacement)
 Sets tag replacement table.

Detailed Description

The FormatAnnotation class.

This class contains different methods for annotation processing.

Constructor & Destructor Documentation

◆ FormatAnnotation()

FormatAnnotation::FormatAnnotation ( const std::shared_ptr< AuxFunc > & af)

FormatAnnotation constructor.

Parameters
afsmart pointer to AuxFunc object.

Member Function Documentation

◆ final_cleaning()

void FormatAnnotation::final_cleaning ( std::string & annotation)

Cleans some sequences from annotation.

Replaces "three spaces" by "two spaces" at the annotation beginning, removes "\n" from annotation beginning, removes 0 - 32 ASCII symbols from the annotation end. Also replaces "\n\n\n" sequences by "\n\n" in whole annotation.

Deprecated
This method will be removed in future releases. Use finalCleaning() instead.
Parameters
annotationUTF-8 annotation content string.

◆ finalCleaning()

void FormatAnnotation::finalCleaning ( std::string & annotation)

Cleans some sequences from annotation.

Replaces "three spaces" by "two spaces" at the annotation beginning, removes "\n" from annotation beginning, removes 0 - 32 ASCII symbols from the annotation end. Also replaces "\n\n\n" sequences by "\n\n" in whole annotation.

Parameters
annotationUTF-8 annotation content string.

◆ remove_escape_sequences()

void FormatAnnotation::remove_escape_sequences ( std::string & annotation)

Removes escape sequences from annotation.

Removes ASCII symbols 0 to 31 (inclusive) from annotation. Only exception is symbol 9 (horizontal tab). It will be replaced by 32 (space). Also removes extra spaces from annotation beginning.

Deprecated
This method will be removed in future releases. Use removeEscapeSequences() instead.
Parameters
annotationUTF-8 annotation content string.

◆ removeAllTags()

void FormatAnnotation::removeAllTags ( std::string & annotation)

Simply removes all XML tags.

In case of errors, this method does nothing.

Parameters
annotationUTF-8 annotation content string.

◆ removeEscapeSequences()

void FormatAnnotation::removeEscapeSequences ( std::string & annotation)

Removes escape sequences from annotation.

Removes ASCII symbols 0 to 31 (inclusive) from annotation. Only exception is symbol 9 (horizontal tab). It will be replaced by 32 (space). Also removes extra spaces from annotation beginning.

Parameters
annotationUTF-8 annotation content string.

◆ replace_tags()

void FormatAnnotation::replace_tags ( std::string & annotation)

Replaces XML tags.

It is highly recommended to call setTagReplacementTable() method before this method call (but it is not compulsory). If tag replacement table is empty, all tags will be just removed.

Deprecated
This method will be removed in future releases. Use replaceTags() instead.
Parameters
annotationUTF-8 annotation content string.

◆ replaceTags()

void FormatAnnotation::replaceTags ( std::string & annotation)

Replaces XML tags.

It is highly recommended to call setTagReplacementTable() method before this method call (but it is not compulsory). If tag replacement table is empty, all tags will be just removed. In case of errors, this method does nothing.

Parameters
annotationUTF-8 annotation content string.

◆ setTagReplacementTable()

void FormatAnnotation::setTagReplacementTable ( const std::vector< ReplaceTagItem > & replacement_table,
const std::vector< std::tuple< std::string, std::string > > & symbols_replacement )

Sets tag replacement table.

If you need to replace XML tags by your own tags or text, you should call this method before replaceTags() call to set replacement table.

Parameters
replacement_tablevector containing ReplaceTagItem objects.
symbols_replacementVector of tuples. First element of tuple is string to be replaced in tag content, second element is replacement string.