Skip to main content

The DotAttributes Class Reference

Class representing an attribute list of a dot graph object. More...

Declaration

class DotAttributes { ... }

Included Headers

Public Constructors Index

DotAttributes (const QCString &input)

Creates an instance of a DotAttribute list given its initial string representation. More...

Public Member Functions Index

QCStringstr () const

Return the string representation of the attribute list. More...

voidupdateValue (const QCString &key, const QCString &inpValue)

Private Member Attributes Index

QCStringm_input

Description

Class representing an attribute list of a dot graph object.

Definition at line 26 of file dotattributes.h.

Public Constructors

DotAttributes()

DotAttributes::DotAttributes (const QCString & input)
inline

Creates an instance of a DotAttribute list given its initial string representation.

Definition at line 30 of file dotattributes.h.

30 DotAttributes(const QCString &input) : m_input(input) {}

Reference m_input.

Public Member Functions

str()

QCString DotAttributes::str ()
inline

Return the string representation of the attribute list.

Definition at line 33 of file dotattributes.h.

33 QCString str() const { return m_input; }

Reference m_input.

Referenced by Config::updateObsolete.

updateValue()

void DotAttributes::updateValue (const QCString & key, const QCString & inpValue)
inline

update a given attribute with a new value. If the attribute is not found a new attribute will be appended.

Definition at line 37 of file dotattributes.h.

37 void updateValue(const QCString &key,const QCString &inpValue)
38 {
39 // look for key\s*=
40 const std::string regStr = key.str()+R"(\s*=)";
41 const reg::Ex re { regStr };
42 reg::Match match;
43 std::string s = m_input.str();
44 if (reg::search(s,match,re)) // replace existing attribute
45 {
46 size_t len = s.length();
47 size_t startPos = match.position()+match.length(); // position after =
48 size_t pos = startPos;
49 while (pos<len && qisspace(s[pos])) pos++;
50 if (pos<len && s[pos]=='"') // quoted value, search for end quote, ignoring escaped quotes
51 {
52 char pc=s[pos];
53 pos++; // skip over start quote
54 while (pos<len && (s[pos]!='"' || (s[pos]=='"' && pc=='\\'))) pc=s[pos++];
55 if (pos<len) pos++; // skip over end quote
56 }
57 else // unquoted value, search for attribute separator (space,comma, or semicolon)
58 {
59 while (pos<len && s[pos]!=',' && s[pos]!=';' && !qisspace(s[pos])) pos++;
60 }
61 QCString value;
62 if (inpValue.isEmpty())
63 {
64 value = m_input.mid(startPos,pos-startPos);
65 }
66 else
67 {
68 value = inpValue;
69 }
70 // pos is now the position after the value, so replace the part between [start..pos) with the new value
71 m_input=m_input.left(startPos)+value.quoted()+m_input.mid(pos);
72 }
73 else // append new attribute
74 {
75 if (!inpValue.isEmpty())
76 {
77 if (!m_input.isEmpty()) m_input+=",";
78 m_input+=key+"="+inpValue.quoted();
79 }
80 }
81 }

References QCString::isEmpty, m_input, qisspace, QCString::quoted, reg::search and QCString::str.

Referenced by updateAttribute.

Private Member Attributes

m_input

QCString DotAttributes::m_input

Definition at line 84 of file dotattributes.h.

Referenced by DotAttributes, str and updateValue.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.