Code Documentation 3.4
Social Network Visualizer
Loading...
Searching...
No Matches
Parser Class Reference

Defines a class for network file loading and parsing. More...

#include <parser.h>

Inheritance diagram for Parser:
Collaboration diagram for Parser:

Classes

struct  ParseConfig
 ParseConfig boundary - the immutable config object. More...
 

Signals

void finished (QString)
 

Public Member Functions

 Parser ()
 
 ~Parser ()
 
void setParseSink (SocNetV::IO::IGraphParseSink *sink)
 
void setOwnedParseSink (std::unique_ptr< SocNetV::IO::IGraphParseSink > sink)
 
void load (const QString &fileName, const QString &codecName, const int &defNodeSize, const QString &defNodeColor, const QString &defNodeShape, const QString &defNodeNumberColor, const int &defNodeNumberSize, const QString &defNodeLabelColor, const int &defNodeLabelSize, const QString &defEdgeColor, const int &canvasWidth, const int &canvasHeight, const int &format, const QString &delim=QString(), const int &sm_mode=1, const bool &sm_has_labels=false)
 Loads the data of the given network file, and calls the relevant method to parse it.
 
bool parseAsPajek (const QByteArray &rawData)
 Parse a Pajek-formatted network from raw bytes.
 
bool parseAsAdjacency (const QByteArray &rawData, const ParseConfig &cfg, const QString &delimiter)
 
bool parseAsDot (const QByteArray &rawData)
 Parses the data as GraphViz (DOT) formatted network.
 
QString preprocessDotContent (const QString &dotContent)
 Preprocesses the content of a DOT file to normalize its formatting, improve parsing and readability.
 
bool parseAsGraphML (const QByteArray &rawData)
 Parses the data as GraphML (not GML) formatted network.
 
bool parseAsGML (const QByteArray &rawData)
 Parses the data as GML formatted network.
 
bool parseAsDL (const QByteArray &rawData)
 Parses the given raw data as DL formatted (UCINET) data.
 
bool parseAsEdgeListSimple (const QByteArray &rawData, const QString &delimiter)
 Parses the data as simple edgelist formatted.
 
bool parseAsEdgeListWeighted (const QByteArray &rawData, const QString &delimiter)
 Parses the data as weighted edgelist formatted network.
 
bool parseAsTwoModeSociomatrix (const QByteArray &rawData)
 Parses a two-mode (bipartite) sociomatrix file (.2sm / .aff).
 
bool readDLKeywords (QStringList &strList, int &N, int &NM, int &NR, int &NC, bool &fullmatrixFormat, bool &edgelist1Format, bool &diagonalPresent)
 Reads and parses DL keywords from a given QStringList.
 
void readDotProperties (QString str, qreal &, QString &label, QString &shape, QString &color, QString &fontName, QString &fontColor)
 Reads the properties of a dot element with improved handling of quoted values.
 
bool readGraphML (QXmlStreamReader &)
 Checks the xml token name and calls the appropriate function.
 
void readGraphMLElementGraph (QXmlStreamReader &)
 Reads a graph definition.
 
void readGraphMLElementNode (QXmlStreamReader &)
 Reads basic node attributes and sets the nodeNumber.
 
void endGraphMLElementNode (QXmlStreamReader &)
 Signals to create a new node.
 
void readGraphMLElementEdge (QXmlStreamAttributes &)
 Reads basic edge creation properties.
 
void endGraphMLElementEdge (QXmlStreamReader &)
 Signals for a new edge to be created/added.
 
void readGraphMLElementData (QXmlStreamReader &)
 Reads data for edges and nodes.
 
void readGraphMLElementUnknown (QXmlStreamReader &)
 Trivial call for unknown elements.
 
void readGraphMLElementKey (QXmlStreamAttributes &)
 Reads a key definition.
 
void readGraphMLElementDefaultValue (QXmlStreamReader &)
 Reads default key values.
 
void readGraphMLElementNodeGraphics (QXmlStreamReader &)
 Reads node graphics data and properties: label, color, shape, size, coordinates, etc.
 
void readGraphMLElementEdgeGraphics (QXmlStreamReader &)
 Reads edge graphics data and properties: path, linestyle,width, arrows, etc.
 
void createMissingNodeEdges ()
 Creates any missing node edges.
 
bool isComment (QString str)
 Helper. Checks if the string parameter is a comment (starts with a known char, i.e #).
 
void createRandomNodes (const int &fixedNum=1, const QString &label=QString(), const int &newNodes=1)
 Signals to create either a single new node (numbered fixedNum) or multiple new nodes (numbered from 1 to to newNodes)
 

Static Public Member Functions

static QString normalizeQuotedIdentifier (const QString &s)
 Normalizes a quoted identifier from external network formats.
 

Private Member Functions

bool validateAndInitialize (const QByteArray &rawData, const QString &delimiter, const bool &sm_has_labels, QStringList &nodeLabels)
 
void resetCounters ()
 
bool doParseAdjacency (QTextStream &ts, const QString &delimiter, const QStringList &nodeLabels)
 
void createNodeWithDefaults (int nodeIndex, const QString &label)
 
bool createEdgesForRow (const QStringList &currentRow, int rowIndex)
 
bool containsReservedKeywords (const QString &str) const
 

Private Attributes

SocNetV::IO::IGraphParseSinkm_parseSink = nullptr
 
std::unique_ptr< SocNetV::IO::IGraphParseSinkm_ownedParseSink
 
QHash< QString, int > nodeHash
 
QHash< QString, QString > keyFor
 
QHash< QString, QString > keyName
 
QHash< QString, QString > keyType
 
QHash< QString, QString > keyDefaultValue
 
QHash< QString, QString > edgesMissingNodesHash
 
QStringList edgeMissingNodesList
 
QStringList edgeMissingNodesListData
 
QStringList relationsList
 
QMultiMap< int, int > firstModeMultiMap
 
QMultiMap< int, int > secondModeMultiMap
 
QXmlStreamReader * xml
 
QString fileDirPath
 
QString m_textCodecName
 
QString networkName
 
QString initNodeColor
 
QString initNodeShape
 
QString initNodeCustomIcon
 
QString initNodeNumberColor
 
QString initNodeLabelColor
 
QString initEdgeColor
 
QString initEdgeLabel
 
QString delimiter
 
QString errorMessage
 
QString nodeColor
 
QString edgeColor
 
QString edgeType
 
QString nodeShape
 
QString nodeLabel
 
QString edgeLabel
 
QString nodeIconPath
 
QString nodeNumberColor
 
QString nodeLabelColor
 
QHash< QString, QString > nodeCustomAttributes
 
QHash< QString, QString > initNodeCustomAttributes
 
QString key_id
 
QString key_value
 
QString key_name
 
QString key_what
 
QString key_type
 
QString node_id
 
QString edge_id
 
QString edge_source
 
QString edge_target
 
QString edge_weight
 
QString edge_directed
 
int gwWidth
 
int gwHeight
 
int totalLinks
 
int totalNodes
 
int fileFormat
 
int two_sm_mode
 
int edgeDirType
 
int initNodeSize
 
int initNodeNumberSize
 
int nodeNumberSize
 
int initNodeLabelSize
 
int nodeLabelSize
 
int source
 
int target
 
int nodeSize
 
qreal initEdgeWeight
 
qreal edgeWeight
 
qreal arrowSize
 
qreal bez_p1_x
 
qreal bez_p1_y
 
qreal bez_p2_x
 
qreal bez_p2_y
 
bool fileLoaded
 
bool missingNode
 
bool arrows
 
bool bezier
 
bool conv_OK
 
bool bool_key
 
bool bool_node
 
bool bool_edge
 
bool fileContainsNodeColors
 
bool fileContainsNodeCoords
 
bool fileContainsLinkColors
 
bool fileContainsLinkLabels
 
double randX
 
double randY
 

Detailed Description

Defines a class for network file loading and parsing.

Supports GraphML, Pajek, Adjacency, Graphviz, UCINET, EdgeLists etc

Constructor & Destructor Documentation

◆ Parser()

Parser::Parser ( )

◆ ~Parser()

Parser::~Parser ( )

Member Function Documentation

◆ containsReservedKeywords()

bool Parser::containsReservedKeywords ( const QString &  str) const
private

Checks if the given string contains any reserved keywords. Reserved keywords suggest the file is not adjacency-formatted but in another graph format. Parsing is aborted if a reserved keyword is found.

Parameters
strThe string to check for keywords.
Returns
true if a reserved keyword is found, false otherwise.

◆ createEdgesForRow()

bool Parser::createEdgesForRow ( const QStringList &  currentRow,
int  rowIndex 
)
private

Iterates through a row of the adjacency matrix to create edges. Emits a signal for each non-zero weight to create an edge between nodes. Parsing is aborted immediately if any invalid data is encountered.

Parameters
currentRowThe adjacency matrix row being processed.
rowIndexThe index of the row (source node for edges).
Returns
true if edges are successfully created, false otherwise.

◆ createMissingNodeEdges()

void Parser::createMissingNodeEdges ( )

Creates any missing node edges.

◆ createNodeWithDefaults()

void Parser::createNodeWithDefaults ( int  nodeIndex,
const QString &  label 
)
private

Emits a signal to create a node with the specified index and label, and default node properties. Assigns a random position for the node within the graph dimensions.

Parameters
nodeIndexIndex of the node to create.
labelLabel for the node (numerical or custom).

◆ createRandomNodes()

void Parser::createRandomNodes ( const int &  fixedNum = 1,
const QString &  label = QString(),
const int &  newNodes = 1 
)

Signals to create either a single new node (numbered fixedNum) or multiple new nodes (numbered from 1 to to newNodes)

Parameters
fixedNum
label
newNodes

◆ doParseAdjacency()

bool Parser::doParseAdjacency ( QTextStream &  ts,
const QString &  delimiter,
const QStringList &  nodeLabels 
)
private

Processes the adjacency matrix file to create nodes and edges. Reads each line of the matrix, creates nodes for the first row, and creates edges for subsequent rows. Uses nodeLabels to assign labels to nodes if provided. Parsing is aborted immediately if any issue is encountered.

Parameters
tsQTextStream of the decoded adjacency matrix file.
delimiterDelimiter used to split rows and columns.
nodeLabelsList of node labels (optional). If empty, numeric labels are used.
Returns
true if the nodes and edges are successfully created, false otherwise.

◆ endGraphMLElementEdge()

void Parser::endGraphMLElementEdge ( QXmlStreamReader &  xml)

Signals for a new edge to be created/added.

Called at the end of edge element

Parameters
xml

◆ endGraphMLElementNode()

void Parser::endGraphMLElementNode ( QXmlStreamReader &  xml)

Signals to create a new node.

called at the end of a node element

Parameters
xml

◆ finished

void Parser::finished ( QString  )
signal

◆ isComment()

SOCNETV_USE_NAMESPACE bool Parser::isComment ( QString  str)

Helper. Checks if the string parameter is a comment (starts with a known char, i.e #).

Parameters
str
Returns
bool

◆ load()

void Parser::load ( const QString &  fileName,
const QString &  codecName,
const int &  defNodeSize,
const QString &  defNodeColor,
const QString &  defNodeShape,
const QString &  defNodeNumberColor,
const int &  defNodeNumberSize,
const QString &  defNodeLabelColor,
const int &  defNodeLabelSize,
const QString &  defEdgeColor,
const int &  canvasWidth,
const int &  canvasHeight,
const int &  format,
const QString &  delim = QString(),
const int &  sm_mode = 1,
const bool &  sm_has_labels = false 
)

Loads the data of the given network file, and calls the relevant method to parse it.

Parameters
fileName
codecName
defNodeSize
defNodeColor
defNodeShape
defNodeNumberColor
defNodeNumberSize
defNodeLabelColor
defNodeLabelSize
defEdgeColor
width
height
format
sm_mode
delim

◆ normalizeQuotedIdentifier()

QString Parser::normalizeQuotedIdentifier ( const QString &  s)
static

Normalizes a quoted identifier from external network formats.

Some formats (e.g. Pajek) use quotes in headers as syntactic delimiters, such as:

*Matrix 9: "star"
*Matrix :9 "star"
*Matrix :9 'star'
Definition matrix.h:115

Quotes are part of the file syntax and must not become part of the internal relation name. This function:

  • trims surrounding whitespace
  • removes a single pair of wrapping double quotes OR single quotes, if present
  • normalizes doubled quotes inside quoted strings: "" -> " '' -> '

It does NOT collapse internal whitespace.

Parameters
sRaw identifier substring extracted from the file.
Returns
Clean identifier suitable for internal storage.

◆ parseAsAdjacency()

SOCNETV_USE_NAMESPACE bool Parser::parseAsAdjacency ( const QByteArray &  rawData,
const ParseConfig cfg,
const QString &  delimiter 
)

Main function to parse adjacency-formatted data.

Validates the format, resets internal counters, and processes the file to create nodes and edges from an adjacency matrix representation.

If cfg.sm_has_labels is true, the first comment line is treated as node labels.

NOTE: Parsing is aborted if any invalid data is encountered.

Example of a supported adjacency matrix file with node labels:

# Alice, Bob, Charlie
0, 1, 1
1, 0, 0
1, 0, 0

In this example:

  • The first line is a comment containing the node labels: Alice, Bob, Charlie.
  • The remaining lines form a 3x3 adjacency matrix where:
    • Row 1 corresponds to Alice
    • Row 2 corresponds to Bob
    • Row 3 corresponds to Charlie
  • A "1" indicates an edge (e.g., Alice is connected to Bob and Charlie).
  • A "0" indicates no edge (e.g., Bob is not connected to Charlie).
Parameters
rawDataRaw input data as QByteArray.
cfgParser configuration (contains format flags and defaults, including sm_has_labels).
delimiterDelimiter used to split rows and columns.
Returns
true if parsing succeeds, false otherwise.

◆ parseAsDL()

SOCNETV_USE_NAMESPACE bool Parser::parseAsDL ( const QByteArray &  rawData)

Parses the given raw data as DL formatted (UCINET) data.

This function reads and interprets a DL formatted file, which is a format used by UCINET. It processes the file line by line, extracting relevant information such as node labels, edge weights, and network properties. The function supports both fullmatrix and edgelist1 formats, and can handle two-mode networks.

Parameters
rawDataThe raw data to be parsed, provided as a QByteArray.
Returns
true if the parsing is successful, false otherwise.

The function performs the following steps:

  • Reads the raw data and decodes it using the specified text codec.
  • Checks if the first non-comment line starts with "DL".
  • Extracts keywords such as N, NM, NR, NC, and FORMAT from the file.
  • Reads row and column labels if present.
  • Creates nodes based on the labels or the declared number of nodes.
  • Reads and processes the data section to create edges between nodes.
  • Emits signals to create nodes and edges in the network.
  • Handles errors and inconsistencies in the file format.
Note
The function emits several signals during the parsing process:
  • signalAddNewRelation(const QString &relation): Emitted when a new relation is found.
  • signalSetRelation(int relationIndex): Emitted to set the current relation.
  • signalCreateEdge(int source, int target, double weight, const QColor &color, EdgeType type, bool arrows, bool bezier): Emitted to create a new edge.
Warning
The function assumes that the input data is correctly formatted according to the DL specification. Any deviations or errors in the format may result in parsing failures.

◆ parseAsDot()

SOCNETV_USE_NAMESPACE bool Parser::parseAsDot ( const QByteArray &  rawData)

Parses the data as GraphViz (DOT) formatted network.

IMPORTANT CONTRACTS / INVARIANTS

  • DOT has two graph “kinds”: 1) digraph => default directed, edges use "->" 2) graph => default undirected, edges use "--"
  • SocNetV must report the graph directedness reliably via Parser::signalFileLoaded (the Graph::graphFileLoaded slot uses this to set directedness before calling edgesEnabled()).
  • Therefore we must NOT use a single variable for two meanings: (a) the overall graph type (graph/digraph), AND (b) the last edge’s operator ("--"/"->").

Previous bug:

  • The parser used edgeDirType as both (a) and (b) and also treated any '-' as an edge indicator. In some cases, this left edgeDirType as Directed even for undirected files, so Graph::graphFileLoaded computed ties while the graph was still considered directed, doubling counts in the CLI (issue #187).

Fix:

  • Track graph-level directedness separately (graphDirType) and never overwrite it.
  • Parse edges only when the line contains "--" or "->" (not merely '-').
Parameters
rawDataRaw file bytes.
Returns
true on successful parse; false on format errors.

◆ parseAsEdgeListSimple()

bool Parser::parseAsEdgeListSimple ( const QByteArray &  rawData,
const QString &  delimiter 
)

Parses the data as simple edgelist formatted.

Parameters
rawData
delimiter
Returns
bool

◆ parseAsEdgeListWeighted()

bool Parser::parseAsEdgeListWeighted ( const QByteArray &  rawData,
const QString &  delimiter 
)

Parses the data as weighted edgelist formatted network.

This method can read and parse edgelist formated files where edge source and target are either named with numbers or with labels That is the following formats can be parsed:

edgelist with node numbers

1 2 1 1 3 2 1 6 2 1 8 2 ...

edgelist with node labels

actor1 actor2 1 actor2 actor4 2 actor1 actor3 1 actorX actorY 3 name othername 1 othername somename 2 ...

Parameters
rawData
delimiter
Returns

◆ parseAsGML()

SOCNETV_USE_NAMESPACE bool Parser::parseAsGML ( const QByteArray &  rawData)

Parses the data as GML formatted network.

This parser is line/state based. Many GML files are "compact" and place multiple attributes on the same line, e.g.:

node [ id 1 label "1" ]

while others use the expanded form:

node [ id 1 label "1" ]

To support both forms, we preprocess the decoded input into a normalized stream where:

  • '[' and ']' become standalone lines (outside quoted strings)
  • each attribute becomes its own "key value" line (outside quoted strings), e.g. 'id 1 label "1"' -> 'id 1' + 'label "1"'

We then run the existing state machine unchanged (but now it receives one attribute per line).

Also accepts both "weight" and "value" as edge weight keys.

Parameters
rawDataRaw file bytes.
Returns
bool True on success, false on parse error.

Returns true if ch is whitespace (space/tab/etc).

Tokenizes a line into tokens while respecting quoted strings.

Example: id 1 label "John Doe" becomes tokens: ["id","1","label","\"John Doe\""]

Quotes are preserved as part of the token.

Normalizes GML text for a line-based parser.

1) Makes '[' and ']' standalone lines (outside quoted strings). 2) Splits compact attribute runs into "key value" lines using a known-key set.

This is intentionally conservative: we only split on keys we know how to parse. Unknown tokens are left as-is.

◆ parseAsGraphML()

SOCNETV_USE_NAMESPACE bool Parser::parseAsGraphML ( const QByteArray &  rawData)

Parses the data as GraphML (not GML) formatted network.

Parameters
rawData
Returns
bool

◆ parseAsPajek()

bool Parser::parseAsPajek ( const QByteArray &  rawData)

Parse a Pajek-formatted network from raw bytes.

Supported constructs include (depending on the file contents):

  • *Network header
  • *Vertices N (node definitions with optional attributes)
  • Tie sections such as *Arcs, *Edges
  • Matrix-based relations:
    • *Matrix :k
    • *Matrix :k "Label"
    • *Matrix k: "Label"
    • empty-label cases like *Matrix :k / *Matrix k:

Behavior:

  • Creates nodes/edges by emitting the standard Parser signals.
  • Detects directedness and relation structure according to Pajek sections.
  • Populates totals (nodes/links) used by the loader and CLI harness.
  • On failure, sets errorMessage and returns false.
Parameters
rawDataEntire file contents (as read from disk).
Returns
true if parsing succeeds, false otherwise.

SPLIT EACH LINE (ON EMPTY SPACE CHARACTERS) IN SEVERAL ELEMENTS

READING NODES, THEN EDGES/ARCS

NODELABEL

NODESHAPE: There are five possible .

NODECOLORS

READ NODE COORDINATES

EDGES

ARCS

ARCSlist

matrix

◆ parseAsTwoModeSociomatrix()

bool Parser::parseAsTwoModeSociomatrix ( const QByteArray &  rawData)

Parses a two-mode (bipartite) sociomatrix file (.2sm / .aff).

The file contains a rectangular NR × NC binary (or weighted) matrix where rows = Mode 1 actors (persons, CEOs, …) and columns = Mode 2 actors (events, clubs, …).

Behaviour is controlled by two_sm_mode (set from ParseConfig::sm_mode, default = 1):

two_sm_mode == 1 → Bipartite graph (default) Creates NR + NC nodes and one undirected edge per non-zero cell. Mode 1 nodes: numbers 1..NR, labels "p1".."pNR", initNodeColor / initNodeShape Mode 2 nodes: numbers NR+1..NR+NC, labels "e1".."eNC", "SkyBlue" / "diamond"

two_sm_mode == 2 → Person (Mode-1) projection [B × Bᵀ] Creates NR nodes. Connects person i and person k with an undirected edge whenever they share at least one event (co-membership).

two_sm_mode == 3 → Event (Mode-2) projection [Bᵀ × B] Creates NC nodes. Connects event j and event l with an undirected edge whenever they share at least one person.

Parameters
rawDataRaw bytes of the file.
Returns
true on success, false on parse error.

◆ preprocessDotContent()

QString Parser::preprocessDotContent ( const QString &  dotContent)

Preprocesses the content of a DOT file to normalize its formatting, improve parsing and readability.

This function performs several transformations on the input DOT content:

  • Converts escaped newlines (&#92;n) into actual newlines.
  • Adds newlines after opening braces { and before closing braces }.
  • Adds newlines after each closing bracket ] and semicolon ;.
  • Normalizes brackets by adding spaces around them.
  • Ensures there is a semicolon ; between consecutive node definitions.
  • Adds spaces around edge definitions (-> and --).
  • Handles node and edge attribute blocks more carefully by adding newlines before them.
  • Merges edge attributes written on separate lines with their respective edge definitions.
Parameters
dotContentThe original content of the DOT file as a QString.
Returns
A QString containing the preprocessed DOT content.

◆ readDLKeywords()

bool Parser::readDLKeywords ( QStringList &  strList,
int &  N,
int &  NM,
int &  NR,
int &  NC,
bool &  fullmatrixFormat,
bool &  edgelist1Format,
bool &  diagonalPresent 
)

Reads and parses DL keywords from a given QStringList.

This function processes a list of strings to extract and interpret DL keywords. It updates the provided references with the parsed values.

Parameters
strListA reference to a QStringList containing the DL keywords.
NA reference to an integer to store the parsed value of 'N'.
NMA reference to an integer to store the parsed value of 'NM'.
NRA reference to an integer to store the parsed value of 'NR'.
NCA reference to an integer to store the parsed value of 'NC'.
fullmatrixFormatA reference to a boolean to indicate if the format is 'FULLMATRIX'.
edgelist1FormatA reference to a boolean to indicate if the format is 'edgelist'.
Returns
true if all keywords are successfully parsed and valid, false otherwise.

◆ readDotProperties()

void Parser::readDotProperties ( QString  str,
qreal &  nValue,
QString &  label,
QString &  shape,
QString &  color,
QString &  fontName,
QString &  fontColor 
)

Reads the properties of a dot element with improved handling of quoted values.

Parameters
strString containing properties (format: "prop1=value1, prop2=value2, ...")
nValueOutput variable for numeric value property
labelOutput variable for label property
shapeOutput variable for shape property
colorOutput variable for color property
fontNameOutput variable for font name property
fontColorOutput variable for font color property

◆ readGraphML()

bool Parser::readGraphML ( QXmlStreamReader &  xml)

Checks the xml token name and calls the appropriate function.

Parameters
xml
Returns
bool

◆ readGraphMLElementData()

void Parser::readGraphMLElementData ( QXmlStreamReader &  xml)

Reads data for edges and nodes.

called at a data element (usually nested inside a node or an edge element)

Parameters
xml

◆ readGraphMLElementDefaultValue()

void Parser::readGraphMLElementDefaultValue ( QXmlStreamReader &  xml)

Reads default key values.

Called at a default element (usually nested inside key element)

Parameters
xml

◆ readGraphMLElementEdge()

void Parser::readGraphMLElementEdge ( QXmlStreamAttributes &  xmlStreamAttr)

Reads basic edge creation properties.

called at the start of an edge element

Parameters
xmlStreamAttr

◆ readGraphMLElementEdgeGraphics()

void Parser::readGraphMLElementEdgeGraphics ( QXmlStreamReader &  xml)

Reads edge graphics data and properties: path, linestyle,width, arrows, etc.

Parameters
xml

◆ readGraphMLElementGraph()

void Parser::readGraphMLElementGraph ( QXmlStreamReader &  xml)

Reads a graph definition.

Called at Graph element

Parameters
xml

◆ readGraphMLElementKey()

void Parser::readGraphMLElementKey ( QXmlStreamAttributes &  xmlStreamAttr)

Reads a key definition.

called at key element

Parameters
xmlStreamAttr

◆ readGraphMLElementNode()

void Parser::readGraphMLElementNode ( QXmlStreamReader &  xml)

Reads basic node attributes and sets the nodeNumber.

called at the start of a node element

Parameters
xml

◆ readGraphMLElementNodeGraphics()

void Parser::readGraphMLElementNodeGraphics ( QXmlStreamReader &  xml)

Reads node graphics data and properties: label, color, shape, size, coordinates, etc.

Parameters
xml

◆ readGraphMLElementUnknown()

void Parser::readGraphMLElementUnknown ( QXmlStreamReader &  xml)

Trivial call for unknown elements.

Parameters
xml

◆ resetCounters()

void Parser::resetCounters ( )
private

Resets counters and data structures used during parsing. Clears relations and resets node and edge counters to ensure a clean state.

◆ setOwnedParseSink()

void Parser::setOwnedParseSink ( std::unique_ptr< SocNetV::IO::IGraphParseSink sink)

◆ setParseSink()

void Parser::setParseSink ( SocNetV::IO::IGraphParseSink sink)

◆ validateAndInitialize()

bool Parser::validateAndInitialize ( const QByteArray &  rawData,
const QString &  delimiter,
const bool &  sm_has_labels,
QStringList &  nodeLabels 
)
private

Validates the adjacency matrix file format and, optionally, gets node labels from first line (if it is a comment line). Checks for reserved keywords, row consistency, and appropriate delimiters in the first 11 rows. Parsing is aborted immediately if any issue is encountered.

Parameters
rawDataRaw input data as QByteArray.
delimiterDelimiter used to split rows and columns.
Returns
true if the file format is valid, false otherwise.

Member Data Documentation

◆ arrows

bool Parser::arrows
private

◆ arrowSize

qreal Parser::arrowSize
private

◆ bez_p1_x

qreal Parser::bez_p1_x
private

◆ bez_p1_y

qreal Parser::bez_p1_y
private

◆ bez_p2_x

qreal Parser::bez_p2_x
private

◆ bez_p2_y

qreal Parser::bez_p2_y
private

◆ bezier

bool Parser::bezier
private

◆ bool_edge

bool Parser::bool_edge
private

◆ bool_key

bool Parser::bool_key
private

◆ bool_node

bool Parser::bool_node
private

◆ conv_OK

bool Parser::conv_OK
private

◆ delimiter

QString Parser::delimiter
private

◆ edge_directed

QString Parser::edge_directed
private

◆ edge_id

QString Parser::edge_id
private

◆ edge_source

QString Parser::edge_source
private

◆ edge_target

QString Parser::edge_target
private

◆ edge_weight

QString Parser::edge_weight
private

◆ edgeColor

QString Parser::edgeColor
private

◆ edgeDirType

int Parser::edgeDirType
private

◆ edgeLabel

QString Parser::edgeLabel
private

◆ edgeMissingNodesList

QStringList Parser::edgeMissingNodesList
private

◆ edgeMissingNodesListData

QStringList Parser::edgeMissingNodesListData
private

◆ edgesMissingNodesHash

QHash<QString, QString> Parser::edgesMissingNodesHash
private

◆ edgeType

QString Parser::edgeType
private

◆ edgeWeight

qreal Parser::edgeWeight
private

◆ errorMessage

QString Parser::errorMessage
private

◆ fileContainsLinkColors

bool Parser::fileContainsLinkColors
private

◆ fileContainsLinkLabels

bool Parser::fileContainsLinkLabels
private

◆ fileContainsNodeColors

bool Parser::fileContainsNodeColors
private

◆ fileContainsNodeCoords

bool Parser::fileContainsNodeCoords
private

◆ fileDirPath

QString Parser::fileDirPath
private

◆ fileFormat

int Parser::fileFormat
private

◆ fileLoaded

bool Parser::fileLoaded
private

◆ firstModeMultiMap

QMultiMap<int, int> Parser::firstModeMultiMap
private

◆ gwHeight

int Parser::gwHeight
private

◆ gwWidth

int Parser::gwWidth
private

◆ initEdgeColor

QString Parser::initEdgeColor
private

◆ initEdgeLabel

QString Parser::initEdgeLabel
private

◆ initEdgeWeight

qreal Parser::initEdgeWeight
private

◆ initNodeColor

QString Parser::initNodeColor
private

◆ initNodeCustomAttributes

QHash<QString, QString> Parser::initNodeCustomAttributes
private

◆ initNodeCustomIcon

QString Parser::initNodeCustomIcon
private

◆ initNodeLabelColor

QString Parser::initNodeLabelColor
private

◆ initNodeLabelSize

int Parser::initNodeLabelSize
private

◆ initNodeNumberColor

QString Parser::initNodeNumberColor
private

◆ initNodeNumberSize

int Parser::initNodeNumberSize
private

◆ initNodeShape

QString Parser::initNodeShape
private

◆ initNodeSize

int Parser::initNodeSize
private

◆ key_id

QString Parser::key_id
private

◆ key_name

QString Parser::key_name
private

◆ key_type

QString Parser::key_type
private

◆ key_value

QString Parser::key_value
private

◆ key_what

QString Parser::key_what
private

◆ keyDefaultValue

QHash<QString, QString> Parser::keyDefaultValue
private

◆ keyFor

QHash<QString, QString> Parser::keyFor
private

◆ keyName

QHash<QString, QString> Parser::keyName
private

◆ keyType

QHash<QString, QString> Parser::keyType
private

◆ m_ownedParseSink

std::unique_ptr<SocNetV::IO::IGraphParseSink> Parser::m_ownedParseSink
private

◆ m_parseSink

SocNetV::IO::IGraphParseSink* Parser::m_parseSink = nullptr
private

◆ m_textCodecName

QString Parser::m_textCodecName
private

◆ missingNode

bool Parser::missingNode
private

◆ networkName

QString Parser::networkName
private

◆ node_id

QString Parser::node_id
private

◆ nodeColor

QString Parser::nodeColor
private

◆ nodeCustomAttributes

QHash<QString, QString> Parser::nodeCustomAttributes
private

◆ nodeHash

QHash<QString, int> Parser::nodeHash
private

◆ nodeIconPath

QString Parser::nodeIconPath
private

◆ nodeLabel

QString Parser::nodeLabel
private

◆ nodeLabelColor

QString Parser::nodeLabelColor
private

◆ nodeLabelSize

int Parser::nodeLabelSize
private

◆ nodeNumberColor

QString Parser::nodeNumberColor
private

◆ nodeNumberSize

int Parser::nodeNumberSize
private

◆ nodeShape

QString Parser::nodeShape
private

◆ nodeSize

int Parser::nodeSize
private

◆ randX

double Parser::randX
private

◆ randY

double Parser::randY
private

◆ relationsList

QStringList Parser::relationsList
private

◆ secondModeMultiMap

QMultiMap<int, int> Parser::secondModeMultiMap
private

◆ source

int Parser::source
private

◆ target

int Parser::target
private

◆ totalLinks

int Parser::totalLinks
private

◆ totalNodes

int Parser::totalNodes
private

◆ two_sm_mode

int Parser::two_sm_mode
private

◆ xml

QXmlStreamReader* Parser::xml
private

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