Doxygen
Loading...
Searching...
No Matches
StyleData Struct Reference

#include <src/rtfstyle.h>

Public Member Functions

 StyleData ()=default
 
 StyleData (const std::string &reference, const std::string &definition)
 
bool setStyle (const std::string &command, const std::string &styleName)
 
const char * reference () const
 
const char * definition () const
 
uint32_t index () const
 

Private Attributes

uint32_t m_index = 0
 
std::string m_reference
 
std::string m_definition
 

Detailed Description

Definition at line 58 of file rtfstyle.h.

Constructor & Destructor Documentation

◆ StyleData() [1/2]

StyleData::StyleData ( )
default

References definition(), and reference().

◆ StyleData() [2/2]

StyleData::StyleData ( const std::string & reference,
const std::string & definition )

Definition at line 286 of file rtfstyle.cpp.

287{
288 reg::Match match;
289 if (reg::search(reference,match,s_clause))
290 {
291 m_index = static_cast<int>(std::stoul(match[1].str()));
292 }
293 else // error
294 {
295 m_index = 0;
296 }
299}
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition regex.cpp:748
bool match(std::string_view str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition regex.cpp:759
static const reg::Ex s_clause(R"(\\s(\d+)\s*)")
uint32_t m_index
Definition rtfstyle.h:74
const char * definition() const
Definition rtfstyle.h:70
const char * reference() const
Definition rtfstyle.h:69
std::string m_reference
Definition rtfstyle.h:75
std::string m_definition
Definition rtfstyle.h:76

References definition(), m_definition, m_index, m_reference, reference(), s_clause, and reg::search().

Member Function Documentation

◆ definition()

const char * StyleData::definition ( ) const
inline

Definition at line 70 of file rtfstyle.h.

70{ return m_definition.c_str(); }

References m_definition.

Referenced by RTFGenerator::beginRTFDocument(), StyleData(), and StyleData().

◆ index()

uint32_t StyleData::index ( ) const
inline

Definition at line 71 of file rtfstyle.h.

71{ return m_index; }

References m_index.

Referenced by setStyle().

◆ reference()

const char * StyleData::reference ( ) const
inline

Definition at line 69 of file rtfstyle.h.

69{ return m_reference.c_str(); }

References m_reference.

Referenced by RTFGenerator::beginRTFDocument(), RTFDocVisitor::getStyle(), StyleData(), and StyleData().

◆ setStyle()

bool StyleData::setStyle ( const std::string & command,
const std::string & styleName )

Definition at line 301 of file rtfstyle.cpp.

302{
303 reg::Match match;
304 if (!reg::search(command,match,s_clause))
305 {
306 err("Style sheet '%s' contains no '\\s' clause.\n{%s}\n", styleName.c_str(), command.c_str());
307 return false;
308 }
309 m_index = static_cast<int>(std::stoul(match[1].str()));
310
311 size_t index = command.find("\\sbasedon");
312 if (index!=std::string::npos)
313 {
314 m_reference = command.substr(0,index);
315 m_definition = command.substr(index);
316 }
317
318 return true;
319}
#define err(fmt,...)
Definition message.h:84
uint32_t index() const
Definition rtfstyle.h:71

References err, index(), m_definition, m_index, m_reference, s_clause, and reg::search().

Referenced by loadStylesheet().

Member Data Documentation

◆ m_definition

std::string StyleData::m_definition
private

Definition at line 76 of file rtfstyle.h.

Referenced by definition(), setStyle(), and StyleData().

◆ m_index

uint32_t StyleData::m_index = 0
private

Definition at line 74 of file rtfstyle.h.

Referenced by index(), setStyle(), and StyleData().

◆ m_reference

std::string StyleData::m_reference
private

Definition at line 75 of file rtfstyle.h.

Referenced by reference(), setStyle(), and StyleData().


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