Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
PointIdentifiers Class Reference

Hash table class that tracks point identifiers as the key, with a corresponding boolean value. More...

#include <PointIdentifiers.h>

Collaboration diagram for PointIdentifiers:
Collaboration graph

Public Member Functions

 PointIdentifiers ()
 Single constructor.
 
bool contains (const QString &pointIdentifier) const
 True if specified entry exists in the table.
 
int count () const
 Number of entries.
 
QString getKey (int i) const
 Get key for index.
 
bool getValue (const QString &pointIdentifier) const
 Get value for key.
 
void loadXml (QXmlStreamReader &reader)
 Load from serialized xml.
 
void saveXml (QXmlStreamWriter &writer) const
 Serialize table to xml.
 
void setKeyValue (const QString &pointIdentifier, bool value)
 Set key/value pair.
 

Detailed Description

Hash table class that tracks point identifiers as the key, with a corresponding boolean value.

Definition at line 19 of file PointIdentifiers.h.

Constructor & Destructor Documentation

◆ PointIdentifiers()

PointIdentifiers::PointIdentifiers ( )

Single constructor.

Definition at line 16 of file PointIdentifiers.cpp.

17{
18}

Member Function Documentation

◆ contains()

bool PointIdentifiers::contains ( const QString & pointIdentifier) const

True if specified entry exists in the table.

Definition at line 20 of file PointIdentifiers.cpp.

21{
22 LOG4CPP_DEBUG_S ((*mainCat)) << "PointIdentifiers::contains"
23 << " pointCount=" << m_pointIdentifiers.count();
24
25 return m_pointIdentifiers.contains (pointIdentifier);
26}
const int INNER_RADIUS_MIN
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ count()

int PointIdentifiers::count ( ) const

Number of entries.

Definition at line 28 of file PointIdentifiers.cpp.

29{
30 return m_pointIdentifiers.count();
31}

◆ getKey()

QString PointIdentifiers::getKey ( int i) const

Get key for index.

This involves copying of all the keys and is therefore slower than using key lookup, so should not be used for extremely numerous point sets

Definition at line 33 of file PointIdentifiers.cpp.

34{
35 ENGAUGE_ASSERT (i < m_pointIdentifiers.count());
36
37 QList<QString> keys = m_pointIdentifiers.keys();
38
39 return keys.at(i);
40}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...

◆ getValue()

bool PointIdentifiers::getValue ( const QString & pointIdentifier) const

Get value for key.

Definition at line 42 of file PointIdentifiers.cpp.

43{
44 ENGAUGE_ASSERT (m_pointIdentifiers.contains (pointIdentifier));
45
46 return m_pointIdentifiers [pointIdentifier];
47}

◆ loadXml()

void PointIdentifiers::loadXml ( QXmlStreamReader & reader)

Load from serialized xml.

Definition at line 49 of file PointIdentifiers.cpp.

50{
51 bool success = true;
52
53 // Read through each DOCUMENT_SERIALIZE_POINT_IDENTIFIER until end of DOCUMENT_SERIALIZE_POINT_IDENTIFIERS is encountered
54 while (loadNextFromReader (reader)) {
55
56 if (reader.atEnd() || reader.hasError ()) {
57 success = false;
58 break;
59 }
60
61 if ((reader.tokenType() == QXmlStreamReader::EndElement) &&
63 break;
64 }
65
66 // Not done yet
67 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
69
70 // This is an entry that we need to add
72
75
77
78 QString identifier = attributes.value (DOCUMENT_SERIALIZE_POINT_IDENTIFIER_NAME).toString();
80
81 m_pointIdentifiers [identifier] = value;
82 }
83 }
84 }
85
86 if (!success) {
87 reader.raiseError (QObject::tr ("Cannot read point identifiers"));
88 }
89}
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIERS
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER_VALUE
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER_NAME
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14

◆ saveXml()

void PointIdentifiers::saveXml ( QXmlStreamWriter & writer) const

Serialize table to xml.

Definition at line 91 of file PointIdentifiers.cpp.

92{
94 PointIdentifiersInternal::const_iterator itr;
95 for (itr = m_pointIdentifiers.begin(); itr != m_pointIdentifiers.end (); itr++) {
96 QString identifier = itr.key();
97 bool value = itr.value();
99 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_IDENTIFIER_NAME, identifier);
102 writer.writeEndElement();
103 }
104 writer.writeEndElement();
105}
const QString DOCUMENT_SERIALIZE_BOOL_FALSE

◆ setKeyValue()

void PointIdentifiers::setKeyValue ( const QString & pointIdentifier,
bool value )

Set key/value pair.

Definition at line 107 of file PointIdentifiers.cpp.

109{
110 m_pointIdentifiers [pointIdentifier] = value;
111}

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