diff --git a/glabels/TextNode.cpp b/glabels/TextNode.cpp index 05b10b2..6787f93 100644 --- a/glabels/TextNode.cpp +++ b/glabels/TextNode.cpp @@ -21,18 +21,6 @@ #include "TextNode.h" -namespace { - typedef enum { - START, - LITERAL, - LITERAL_DOLLAR, - START_DOLLAR, - FIELD, - DONE - } State; -} - - /// /// Default Constructor /// @@ -51,155 +39,6 @@ TextNode::TextNode( bool isField, const QString &data ) } -/// -/// Constructor from Parsing Next Token in Text -/// -TextNode::TextNode( const QString &text, int iStart, int &iNext ) -{ - State state = START; - QString literalText; - QString fieldName; - bool isField = false; - - int i = iStart; - - while ( state != DONE ) - { - QChar c = text[i]; - - switch (state) { - - case START: - switch (c.unicode()) { - case '$': - /* May be start of a field node. */ - i++; - state = START_DOLLAR; - break; - case '\n': - state = DONE; - break; - case 0: - state = DONE; - break; - default: - /* Start a literal text node. */ - literalText.append( c ); - i++; - state = LITERAL; - break; - } - break; - - case LITERAL: - switch (c.unicode()) { - case '$': - /* May be the beginning of a field node. */ - i++; - state = LITERAL_DOLLAR; - break; - case '\n': - state = DONE; - break; - case 0: - state = DONE; - break; - default: - literalText.append( c ); - i++; - state = LITERAL; - break; - } - break; - - case LITERAL_DOLLAR: - switch (c.unicode()) { - case '{': - /* "${" indicates the start of a new field node, gather for literal too. */ - literalText.append( '$' ); - i++; - state = DONE; - break; - case '\n': - /* Append "$" to literal text, don't gather newline. */ - literalText.append( '$' ); - i++; - state = DONE; - break; - case 0: - /* Append "$" to literal text, don't gather null. */ - literalText.append( '$' ); - i++; - state = DONE; - break; - default: - /* Append "$" to literal text, gather this character too. */ - literalText.append( '$' ); - literalText.append( c ); - i+=2; - state = LITERAL; - break; - } - break; - - case START_DOLLAR: - switch (c.unicode()) { - case '{': - /* This is probably the begining of a field node, gather for literal too. */ - literalText.append( c ); - i++; - state = FIELD; - break; - case '\n': - state = DONE; - break; - case 0: - state = DONE; - break; - default: - /* The "$" was literal. */ - literalText.append( c ); - i++; - state = LITERAL; - break; - } - break; - - case FIELD: - switch (c.unicode()) { - case '}': - /* We now finally know that this node is really field node. */ - isField = true; - i++; - state = DONE; - break; - case '\n': - state = DONE; - break; - case 0: - state = DONE; - break; - default: - /* Gather for field name and literal, just in case. */ - fieldName.append( c ); - literalText.append( c ); - i++; - state = FIELD; - break; - } - break; - - } - - } - - mIsField = isField; - mData = isField ? fieldName : literalText; - - iNext = i; -} - - /// /// == Operator /// diff --git a/glabels/TextNode.h b/glabels/TextNode.h index 626fa43..6f0b372 100644 --- a/glabels/TextNode.h +++ b/glabels/TextNode.h @@ -39,8 +39,6 @@ public: TextNode( bool isField, const QString &data ); - TextNode( const QString &text, int i_start, int &i_next ); - ///////////////////////////////// // Operators