Public Member Functions | Public Attributes | Static Public Attributes | List of all members
StyleData Struct Reference

#include <rtfstyle.h>

Public Member Functions

 StyleData (const char *reference, const char *definition)
 
 ~StyleData ()
 
bool setStyle (const char *s, const char *styleName)
 

Public Attributes

unsigned index
 
char * reference
 
char * definition
 

Static Public Attributes

static const QRegExp s_clause
 

Detailed Description

Definition at line 59 of file rtfstyle.h.

Constructor & Destructor Documentation

StyleData::StyleData ( const char *  reference,
const char *  definition 
)

Definition at line 341 of file rtfstyle.cpp.

342 {
343  int start = s_clause.match(reference); ASSERT(start >= 0);
344  reference += start;
345  index = (int)atol(reference + 2); ASSERT(index > 0);
346 
347  ASSERT(reference != 0);
348  size_t size = 1 + strlen(reference);
349  memcpy(this->reference = new char[size], reference, size);
350 
351  ASSERT(definition != 0);
352  size = 1 + strlen(definition);
353  memcpy(this->definition = new char[size], definition, size);
354 }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
unsigned index
Definition: rtfstyle.h:66
int match(const QCString &str, int index=0, int *len=0, bool indexIsStart=TRUE) const
Definition: qregexp.cpp:649
char * definition
Definition: rtfstyle.h:68
char * reference
Definition: rtfstyle.h:67
static const QRegExp s_clause
Definition: rtfstyle.h:74
#define ASSERT(x)
Definition: qglobal.h:590
StyleData::~StyleData ( )

Definition at line 356 of file rtfstyle.cpp.

357 {
358  delete[] reference;
359  delete[] definition;
360 }
char * definition
Definition: rtfstyle.h:68
char * reference
Definition: rtfstyle.h:67

Member Function Documentation

bool StyleData::setStyle ( const char *  s,
const char *  styleName 
)

Definition at line 362 of file rtfstyle.cpp.

363 {
364  static const QRegExp subgroup("^{[^}]*}\\s*");
365  static const QRegExp any_clause("^\\\\[a-z][a-z0-9-]*\\s*");
366 
367  int len = 0; // length of a particular RTF formatting control
368  int ref_len = 0; // length of the whole formatting section of a style
369  int start = s_clause.match(s, 0, &len);
370  if (start < 0)
371  {
372  err("Style sheet '%s' contains no '\\s' clause.\n{%s}\n", styleName, s);
373  return FALSE;
374  }
375  s += start;
376  index = (int)atol(s + 2); ASSERT(index > 0);
377 
378  // search for the end of pure formatting codes
379  const char* end = s + len;
380  ref_len = len;
381  bool haveNewDefinition = TRUE;
382  for(;;)
383  {
384  if (*end == '{')
385  {
386  // subgroups are used for \\additive
387  if (0 != subgroup.match(end, 0, &len))
388  break;
389  else
390  {
391  end += len;
392  ref_len += len;
393  }
394  }
395  else if (*end == '\\')
396  {
397  if (0 == qstrncmp(end, "\\snext", 6))
398  break;
399  if (0 == qstrncmp(end, "\\sbasedon", 9))
400  break;
401  if (0 != any_clause.match(end, 0, &len))
402  break;
403  end += len;
404  ref_len += len;
405  }
406  else if (*end == 0)
407  { // no style-definition part, keep default value
408  haveNewDefinition = FALSE;
409  break;
410  }
411  else // plain name without leading \\snext
412  break;
413  }
414  delete[] reference;
415  reference = new char[ref_len + 1];
416  memcpy(reference, s, ref_len);
417  reference[ref_len] = 0;
418  if (haveNewDefinition)
419  {
420  delete[] definition;
421  size_t size = 1 + strlen(end);
422  definition = new char[size];
423  memcpy(definition, end, size);
424  }
425  return TRUE;
426 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
const bool FALSE
Definition: qglobal.h:370
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
unsigned index
Definition: rtfstyle.h:66
void err(const char *fmt,...)
Definition: message.cpp:226
int match(const QCString &str, int index=0, int *len=0, bool indexIsStart=TRUE) const
Definition: qregexp.cpp:649
char * definition
Definition: rtfstyle.h:68
char * reference
Definition: rtfstyle.h:67
static const QRegExp s_clause
Definition: rtfstyle.h:74
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
#define ASSERT(x)
Definition: qglobal.h:590

Member Data Documentation

char* StyleData::definition

Definition at line 68 of file rtfstyle.h.

unsigned StyleData::index

Definition at line 66 of file rtfstyle.h.

char* StyleData::reference

Definition at line 67 of file rtfstyle.h.

const QRegExp StyleData::s_clause
static

Definition at line 74 of file rtfstyle.h.


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