libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | List of all members
crn::xml::Alto Class Reference

XML Alto file wrapper. More...

#include <CRNAlto.h>

+ Inheritance diagram for crn::xml::Alto:
+ Collaboration diagram for crn::xml::Alto:

Public Member Functions

 Alto (const Path &fname, bool char_conversion_throws=true)
 Constructor from a file. More...
 
 Alto (const Path &imagename, const StringUTF8 &ns, const StringUTF8 &encoding="UTF-8", const StringUTF8 &version="1.0", bool char_conversion_throws=true)
 Constructor from image. More...
 
 Alto (const Alto &)=delete
 
 Alto (Alto &&)=default
 
virtual ~Alto () override
 
Altooperator= (const Alto &)=delete
 
Altooperator= (Alto &&)=default
 
DescriptionGetDescription ()
 Gets the global description part of the Alto (may be null) More...
 
const DescriptionGetDescription () const
 
StylesGetStyles ()
 Gets the styles description part of the Alto (may be null) More...
 
const StylesGetStyles () const
 
LayoutGetLayout ()
 Gets the layout description part of the Alto. More...
 
const LayoutGetLayout () const
 
Layout::PageGetPage (const Id &id)
 
const Layout::PageGetPage (const Id &id) const
 
Layout::Page::Space & GetSpace (const Id &id)
 
const Layout::Page::Space & GetSpace (const Id &id) const
 
Layout::Page::Space::Block & GetBlock (const Id &id)
 
const Layout::Page::Space::Block & GetBlock (const Id &id) const
 
Layout::Page::Space::TextBlock & GetTextBlock (const Id &id)
 
const
Layout::Page::Space::TextBlock & 
GetTextBlock (const Id &id) const
 
Layout::Page::Space::TextBlock::TextLine & GetTextLine (const Id &id)
 
const
Layout::Page::Space::TextBlock::TextLine & 
GetTextLine (const Id &id) const
 
Layout::Page::Space::TextBlock::TextLine::Word & GetWord (const Id &id)
 
const
Layout::Page::Space::TextBlock::TextLine::Word & 
GetWord (const Id &id) const
 
ElementGetElement (const Id &id)
 
const ElementGetElement (const Id &id) const
 
Id CreateId ()
 Creates a new id for the document. More...
 
bool CheckId (const Id &id) const
 Checks if an id already exists in the document. More...
 
Id AddId (Element &el)
 Adds an id to an element. More...
 
- Public Member Functions inherited from crn::xml::Document
 Document (const StringUTF8 &encoding="UTF-8", const StringUTF8 &version="1.0", bool char_conversion_throws=true)
 Constructor. More...
 
 Document (const Path &fname, bool char_conversion_throws=true)
 Constructor from file. More...
 
 Document (const char *content, bool char_conversion_throws=true)
 Constructor from buffer. More...
 
 Document (const Document &)=delete
 
 Document (Document &&)
 
Documentoperator= (const Document &)=delete
 
Documentoperator= (Document &&)
 
virtual ~Document ()
 Destructor. More...
 
 operator bool () const noexcept
 Checks if the document is open. More...
 
bool operator! () const noexcept
 Checks if the document is not open. More...
 
void Save (const Path &fname)
 Saves to file. More...
 
void Save ()
 Saves to file. More...
 
const PathGetFilename () const noexcept
 Gets the filename if the document exists on the disk. More...
 
const StringUTF8GetEncoding () const noexcept
 Gets the character encoding of the file. More...
 
const StringUTF8GetVersion () const noexcept
 Gets the XML version of the file. More...
 
Element GetRoot ()
 Gets the first element. More...
 
Node GetFirstNode ()
 Gets the first child node. More...
 
Node GetLastNode ()
 Gets the last child node. More...
 
Node BeginNode ()
 Gets the first child node. More...
 
Node EndNode ()
 Gets a null node. More...
 
Element GetFirstElement (const StringUTF8 &name="")
 Gets the first child element. More...
 
Element GetLastElement (const StringUTF8 &name="")
 Gets the last child element. More...
 
Element BeginElement ()
 Gets the first child element. More...
 
Element EndElement ()
 Gets a null node. More...
 
Element PushBackElement (const StringUTF8 &name)
 Adds an element at the end of the children list. More...
 
Element InsertElement (Node &n, const StringUTF8 &name)
 Inserts an element after a node. More...
 
Comment PushBackComment (const StringUTF8 &text)
 Adds a comment at the end of the children list. More...
 
Comment InsertComment (Node &n, const StringUTF8 &text)
 Inserts a comment after a node. More...
 
Node PushBackClone (Node &n, bool recursive=false)
 Adds a copy of a node at the end of the children list. More...
 
StringUTF8 AsString ()
 Exports the document to a string. More...
 

Detailed Description

XML Alto file wrapper.

A class to load, modify and save an XML Alto file

Author
Yann LEYDIER

Definition at line 40 of file CRNAlto.h.

Constructor & Destructor Documentation

Alto::Alto ( const Path fname,
bool  char_conversion_throws = true 
)

Constructor from a file.

Constructor from a file

Exceptions
crn::ExceptionIOcannot read file
ExceptionInvalidArgumentnull node
ExceptionNotFoundan mandatory element or attribute was not found
Parameters
[in]fnamethe path to the file to read
[in]char_conversion_throwsshall an exception be thrown on character conversion error?

Definition at line 36 of file CRNAlto.cpp.

Alto::Alto ( const Path imagename,
const StringUTF8 ns,
const StringUTF8 encoding = "UTF-8",
const StringUTF8 version = "1.0",
bool  char_conversion_throws = true 
)

Constructor from image.

Constructor from image

Exceptions
crn::ExceptionInvalidArgumentnull filename or namespace
Parameters
[in]imagenamethe path the image
[in]nsthe namespace
[in]charsetthe character encoding
[in]throw_exceptionsshall an exception be thrown on character conversion error?

Definition at line 50 of file CRNAlto.cpp.

crn::xml::Alto::Alto ( const Alto )
delete
crn::xml::Alto::Alto ( Alto &&  )
default
virtual crn::xml::Alto::~Alto ( )
inlineoverridevirtual

Definition at line 49 of file CRNAlto.h.

Member Function Documentation

Id Alto::AddId ( Element el)

Adds an id to an element.

Adds an Id to an element and registers it

Warning
does not check if the element is really contained by the alto object
Exceptions
crn::ExceptionInvalidArgumentthe element already has an id
Parameters
[in]elthe element to register
Returns
the new id

Definition at line 622 of file CRNAlto.cpp.

bool Alto::CheckId ( const Id id) const

Checks if an id already exists in the document.

Checks if an id already exists in the document

Parameters
[in]idthe id to check
Returns
true if the id is free for use

Definition at line 611 of file CRNAlto.cpp.

Id Alto::CreateId ( )

Creates a new id for the document.

Creates a new id for the document

Returns
an id not already used

Definition at line 591 of file CRNAlto.cpp.

Alto::Layout::Page::Space::Block & Alto::GetBlock ( const Id id)

Returns a block

Warning
very slow
Exceptions
ExceptionNotFoundblock not found
Parameters
[in]idthe id of the block to get
Returns
the block

Definition at line 145 of file CRNAlto.cpp.

const Alto::Layout::Page::Space::Block & Alto::GetBlock ( const Id id) const

Returns a block

Warning
very slow
Exceptions
ExceptionNotFoundblock not found
Parameters
[in]idthe id of the block to get
Returns
the block

Definition at line 171 of file CRNAlto.cpp.

Description& crn::xml::Alto::GetDescription ( )
inline

Gets the global description part of the Alto (may be null)

Definition at line 91 of file CRNAlto.h.

const Description& crn::xml::Alto::GetDescription ( ) const
inline

Definition at line 92 of file CRNAlto.h.

Element & Alto::GetElement ( const Id id)

Returns an element

Warning
very slow
Exceptions
ExceptionNotFoundelement not found
Parameters
[in]idthe id of the element to get
Returns
the element

Definition at line 407 of file CRNAlto.cpp.

const Element & Alto::GetElement ( const Id id) const

Returns an element

Warning
very slow
Exceptions
ExceptionNotFoundelement not found
Parameters
[in]idthe id of the element to get
Returns
the element

Definition at line 472 of file CRNAlto.cpp.

Layout& crn::xml::Alto::GetLayout ( )
inline

Gets the layout description part of the Alto.

Definition at line 101 of file CRNAlto.h.

const Layout& crn::xml::Alto::GetLayout ( ) const
inline

Definition at line 102 of file CRNAlto.h.

Alto::Layout::Page & Alto::GetPage ( const Id id)

Returns a page

Warning
slow
Exceptions
ExceptionNotFoundpage not found
Parameters
[in]idthe id of the page to get
Returns
the page

Definition at line 63 of file CRNAlto.cpp.

const Alto::Layout::Page & Alto::GetPage ( const Id id) const

Returns a page

Warning
slow
Exceptions
ExceptionNotFoundpage not found
Parameters
[in]idthe id of the page to get
Returns
the page

Definition at line 81 of file CRNAlto.cpp.

Alto::Layout::Page::Space & Alto::GetSpace ( const Id id)

Returns a space

Warning
slow
Exceptions
ExceptionNotFoundspace not found
Parameters
[in]idthe id of the space to get
Returns
the space

Definition at line 99 of file CRNAlto.cpp.

const Alto::Layout::Page::Space & Alto::GetSpace ( const Id id) const

Returns a space

Warning
slow
Exceptions
ExceptionNotFoundspace not found
Parameters
[in]idthe id of the space to get
Returns
the space

Definition at line 122 of file CRNAlto.cpp.

Styles& crn::xml::Alto::GetStyles ( )
inline

Gets the styles description part of the Alto (may be null)

Definition at line 96 of file CRNAlto.h.

const Styles& crn::xml::Alto::GetStyles ( ) const
inline

Definition at line 97 of file CRNAlto.h.

Alto::Layout::Page::Space::TextBlock & Alto::GetTextBlock ( const Id id)

Returns a textblock

Warning
very slow
Exceptions
ExceptionNotFoundtextblock not found
Parameters
[in]idthe id of the textblock to get
Returns
the textblock

Definition at line 197 of file CRNAlto.cpp.

const Alto::Layout::Page::Space::TextBlock & Alto::GetTextBlock ( const Id id) const

Returns a textblock

Warning
very slow
Exceptions
ExceptionNotFoundtextblock not found
Parameters
[in]idthe id of the textblock to get
Returns
the textblock

Definition at line 226 of file CRNAlto.cpp.

Alto::Layout::Page::Space::TextBlock::TextLine & Alto::GetTextLine ( const Id id)

Returns a line

Warning
very slow
Exceptions
ExceptionNotFoundline not found
Parameters
[in]idthe id of the line to get
Returns
the line

Definition at line 255 of file CRNAlto.cpp.

const Alto::Layout::Page::Space::TextBlock::TextLine & Alto::GetTextLine ( const Id id) const

Returns a line

Warning
very slow
Exceptions
ExceptionNotFoundline not found
Parameters
[in]idthe id of the line to get
Returns
the line

Definition at line 289 of file CRNAlto.cpp.

Alto::Layout::Page::Space::TextBlock::TextLine::Word & Alto::GetWord ( const Id id)

Returns a word

Warning
very slow
Exceptions
ExceptionNotFoundword not found
Parameters
[in]idthe id of the word to get
Returns
the word

Definition at line 323 of file CRNAlto.cpp.

const Alto::Layout::Page::Space::TextBlock::TextLine::Word & Alto::GetWord ( const Id id) const

Returns a word

Warning
very slow
Exceptions
ExceptionNotFoundword not found
Parameters
[in]idthe id of the word to get
Returns
the word

Definition at line 365 of file CRNAlto.cpp.

Alto& crn::xml::Alto::operator= ( const Alto )
delete
Alto& crn::xml::Alto::operator= ( Alto &&  )
default

The documentation for this class was generated from the following files: