53 #ifndef _RNR_LOG_BOOK_H 54 #define _RNR_LOG_BOOK_H 56 #include <sys/types.h> 71 #include "rnr/rnrconfig.h" 125 Entry(
const std::string &strMark,
const std::string &strText);
206 #define BOOKMARKFUNC() bookmark(__func__) 215 LogBook(
const std::string strName =
"Log Book",
216 size_t uMaxEntries = MaxEntriesDft,
217 size_t uMaxEntryLen = MaxEntryLenDft);
251 LogBook &operator<<(
unsigned int val);
253 LogBook &operator<<(
unsigned long val);
254 LogBook &operator<<(
long long val);
255 LogBook &operator<<(
unsigned long long val);
256 LogBook &operator<<(
float val);
257 LogBook &operator<<(
double val);
258 LogBook &operator<<(
long double val);
263 LogBook &operator<<(
const char *val);
264 LogBook &operator<<(
void *val);
269 LogBook &operator<<(
const std::string &val);
280 LogBook &operator<<(std::ostream& (*pf)(std::ostream&));
281 LogBook &operator<<(std::ios& (*pf)(std::ios&));
282 LogBook &operator<<(std::ios_base& (*pf)(std::ios_base&));
302 size_t logEntry(
const std::string strText,
const std::string strMark =
"");
348 void setPending(
const std::string strText,
const std::string strMark);
382 size_t eraseToMark(
const std::string strMark,
int whence);
415 const Entry &
at(
const std::string &strMark)
const;
426 const Entry &
at(
const size_t index)
const;
438 const Entry &
at(
const size_t index,
int whence)
const;
482 const std::string &
textAt(
const std::string &strMark)
const 496 const std::string &
textAt(
const size_t index)
const 511 const std::string &
textAt(
const size_t index,
int whence)
const 539 size_t getBookMarks(BookMarkList &list,
int whence)
const;
590 return (
size_t)
m_book.size();
600 void resize(
size_t uMaxEntries);
704 std::ostream &
printLog(std::ostream &os)
const;
740 const std::string strMark,
745 friend std::ostream &operator<<(std::ostream &os,
const LogBook &log);
806 BookIter
findMark(
const std::string &strMark);
821 BookCIter
findMark(
const std::string &strMark)
const;
828 void sortMarks(BookMarkList &sorted)
const;
853 void prt(std::ostream &os,
size_t index0,
size_t index1)
const;
864 void rprt(std::ostream &os,
size_t index0,
size_t index1)
const;
884 extern std::ostream &operator<<(std::ostream &os,
const LogBook &log);
1008 #endif // _RNR_LOG_BOOK_H unsigned setFlags(const unsigned uFlags)
Set the current formatting flags.
std::ostream & printToMark(std::ostream &os, const std::string strMark, int endpt) const
Print the log book entires between the bookmark and the specified end point to the output stream...
static const size_t MaxEntryLenDft
max entry length (8192)
void clearFlags()
Clear alll current formatting flags.
std::string makeBookMarkLabel()
Generate a unique bookmark label.
size_t eraseEntries(size_t uNumEntries, int whence)
Erases a given number of entries from the log book.
BookDeq m_book
the log book
std::ostream & printLog(std::ostream &os) const
Print the entire log book to the output stream.
void erasePending()
Erase the pending log text and associated bookmark.
size_t eraseToMark(const std::string strMark, int whence)
Erases all entries from the log book up to the bookmark.
std::deque< Entry > BookDeq
book type
unsigned compAndFlags(const unsigned uFlags)
Apply one's Complement and And into the current formatting flags.
void ssflush()
Flush the pending text stream.
bool checkLen(size_t uEstLen=1)
Check the length of the pending entry.
static const unsigned FlagDebug
debug
lbmanip_fg_ setflags(const unsigned flags)
LogBook formatting flags parametric manipulator function.
BookDeq::const_reverse_iterator BookCRIter
const rev book iter
void limitSize()
Limit size of log book to defined limit.
const std::string & textAt(const size_t index, int whence) const
Get the entry text at relative index from whence.
void clear()
Clear the log book and bookmarks, along with any pending entry.
size_t m_uMaxEntries
maximum number of log entries
static const unsigned FlagOAllF
output all entry fields
void setName(const std::string &strName)
Set the name of the log book.
BookDeq::iterator BookIter
book iterator
static const unsigned FlagONum
output log entry number
std::string m_strText
entry text, empty if no text
size_t getBookMarks(BookMarkList &list, int whence) const
Get a sorted list of bookmark labels.
LogBook(const std::string strName="Log Book", size_t uMaxEntries=MaxEntriesDft, size_t uMaxEntryLen=MaxEntryLenDft)
Default initialization constructor.
size_t numOfTotalEver() const
Return the total number of entries ever added during log book's life.
std::string m_strMark
bookmark label
const Entry & lastEntry() const
Get the last (latest) log entry.
void rprt(std::ostream &os, size_t index0, size_t index1) const
Reverse print log book from index 1 to index 0, inclusive.
BookDeq::reverse_iterator BookRIter
reverse book iter
std::string m_strMark
entry bookmark, empty if no mark
const Entry & at(const std::string &strMark) const
Get the entry at the bookmark.
unsigned orFlags(const unsigned uFlags)
Or new flags into the current formatting flags.
BookMarkList::const_iterator BookMarkListCIter
bookmark const list iter
const std::string & textAt(const size_t index) const
Get the entry text at the index.
static const size_t MaxEntriesDft
max num entries default
void setPendingBookMark(const std::string strMark)
Set the pending bookmark.
size_t size() const
Return the number of logged entries in the log book.
static const unsigned FlagOTime
output log entry time
const std::string & getName() const
Get the name of the log book.
void rsortMarks(BookMarkList &sorted) const
Reverse sort bookmarks from newest to oldest.
static const unsigned FlagORev
output log reverse order
void erasePendingBookMark()
Erase the pending log bookmark.
void setPending(const std::string strText, const std::string strMark)
Set the pending log text and associated bookmark.
const Entry & operator[](const size_t index) const
Log book array index operator.
static const unsigned FlagOMark
output log entry bookmarks
LogBook & eoe(LogBook &log)
LogBook end-of-entry stream manipulator.
BookMarkList::iterator BookMarkListIter
bookmark list iterator
unsigned getFlags() const
Get the current formatting flags.
BookIter findMark(const std::string &strMark)
Find position it log book of the bookmarked entry.
std::stringstream m_ssText
pending text stream
const size_t max_size() const
Return the maximum number entries the log book can hold.
unsigned m_uFlags
formatting flags
BookDeq::const_iterator BookCIter
book const iterator
LogBook parametric formatting flags manipulator structure.
void copy(const LogBook &src)
Copy log book verbatim to this log book.
LogBook & bookmark(LogBook &log)
LogBook bookmark stream manipulator.
LogBook parametric bookmark stream manipulator structure.
static const int NEWEST
newest, most recent entries
void erasePendingText()
Erase the pending log text.
bool empty()
Test if entry is empty ("no entry" entry).
size_t logPending()
Log any pending entry into the log book.
void prt(std::ostream &os, size_t index0, size_t index1) const
Print log book from index 0 to index 1, inclusive.
virtual ~LogBook()
Destructor.
std::vector< BookMark > BookMarkList
bookmark list type
std::string m_strMark
pending bookmark label
timespec m_timestamp
entry timestamp
Entry & operator=(const Entry &rhs)
Assignment operator.
Entry()
Default contructor.
bool hasBookMark(const std::string &strMark) const
Test if bookmark exists in log book.
size_t logEntry(const std::string strText, const std::string strMark="")
Log the given entry into the log book.
EntryList::const_iterator EntryListCIter
entry const list iterator
static const int OLDEST
oldest entries
void sortMarks(BookMarkList &sorted) const
Sort bookmarks from oldest to newest.
const std::string & textAt(const std::string &strMark) const
Get the entry text at the bookmark.
bool m_bWarnThrottle
do [not] throttle warnings
virtual ~Entry()
Destructor.
std::vector< Entry > EntryList
entry list type
std::string m_strName
name of log
const std::string & lastText() const
Get the last (latest) log entry text.
static const unsigned FlagNone
no flags
void setPendingText(const std::string strText)
Set the pending log text.
size_t m_uTotalEver
total entries added during lifetime
void resize(size_t uMaxEntries)
Resize maximum size of log book.
EntryList::iterator EntryListIter
entry list iterator
size_t m_uMaxEntryLen
maximum entry length