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 | Static Public Member Functions | List of all members
crn::Document Class Reference

Document utility class. More...

#include <CRNDocument.h>

+ Inheritance diagram for crn::Document:
+ Collaboration diagram for crn::Document:

Classes

class  iterator
 Iterator on the blocks of the document. More...
 

Public Member Functions

 Document ()
 Constructor. More...
 
virtual ~Document () override
 Destructor. More...
 
 Document (const Document &)=delete
 
Documentoperator= (const Document &)=delete
 
 Document (Document &&)=default
 
Documentoperator= (Document &&)=default
 
void SetBasename (const Path &s)
 Sets the base name of the document if any. More...
 
void SetAuthor (const String &s)
 Sets the author of the document. More...
 
void SetDate (const String &s)
 Sets the date of the document. More...
 
const PathGetBasename () const noexcept
 Gets the file base name of the document. More...
 
const StringGetAuthor () const noexcept
 Gets the author of the document. More...
 
const StringGetDate () const noexcept
 Gets the date of the document. More...
 
std::vector< PathGetFilenames () const
 Gets the list of the image files of the document. More...
 
std::vector< StringGetViewIds () const
 Gets the list of the view ids of the document. More...
 
String AddView (const Path &fname)
 Adds a new image. More...
 
String InsertView (const Path &fname, size_t pos)
 Inserts a new image. More...
 
void RemoveView (const Path &fname)
 Removes a view. More...
 
void RemoveView (size_t num)
 Removes a view. More...
 
void RemoveView (const String &id)
 Removes a view. More...
 
SBlock GetView (size_t num) const
 Returns a pointer to a view. More...
 
SBlock GetView (const String &id) const
 Returns a pointer to a view. More...
 
SBlock GetView (const Path &fname) const
 Returns a pointer to a view. More...
 
size_t GetViewIndex (const String &id) const
 Returns the index of a view. More...
 
size_t GetViewIndex (const Path &fname) const
 Returns the index of a view. More...
 
String GetViewId (size_t num) const
 Returns the id of a view. More...
 
String GetViewId (const Path &fname) const
 Returns the id of a view. More...
 
Path GetViewFilename (size_t num) const
 Returns the filename of a view. More...
 
Path GetViewFilename (const String &id) const
 Returns the filename of a view. More...
 
size_t GetNbViews () const noexcept
 Returns the number of views. More...
 
void ReorderViewsFrom (const std::vector< size_t > &from)
 Reorders the views. More...
 
void ReorderViewsTo (const std::vector< size_t > &to)
 Reorders the views. More...
 
void Clear ()
 Removes all views and unsets all data. More...
 
Path GetThumbnailPath () const
 Returns the path of the thumbnails. More...
 
UImage GetThumbnail (size_t index, bool refresh=false) const
 Returns a thumbnail of a view (cached) More...
 
UImage GetThumbnail (const String &id, bool refresh=false) const
 Returns a thumbnail of a view (cached) More...
 
Path GetThumbnailFilename (size_t index, bool refresh=false) const
 Returns the filename of a thumbnail of a view (cached) More...
 
Path GetThumbnailFilename (const String &id, bool refresh=false) const
 Returns the filename of a thumbnail of a view (cached) More...
 
iterator begin () const
 Returns an iterator to the first block. More...
 
iterator end () const
 Returns an iterator after the last block. More...
 
- Public Member Functions inherited from crn::Savable
 Savable (const String &s=U"")
 Default constructor. More...
 
virtual ~Savable ()
 Destructor. More...
 
 Savable (const Savable &)=delete
 No copy construction allowed. More...
 
Savableoperator= (const Savable &)=delete
 No assignment allowed. More...
 
 Savable (Savable &&) noexcept
 
Savableoperator= (Savable &&c)
 
const StringGetName () const
 Returns the name of the object. More...
 
void SetName (const String &s)
 Sets the name of the object. More...
 
void SetName (String &&s) noexcept
 Sets the name of the object. More...
 
void SetUserData (const String &key, SObject value)
 Adds or replaces a user data. More...
 
bool IsUserData (const String &key) const
 Tests if a user data key exists. More...
 
SObject GetUserData (const String &key)
 Gets a user data by key. More...
 
String GetUserDataKey (const SObject &value) const
 Gets a user data key by value. More...
 
const SObject GetUserData (const String &key) const
 Gets a user data by key. More...
 
void DeleteUserData (const String &key)
 Deletes a user data entry and frees the value. More...
 
void ClearUserData ()
 Deletes all user data entries. More...
 
 Savable (const String &s, const Path &fname)
 Constructor from file name. More...
 
void Load (const Path &fname)
 Loads the object from an XML file (Safe) More...
 
void Save (const Path &fname)
 Saves the object to an XML file (Safe) More...
 
void Save ()
 Saves the object to an already set XML file. More...
 
const PathGetFilename () const noexcept
 Returns the file name of the object. More...
 
void deserialize_internal_data (xml::Element &el)
 Initializes some internal data from an XML element. More...
 
void serialize_internal_data (xml::Element &el) const
 Dumps some internal data to an XML element. More...
 
- Public Member Functions inherited from crn::Object
virtual ~Object ()=default
 

Static Public Member Functions

static Path GetDefaultDirName ()
 Returns the default directory where the documents are saved. More...
 
static size_t GetThumbWidth () noexcept
 
static size_t GetThumbHeight () noexcept
 
static void SetThumbWidth (size_t w)
 
static void SetThumbHeight (size_t h)
 

Additional Inherited Members

- Protected Member Functions inherited from crn::Savable
void setFilename (const Path &fname)
 Overwrites the filename. More...
 
void setFilename (Path &&fname) noexcept
 Overwrites the filename. More...
 
- Protected Attributes inherited from crn::Savable
std::unique_ptr< std::mutex > filelock
 

Detailed Description

Document utility class.

This class represents a document (book, volume, etc.).

Author
Yann LEYDIER
Date
25 August 2006
Version
0.2

Definition at line 52 of file CRNDocument.h.

Constructor & Destructor Documentation

Document::Document ( )

Constructor.

Default constructor

Definition at line 46 of file CRNDocument.cpp.

Document::~Document ( )
overridevirtualdefault

Destructor.

Destructor

Definition at line 58 of file CRNDocument.cpp.

crn::Document::Document ( const Document )
delete
Document::Document ( Document &&  )
default

Member Function Documentation

String Document::AddView ( const Path fname)

Adds a new image.

Adds a new image.

Exceptions
ExceptionInvalidArgumentnull filename
Parameters
[in]fnameThe filename of the image to add to the views.
Returns
the id of the new view

Definition at line 71 of file CRNDocument.cpp.

iterator crn::Document::begin ( ) const
inline

Returns an iterator to the first block.

Definition at line 156 of file CRNDocument.h.

void Document::Clear ( )

Removes all views and unsets all data.

Removes all views and unsets all data

Definition at line 427 of file CRNDocument.cpp.

iterator crn::Document::end ( ) const
inline

Returns an iterator after the last block.

Definition at line 158 of file CRNDocument.h.

const String& crn::Document::GetAuthor ( ) const
inlinenoexcept

Gets the author of the document.

Definition at line 75 of file CRNDocument.h.

const Path& crn::Document::GetBasename ( ) const
inlinenoexcept

Gets the file base name of the document.

Definition at line 73 of file CRNDocument.h.

const String& crn::Document::GetDate ( ) const
inlinenoexcept

Gets the date of the document.

Definition at line 77 of file CRNDocument.h.

Path Document::GetDefaultDirName ( )
static

Returns the default directory where the documents are saved.

Returns the default directory where the documents are saved

Returns
the default directory where the documents are saved

Definition at line 681 of file CRNDocument.cpp.

std::vector< Path > Document::GetFilenames ( ) const

Gets the list of the image files of the document.

Gets the list of the image files of the document

Returns
a vector containing the file names

Definition at line 709 of file CRNDocument.cpp.

size_t crn::Document::GetNbViews ( ) const
inlinenoexcept

Returns the number of views.

Definition at line 112 of file CRNDocument.h.

size_t Document::GetThumbHeight ( )
staticnoexcept

Definition at line 815 of file CRNDocument.cpp.

UImage Document::GetThumbnail ( size_t  index,
bool  refresh = false 
) const

Returns a thumbnail of a view (cached)

Returns a thumbnail of a view (cached)

Exceptions
ExceptionDomainindex out of bounds
ExceptionUninitializedthe document was never saved
ExceptionIOthe image could not be loaded (file not found or invalid image format)
Parameters
[in]indexthe index of the view
[in]refreshshall the thumbnail be recomputed?
Returns
a thumbnail image

Definition at line 560 of file CRNDocument.cpp.

UImage Document::GetThumbnail ( const String id,
bool  refresh = false 
) const

Returns a thumbnail of a view (cached)

Returns a thumbnail of a view (cached)

Exceptions
ExceptionNotFoundid not found
ExceptionUninitializedthe document was never saved
ExceptionIOthe image could not be loaded (file not found or invalid image format)
Parameters
[in]idthe id of the view
[in]refreshshall the thumbnail be recomputed?
Returns
a thumbnail image

Definition at line 577 of file CRNDocument.cpp.

Path Document::GetThumbnailFilename ( size_t  index,
bool  refresh = false 
) const

Returns the filename of a thumbnail of a view (cached)

Returns the filename of a thumbnail of a view (cached)

Exceptions
ExceptionDomainindex out of bounds
ExceptionUninitializedthe document was never saved
ExceptionIOthe image could not be loaded (file not found or invalid image format)
ExceptionIOcannot create directory
Parameters
[in]indexthe index of the view
[in]refreshshall the thumbnail be recomputed?
Returns
the filename of a thumbnail image

Definition at line 594 of file CRNDocument.cpp.

Path Document::GetThumbnailFilename ( const String id,
bool  refresh = false 
) const

Returns the filename of a thumbnail of a view (cached)

Returns the filename of a thumbnail of a view (cached)

Exceptions
ExceptionNotFoundid not found
ExceptionUninitializedthe document was never saved
ExceptionIOthe image could not be loaded (file not found or invalid image format)
Parameters
[in]idthe id of the view
[in]refreshshall the thumbnail be recomputed?
Returns
the filename of a thumbnail image

Definition at line 630 of file CRNDocument.cpp.

Path Document::GetThumbnailPath ( ) const

Returns the path of the thumbnails.

Returns the path of the thumbnails

Returns
the path of the thumbnails

Definition at line 518 of file CRNDocument.cpp.

size_t Document::GetThumbWidth ( )
staticnoexcept

Definition at line 811 of file CRNDocument.cpp.

SBlock Document::GetView ( size_t  num) const

Returns a pointer to a view.

Returns a pointer to a view.

Its counter is incremented.

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOXML file exists but cannot be accessed or has invalid structure
ExceptionRuntimethe XML file does not fit the block's image
ExceptionIOcannot open image
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
Parameters
[in]numThe index of the view.
Returns
A pointer to a block

Definition at line 195 of file CRNDocument.cpp.

SBlock Document::GetView ( const String id) const

Returns a pointer to a view.

Returns a pointer to a view

Exceptions
ExceptionNotFoundid not found
ExceptionIOXML file exists but cannot be accessed or has invalid structure
ExceptionRuntimethe XML file does not fit the block's image
ExceptionIOcannot open image
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
Parameters
[in]idthe id of the view
Returns
a pointer to the view's block

Definition at line 228 of file CRNDocument.cpp.

SBlock Document::GetView ( const Path fname) const

Returns a pointer to a view.

Returns a pointer to a view

Exceptions
ExceptionNotFoundfilename not found
ExceptionIOXML file exists but cannot be accessed or has invalid structure
ExceptionRuntimethe XML file does not fit the block's image
ExceptionIOcannot open image
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
Parameters
[in]fnamethe file name of the view
Returns
a pointer to the view's block

Definition at line 245 of file CRNDocument.cpp.

Path Document::GetViewFilename ( size_t  num) const

Returns the filename of a view.

Returns the filename of a view

Exceptions
ExceptionDomainindex out of bounds
Parameters
[in]numthe index of the view
Returns
the filename of the view

Definition at line 325 of file CRNDocument.cpp.

Path Document::GetViewFilename ( const String id) const

Returns the filename of a view.

Returns the filename of a view

Exceptions
ExceptionNotFoundid not found
Parameters
[in]idthe id of the view
Returns
the filename of the view

Definition at line 340 of file CRNDocument.cpp.

String Document::GetViewId ( size_t  num) const

Returns the id of a view.

Returns the id of a view

Exceptions
ExceptionDomainindex out of bounds
Parameters
[in]numthe index of the view
Returns
the id of the view

Definition at line 293 of file CRNDocument.cpp.

String Document::GetViewId ( const Path fname) const

Returns the id of a view.

Returns the id of a view

Exceptions
ExceptionNotFoundfilename not found
Parameters
[in]fnamethe file name of the view
Returns
the id of the view

Definition at line 308 of file CRNDocument.cpp.

std::vector< String > Document::GetViewIds ( ) const

Gets the list of the view ids of the document.

Gets the list of the view ids of the document

Returns
a vector containing the view ids

Definition at line 722 of file CRNDocument.cpp.

size_t Document::GetViewIndex ( const String id) const

Returns the index of a view.

Returns the index of a view

Exceptions
ExceptionNotFoundid not found
Parameters
[in]idthe id the view
Returns
the index of the view

Definition at line 258 of file CRNDocument.cpp.

size_t Document::GetViewIndex ( const Path fname) const

Returns the index of a view.

Returns the index of a view

Exceptions
ExceptionNotFoundfilename not found
Parameters
[in]fnamethe file name the view
Returns
the index of the view

Definition at line 276 of file CRNDocument.cpp.

String Document::InsertView ( const Path fname,
size_t  pos 
)

Inserts a new image.

Inserts a new image.

Exceptions
ExceptionInvalidArgumentnull filename
ExceptionDomainindex out of bounds
Parameters
[in]fnameThe filename of the image to add to the views.
[in]posthe position where the image will be added
Returns
the id of the new view

Definition at line 103 of file CRNDocument.cpp.

Document& crn::Document::operator= ( const Document )
delete
Document & Document::operator= ( Document &&  )
default
void Document::RemoveView ( const Path fname)

Removes a view.

Removes a view.

If multiple views have the same filename, only the first is removed.

Exceptions
ExceptionNotFoundfilename not found
Parameters
[in]fnameThe filename of the image to remove from the views.

Definition at line 130 of file CRNDocument.cpp.

void Document::RemoveView ( size_t  num)

Removes a view.

Removes a view.

Exceptions
ExceptionDomainindex out of bounds
Parameters
[in]numThe index of the view to remove.

Definition at line 147 of file CRNDocument.cpp.

void Document::RemoveView ( const String id)

Removes a view.

Removes a view.

Exceptions
ExceptionNotFoundid not found
Parameters
[in]idThe id of the view to remove.

Definition at line 175 of file CRNDocument.cpp.

void Document::ReorderViewsFrom ( const std::vector< size_t > &  from)

Reorders the views.

Reorders the views

Exceptions
ExceptionDimensionchangeset is of wrong size
ExceptionLogicchangeset contains duplicates
ExceptionDomainchangeset contains values out of bounds
Parameters
[in]froma vector containing the previous index of each view
Returns
true if success, false else

Definition at line 355 of file CRNDocument.cpp.

void Document::ReorderViewsTo ( const std::vector< size_t > &  to)

Reorders the views.

Reorders the views

Exceptions
ExceptionDimensionchangeset is of wrong size
ExceptionLogicchangeset contains duplicates
ExceptionDomainchangeset contains values out of bounds
Parameters
[in]toa vector containing the new index of each view
Returns
true if success, false else

Definition at line 395 of file CRNDocument.cpp.

void crn::Document::SetAuthor ( const String s)
inline

Sets the author of the document.

Definition at line 68 of file CRNDocument.h.

void crn::Document::SetBasename ( const Path s)
inline

Sets the base name of the document if any.

Definition at line 66 of file CRNDocument.h.

void crn::Document::SetDate ( const String s)
inline

Sets the date of the document.

Definition at line 70 of file CRNDocument.h.

void Document::SetThumbHeight ( size_t  h)
static

Definition at line 825 of file CRNDocument.cpp.

void Document::SetThumbWidth ( size_t  w)
static

Definition at line 819 of file CRNDocument.cpp.


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