diff options
Diffstat (limited to 'xml')
-rw-r--r-- | xml/display.c | 2 | ||||
-rw-r--r-- | xml/display.h | 2 | ||||
-rw-r--r-- | xml/function.c | 2 | ||||
-rw-r--r-- | xml/function.h | 2 | ||||
-rw-r--r-- | xml/object.c | 6 | ||||
-rw-r--r-- | xml/object.h | 5 | ||||
-rw-r--r-- | xml/parser.c | 8 | ||||
-rw-r--r-- | xml/parser.h | 2 | ||||
-rw-r--r-- | xml/skin.c | 2 | ||||
-rw-r--r-- | xml/skin.h | 2 | ||||
-rw-r--r-- | xml/string.c | 31 | ||||
-rw-r--r-- | xml/string.h | 70 | ||||
-rw-r--r-- | xml/type.c | 2 | ||||
-rw-r--r-- | xml/type.h | 2 | ||||
-rw-r--r-- | xml/xml.c | 2 | ||||
-rw-r--r-- | xml/xml.h | 2 |
16 files changed, 97 insertions, 45 deletions
diff --git a/xml/display.c b/xml/display.c index 4790b2d..058b7df 100644 --- a/xml/display.c +++ b/xml/display.c @@ -1,5 +1,5 @@ /* - * $Id: display.c,v 1.3 2004/12/08 17:13:26 lordjaxom Exp $ + * $Id: display.c,v 1.1 2004/12/19 22:03:25 lordjaxom Exp $ */ #include "xml/display.h" diff --git a/xml/display.h b/xml/display.h index 6c233b2..b57f734 100644 --- a/xml/display.h +++ b/xml/display.h @@ -1,5 +1,5 @@ /* - * $Id: display.h,v 1.3 2004/12/08 17:13:26 lordjaxom Exp $ + * $Id: display.h,v 1.1 2004/12/19 22:03:25 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_DISPLAY_H diff --git a/xml/function.c b/xml/function.c index 66bae48..ca06922 100644 --- a/xml/function.c +++ b/xml/function.c @@ -1,5 +1,5 @@ /* - * $Id: function.c,v 1.8 2004/12/17 19:56:16 lordjaxom Exp $ + * $Id: function.c,v 1.1 2004/12/19 22:03:26 lordjaxom Exp $ */ #include "xml/function.h" diff --git a/xml/function.h b/xml/function.h index abd1199..a67163b 100644 --- a/xml/function.h +++ b/xml/function.h @@ -1,5 +1,5 @@ /* - * $Id: function.h,v 1.5 2004/12/12 20:26:25 lordjaxom Exp $ + * $Id: function.h,v 1.1 2004/12/19 22:03:26 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_FUNCTION_H diff --git a/xml/object.c b/xml/object.c index 940e5a9..b1da0b9 100644 --- a/xml/object.c +++ b/xml/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.6 2004/12/17 19:56:16 lordjaxom Exp $ + * $Id: object.c,v 1.1 2004/12/19 22:03:27 lordjaxom Exp $ */ #include "xml/object.h" @@ -7,8 +7,8 @@ #include "font.h" static const std::string ObjectNames[] = - { "image", "text", "rectangle", "ellipse", "slope", "progress", "scrolltext", "scrollbar", - "block", "list", "item" }; + { "image", "text", "marquee", "rectangle", "ellipse", "slope", "progress", "scrolltext", + "scrollbar", "block", "list", "item" }; cxObject::cxObject(cxDisplay *parent): mType((eType)__COUNT_OBJECT__), diff --git a/xml/object.h b/xml/object.h index 41a626a..4778b83 100644 --- a/xml/object.h +++ b/xml/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $ + * $Id: object.h,v 1.1 2004/12/19 22:03:27 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_OBJECT_H @@ -48,6 +48,7 @@ public: enum eType { image, text, + marquee, rectangle, ellipse, slope, @@ -80,6 +81,7 @@ private: cxString mTotal; std::string mFontFace; int mFontSize; + uint mIndex; cxObjects *mObjects; // used for block objects such as <list> cxDisplay *mDisplay; cxSkin *mSkin; @@ -106,6 +108,7 @@ public: std::string Text(void) const { return mText.Evaluate(); } int Current(void) const { return mCurrent.Evaluate(); } int Total(void) const { return mTotal.Evaluate(); } + uint Index(void) const { return mIndex; } cxDisplay *Display(void) const { return mDisplay; } cxSkin *Skin(void) const { return mSkin; } diff --git a/xml/parser.c b/xml/parser.c index 62cc69c..71c9453 100644 --- a/xml/parser.c +++ b/xml/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.7 2004/12/14 20:02:31 lordjaxom Exp $ + * $Id: parser.c,v 1.1 2004/12/19 22:03:27 lordjaxom Exp $ */ #include "xml/parser.h" @@ -84,6 +84,7 @@ static cxSkin *skin = NULL; static cxDisplay *display = NULL; static cxObject *parent = NULL; static cxObject *object = NULL; +static uint mindex = 0; bool xStartElem(const std::string &name, std::map<std::string,std::string> &attrs) { //Dprintf("start element: %s\n", name.c_str()); @@ -146,10 +147,13 @@ bool xStartElem(const std::string &name, std::map<std::string,std::string> &attr ATTRIB_MAN_FUNC ("path", object->mPath.Parse); } else if (name == "text" + || name == "marquee" || name == "scrolltext") { ATTRIB_OPT_STRING("color", object->mFg); ATTRIB_OPT_FUNC ("align", object->ParseAlignment); ATTRIB_OPT_FUNC ("font", object->ParseFontFace); + + object->mIndex = mindex++; } else if (name == "rectangle") { ATTRIB_OPT_STRING("color", object->mFg); @@ -197,6 +201,7 @@ bool xCharData(const std::string &text) { if (end - start + 1 > 0) { //Dprintf("context: %s\n", context[context.size() - 1].c_str()); if (context[context.size() - 1] == "text" + || context[context.size() - 1] == "marquee" || context[context.size() - 1] == "scrolltext") { if (!object->mText.Parse(text.substr(start, end - start + 1))) return false; @@ -212,6 +217,7 @@ bool xEndElem(const std::string &name) { if (name == "display") { skin->mDisplays[display->Type()] = display; display = NULL; + mindex = 0; } else if (object != NULL || parent != NULL) { if (object == NULL) { diff --git a/xml/parser.h b/xml/parser.h index 60fe30c..5f37118 100644 --- a/xml/parser.h +++ b/xml/parser.h @@ -1,5 +1,5 @@ /* - * $Id: parser.h,v 1.1.1.1 2004/11/19 16:45:31 lordjaxom Exp $ + * $Id: parser.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_PARSER_H @@ -1,5 +1,5 @@ /* - * $Id: skin.c,v 1.2 2004/12/08 17:13:26 lordjaxom Exp $ + * $Id: skin.c,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ */ #include "xml/skin.h" @@ -1,5 +1,5 @@ /* - * $Id: skin.h,v 1.3 2004/12/08 17:13:26 lordjaxom Exp $ + * $Id: skin.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_SKIN_H diff --git a/xml/string.c b/xml/string.c index 5b573eb..742439e 100644 --- a/xml/string.c +++ b/xml/string.c @@ -1,5 +1,5 @@ /* - * $Id: string.c,v 1.8 2004/12/17 19:56:16 lordjaxom Exp $ + * $Id: string.c,v 1.1 2004/12/19 22:03:25 lordjaxom Exp $ */ #include "xml/string.h" @@ -40,8 +40,8 @@ static const char *Tokens[__COUNT_TOKEN__] = { std::string txToken::Token(const txToken &Token) { std::string result = (std::string)"{" + Tokens[Token.Type]; - if (Token.Attrib.length() > 0) - result += ":" + Token.Attrib; + //if (Token.Attrib.length() > 0) + // result += ":" + Token.Attrib; result += "}"; return result; @@ -92,20 +92,31 @@ bool cxString::Parse(const std::string &Text) { } int pos = -1; - txToken &lastToken = mTokens[mTokens.size() - 1]; - Dprintf("assigning attrib: %.*s\n", ptr-last, last); - lastToken.Attrib.assign(last, ptr - last); - while ((pos = lastToken.Attrib.find('\\', pos + 1)) != -1) { - switch (lastToken.Attrib[pos + 1]) { + std::string attr; + attr.assign(last, ptr - last); + while ((pos = attr.find('\\', pos + 1)) != -1) { + switch (attr[pos + 1]) { case 'n': - lastToken.Attrib.replace(pos, 2, "\n"); + attr.replace(pos, 2, "\n"); break; default: - lastToken.Attrib.erase(pos, 1); + attr.erase(pos, 1); } } + txToken &lastToken = mTokens[mTokens.size() - 1]; + if (attr == "clean") + lastToken.Attrib = aClean; + else { + char *end; + int n = strtol(attr.c_str(), &end, 10); + if (end != attr.c_str() && end == '\0') + lastToken.Attrib = n; + else + lastToken.Attrib = attr; + } + inAttrib = false; inToken = false; } else { diff --git a/xml/string.h b/xml/string.h index 8e29db8..00e5fab 100644 --- a/xml/string.h +++ b/xml/string.h @@ -1,5 +1,5 @@ /* - * $Id: string.h,v 1.8 2004/12/17 19:56:16 lordjaxom Exp $ + * $Id: string.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_STRING_H @@ -96,15 +96,52 @@ enum exToken { #define __COUNT_TOKEN__ (tCanScrollDown + 1) }; +enum exAttrib { + aNone, + aNumber, + aString, + aClean + +#define __COUNT_ATTRIB__ (aClean + 1) +}; + +struct txAttrib { + exAttrib Type; + std::string Text; + int Number; + + txAttrib(const std::string &a): Type(aString), Text(a) {} + txAttrib(int n): Type(aNumber), Number(0) {} + txAttrib(exAttrib t): Type(t), Text(""), Number(0) {} + txAttrib(void): Type(aNone) {} + + friend bool operator== (const txAttrib &A, const txAttrib &B); + friend bool operator< (const txAttrib &A, const txAttrib &B); +}; + +inline bool operator== (const txAttrib &A, const txAttrib &B) +{ + return A.Type == B.Type + && A.Text == B.Text; +} + +inline bool operator< (const txAttrib &A, const txAttrib &B) +{ + return A.Type == B.Type + ? A.Text < B.Text + : A.Type < B.Type; +} + struct txToken { - exToken Type; - uint Offset; - std::string Attrib; - int Index; - int Tab; + exToken Type; + uint Offset; + txAttrib Attrib; + int Index; + int Tab; txToken(void): Index(-1), Tab(-1) {} - txToken(exToken t, uint o, const std::string &a): Type(t), Offset(o), Attrib(a), Index(-1), Tab(-1) {} + txToken(exToken t, uint o, const std::string &a): + Type(t), Offset(o), Attrib(a), Index(-1), Tab(-1) {} friend bool operator< (const txToken &A, const txToken &B); @@ -113,18 +150,13 @@ struct txToken { inline bool operator< (const txToken &A, const txToken &B) { - if (A.Type == B.Type) { - if (A.Attrib == B.Attrib) { - if (A.Index == B.Index) - return A.Tab < B.Tab; - else - return A.Index < B.Index; - } - else - return A.Attrib < B.Attrib; - } - else - return A.Type < B.Type; + return A.Type == B.Type + ? A.Attrib == B.Attrib + ? A.Index == B.Index + ? A.Tab < B.Tab + : A.Index < B.Index + : A.Attrib < B.Attrib + : A.Type < B.Type; } class cxString { @@ -1,5 +1,5 @@ /* - * $Id: type.c,v 1.4 2004/12/17 19:56:16 lordjaxom Exp $ + * $Id: type.c,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ */ #include "xml/type.h" @@ -1,5 +1,5 @@ /* - * $Id: type.h,v 1.6 2004/12/17 19:56:16 lordjaxom Exp $ + * $Id: type.h,v 1.1 2004/12/19 22:03:28 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_TYPE_H @@ -1,5 +1,5 @@ /* - * $Id: xml.c,v 1.3 2004/12/12 20:26:25 lordjaxom Exp $ + * $Id: xml.c,v 1.1 2004/12/19 22:03:49 lordjaxom Exp $ * This module was kindly provided by Clemens Kirchgatterer */ @@ -1,5 +1,5 @@ /* - * $Id: xml.h,v 1.1.1.1 2004/11/19 16:45:31 lordjaxom Exp $ + * $Id: xml.h,v 1.1 2004/12/19 22:03:49 lordjaxom Exp $ * This module was kindly provided by Clemens Kirchgatterer */ |