libcrn
3.9.5
A document image processing library
|
Document utility class. More...
#include <CRNDocument.h>
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 | |
Document & | operator= (const Document &)=delete |
Document (Document &&)=default | |
Document & | operator= (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 Path & | GetBasename () const noexcept |
Gets the file base name of the document. More... | |
const String & | GetAuthor () const noexcept |
Gets the author of the document. More... | |
const String & | GetDate () const noexcept |
Gets the date of the document. More... | |
std::vector< Path > | GetFilenames () const |
Gets the list of the image files of the document. More... | |
std::vector< String > | GetViewIds () 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... | |
![]() | |
Savable (const String &s=U"") | |
Default constructor. More... | |
virtual | ~Savable () |
Destructor. More... | |
Savable (const Savable &)=delete | |
No copy construction allowed. More... | |
Savable & | operator= (const Savable &)=delete |
No assignment allowed. More... | |
Savable (Savable &&) noexcept | |
Savable & | operator= (Savable &&c) |
const String & | GetName () 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 Path & | GetFilename () 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... | |
![]() | |
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 | |
![]() | |
void | setFilename (const Path &fname) |
Overwrites the filename. More... | |
void | setFilename (Path &&fname) noexcept |
Overwrites the filename. More... | |
![]() | |
std::unique_ptr< std::mutex > | filelock |
Document utility class.
This class represents a document (book, volume, etc.).
Definition at line 52 of file CRNDocument.h.
Document::Document | ( | ) |
|
overridevirtualdefault |
|
delete |
|
default |
Adds a new image.
Adds a new image.
ExceptionInvalidArgument | null filename |
[in] | fname | The filename of the image to add to the views. |
Definition at line 71 of file CRNDocument.cpp.
|
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.
|
inline |
Returns an iterator after the last block.
Definition at line 158 of file CRNDocument.h.
|
inlinenoexcept |
Gets the author of the document.
Definition at line 75 of file CRNDocument.h.
|
inlinenoexcept |
Gets the file base name of the document.
Definition at line 73 of file CRNDocument.h.
|
inlinenoexcept |
Gets the date of the document.
Definition at line 77 of file CRNDocument.h.
|
static |
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
Definition at line 709 of file CRNDocument.cpp.
|
inlinenoexcept |
Returns the number of views.
Definition at line 112 of file CRNDocument.h.
|
staticnoexcept |
Definition at line 815 of file CRNDocument.cpp.
Returns a thumbnail of a view (cached)
Returns a thumbnail of a view (cached)
ExceptionDomain | index out of bounds |
ExceptionUninitialized | the document was never saved |
ExceptionIO | the image could not be loaded (file not found or invalid image format) |
[in] | index | the index of the view |
[in] | refresh | shall the thumbnail be recomputed? |
Definition at line 560 of file CRNDocument.cpp.
Returns a thumbnail of a view (cached)
Returns a thumbnail of a view (cached)
ExceptionNotFound | id not found |
ExceptionUninitialized | the document was never saved |
ExceptionIO | the image could not be loaded (file not found or invalid image format) |
[in] | id | the id of the view |
[in] | refresh | shall the thumbnail be recomputed? |
Definition at line 577 of file CRNDocument.cpp.
Returns the filename of a thumbnail of a view (cached)
Returns the filename of a thumbnail of a view (cached)
ExceptionDomain | index out of bounds |
ExceptionUninitialized | the document was never saved |
ExceptionIO | the image could not be loaded (file not found or invalid image format) |
ExceptionIO | cannot create directory |
[in] | index | the index of the view |
[in] | refresh | shall the thumbnail be recomputed? |
Definition at line 594 of file CRNDocument.cpp.
Returns the filename of a thumbnail of a view (cached)
Returns the filename of a thumbnail of a view (cached)
ExceptionNotFound | id not found |
ExceptionUninitialized | the document was never saved |
ExceptionIO | the image could not be loaded (file not found or invalid image format) |
[in] | id | the id of the view |
[in] | refresh | shall the thumbnail be recomputed? |
Definition at line 630 of file CRNDocument.cpp.
Path Document::GetThumbnailPath | ( | ) | const |
Returns the path of the thumbnails.
Returns the path of the thumbnails
Definition at line 518 of file CRNDocument.cpp.
|
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.
ExceptionDomain | index out of bounds |
ExceptionIO | XML file exists but cannot be accessed or has invalid structure |
ExceptionRuntime | the XML file does not fit the block's image |
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | num | The index of the view. |
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
ExceptionNotFound | id not found |
ExceptionIO | XML file exists but cannot be accessed or has invalid structure |
ExceptionRuntime | the XML file does not fit the block's image |
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | id | the id of the view |
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
ExceptionNotFound | filename not found |
ExceptionIO | XML file exists but cannot be accessed or has invalid structure |
ExceptionRuntime | the XML file does not fit the block's image |
ExceptionIO | cannot open image |
ExceptionRuntime | unsupported image format (not BW, Gray nor RGB) |
[in] | fname | the file name of the view |
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
ExceptionDomain | index out of bounds |
[in] | num | the index of the view |
Definition at line 325 of file CRNDocument.cpp.
Returns the filename of a view.
Returns the filename of a view
ExceptionNotFound | id not found |
[in] | id | the id 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
ExceptionDomain | index out of bounds |
[in] | num | the index of the view |
Definition at line 293 of file CRNDocument.cpp.
Returns the id of a view.
Returns the id of a view
ExceptionNotFound | filename not found |
[in] | fname | the file name 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
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
ExceptionNotFound | id not found |
[in] | id | the id 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
ExceptionNotFound | filename not found |
[in] | fname | the file name the view |
Definition at line 276 of file CRNDocument.cpp.
Inserts a new image.
Inserts a new image.
ExceptionInvalidArgument | null filename |
ExceptionDomain | index out of bounds |
[in] | fname | The filename of the image to add to the views. |
[in] | pos | the position where the image will be added |
Definition at line 103 of file CRNDocument.cpp.
void Document::RemoveView | ( | const Path & | fname | ) |
Removes a view.
Removes a view.
If multiple views have the same filename, only the first is removed.
ExceptionNotFound | filename not found |
[in] | fname | The 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.
ExceptionDomain | index out of bounds |
[in] | num | The 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.
ExceptionNotFound | id not found |
[in] | id | The 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
ExceptionDimension | changeset is of wrong size |
ExceptionLogic | changeset contains duplicates |
ExceptionDomain | changeset contains values out of bounds |
[in] | from | a vector containing the previous index of each view |
Definition at line 355 of file CRNDocument.cpp.
void Document::ReorderViewsTo | ( | const std::vector< size_t > & | to | ) |
Reorders the views.
Reorders the views
ExceptionDimension | changeset is of wrong size |
ExceptionLogic | changeset contains duplicates |
ExceptionDomain | changeset contains values out of bounds |
[in] | to | a vector containing the new index of each view |
Definition at line 395 of file CRNDocument.cpp.
|
inline |
Sets the author of the document.
Definition at line 68 of file CRNDocument.h.
|
inline |
Sets the base name of the document if any.
Definition at line 66 of file CRNDocument.h.
|
inline |
Sets the date of the document.
Definition at line 70 of file CRNDocument.h.
|
static |
Definition at line 825 of file CRNDocument.cpp.
|
static |
Definition at line 819 of file CRNDocument.cpp.