00001
00002
00003
00004
00005
00006
00007
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 # include "xmlvaluable.hpp"
00041 # include "valuers/xmlvaluer.hpp"
00042
00043 BEGIN_XDFLENGINE_NS
00044
00045
00046
00047
00048
00049
00050
00051
00052 XMLValuable::XMLValuable()
00053 {
00054 DEBUG_CREATE(XMLValuable)
00055 }
00056
00057
00058
00059
00060 XMLValuable::~XMLValuable()
00061 {
00062 DEBUG_DEL(XMLValuable)
00063
00064
00065 while( !m_vaValuers.empty() )(delete m_vaValuers.pop());
00066
00067 }
00068
00069
00070
00071
00072 char* XMLValuable::calculateValue( const char* p_pszValue)
00073 {
00074 char* l_pszBefore = 0;
00075 char* l_pszPrefix = 0;
00076 char* l_pszExpr = 0;
00077 char* l_pszAfter = 0;
00078 char* l_pszValue = 0;
00079 char* l_pszRet = 0;
00080 char* l_pszTmp = 0;
00081 XMLValuer* l_pXMLValuer;
00082
00083
00084 DEBUG_FUNC(XMLValuable::calculateValue)
00085
00086 l_pszTmp = copyCharBuffer( p_pszValue);
00087 l_pszBefore = l_pszTmp;
00088 l_pszAfter = l_pszTmp;
00089 l_pszRet=copyCharBuffer("");
00090
00091 while(true)
00092 {
00093
00094
00095
00096 l_pszPrefix = strstr(l_pszBefore, XMLVALUER_DELIM);
00097 if( ! l_pszPrefix) break;
00098 l_pszPrefix[0]='\0';
00099 l_pszPrefix+= strlen( XMLVALUER_DELIM);
00100
00101
00102 l_pszExpr = strstr(l_pszPrefix, XMLVALUER_SEP);
00103 if( ! l_pszExpr) break;
00104 l_pszExpr[0]='\0';
00105 l_pszExpr+= strlen( XMLVALUER_SEP);
00106
00107
00108 l_pszAfter = strstr(l_pszExpr, XMLVALUER_DELIM);
00109 if( ! l_pszAfter) break;
00110 l_pszAfter[0]='\0';
00111 l_pszAfter+= strlen( XMLVALUER_DELIM);
00112
00113
00114 l_pXMLValuer = getValuer( l_pszPrefix);
00115
00116 l_pszValue = 0;
00117 if( l_pXMLValuer)
00118 {
00119 l_pszValue = l_pXMLValuer->calculateExpression( l_pszExpr);
00120 }
00121
00122 if( !l_pszValue)
00123 {
00124 l_pszValue = copyCharBuffer("");
00125 l_pszValue = concatCharBuffer( l_pszValue,XMLVALUER_DELIM);
00126 l_pszValue = concatCharBuffer( l_pszValue,l_pszPrefix);
00127 l_pszValue = concatCharBuffer( l_pszValue,XMLVALUER_SEP);
00128 l_pszValue = concatCharBuffer( l_pszValue,l_pszExpr);
00129 l_pszValue = concatCharBuffer( l_pszValue,XMLVALUER_DELIM);
00130 }
00131
00132 l_pszRet = concatCharBuffer(l_pszRet, l_pszBefore);
00133 l_pszRet = concatCharBuffer(l_pszRet, l_pszValue);
00134 l_pszValue = releaseCharBuffer( l_pszValue);
00135 l_pszBefore = l_pszAfter;
00136
00137 }
00138
00139 l_pszRet = concatCharBuffer(l_pszRet, l_pszAfter);
00140
00141
00142 l_pszTmp = releaseCharBuffer( l_pszTmp);
00143
00144 return l_pszRet;
00145 }
00146
00147
00148
00149
00150 void XMLValuable::addValuer ( XMLValuer* p_pXV_valuer, const char* p_pszName)
00151 {
00152 DEBUG_FUNC(XMLValuable::addValuer)
00153 m_vaValuers.add( p_pXV_valuer, p_pszName);
00154 }
00155
00156
00157
00158
00159 XMLValuer* XMLValuable::getValuer(const char* p_pszName) const
00160 {
00161 DEBUG_FUNC(XMLValuable::getValuer)
00162 return m_vaValuers.get( p_pszName);
00163 }
00164
00165
00166
00167
00168 END_XDFLENGINE_NS