size_t AOutputBuffer::append(const AString& str, size_t len) { if (!len) return 0; if (AConstant::npos == len) return _append(str.c_str(), str.getSize()); else { AASSERT(this, len <= str.getSize()); return _append(str.c_str(), len); } }
int ut_ATextGenerator_General() { std::cerr << "ut_ATextGenerator_General" << std::endl; int iRet = 0x0; AString str; bool errorOccured = false; for (int iX=0; iX < 666; ++iX) { u4 sizeNeeded = ARandomNumberGenerator::get().nextRange(300, 16); //std::cerr << "ATextGenerator::generateUniqueId size: " << sizeNeeded << std::endl; ATextGenerator::generateUniqueId(str, sizeNeeded); if (str.getSize() != sizeNeeded) { std::cerr << "ATextGenerator::generateUniqueId failed for size: " << sizeNeeded << std::endl; iRet++; errorOccured = true; break; } str.clear(); } if (!errorOccured) std::cerr << "." << std::flush; return iRet; }
void ATextGenerator::generateRandomString(AOutputBuffer& target, size_t len, const AString& strCharSet) { for (size_t i = 0x0; i < len; ++i) { target.append(strCharSet.peek(ARandomNumberGenerator::get().nextRange(strCharSet.getSize()))); } }
void AFragmentCounter::_set() { u1 digits = (u1)(log10((float)m_Value) + 1); u1 odosize = (digits > m_Digits ? digits : m_Digits); m_strOdometer.fill('0'); AString str; str.parseU4(m_Value); if (m_strOdometer.getSize() < str.getSize()) m_strOdometer.setSize(str.getSize()); str.reverse(); memcpy(m_strOdometer.startUsingCharPtr(), str.c_str(), str.getSize()); m_strOdometer.stopUsingCharPtr(odosize); m_strOdometer.reverse(); }
int AWordUtility::splitSyllables(const AString& source, VECTOR_AString& result, bool handleSilentTrailing /* = true */) { if (source.isEmpty()) return 0; AString word(source); if (handleSilentTrailing) word.stripTrailing(msstr_SilentEnd); int count = 0; size_t start = 0; size_t pos = word.findOneOf(msstr_SyllableSeparators); while (AConstant::npos != pos) { AString str; word.peek(str, start, pos - start + 1); result.push_back(str.c_str()); ++count; start = pos+1; pos = word.findNotOneOf(msstr_SyllableSeparators, start); if (AConstant::npos != pos) pos = word.findOneOf(msstr_SyllableSeparators, start); } if (start < word.getSize()) { //a_Append leftovers to last word AString str; word.peek(str, start); if (count > 0) result.back().append(str); else result.push_back(str); } //a_Account for the silent trailing letters if (handleSilentTrailing && word.getSize() < source.getSize()) { AString str; source.peek(str, word.getSize()); if (count > 0) result.back().append(str); else result.push_back(str); } return count; }
/*! Uses the model to emit content for a path thisfunction("<path to the AXmlElement to emit>", separate) lua namespace: model lua param: Path to emit lua param: if non-nil then each element found will be returned by itself lua return: Content at the given path or nil if element does not exist */ static int alibrary_Objects_Model_emitContentFromPath(lua_State *L) { ATemplateContext *pLuaContext = static_cast<ATemplateContext *>(L->acontext); AASSERT(NULL, pLuaContext); size_t len = AConstant::npos; const char *s = luaL_checklstring(L, 1, &len); const AString& xmlpath = AString::wrap(s, len); int mode = 0; if (lua_gettop(L) > 1) mode = luaL_checkint(L, 2); AXmlElement::CONST_CONTAINER nodes; size_t ret = pLuaContext->useModel().useRoot().find(xmlpath, nodes); if (mode) { //a_Return each as separate values AString str; for (AXmlElement::CONST_CONTAINER::const_iterator cit = nodes.begin(); cit != nodes.end(); ++cit) { (*cit)->emitContent(str); lua_pushlstring(L, str.c_str(), str.getSize()); str.clear(); } return (int)ret; } else { if (ret > 0) { //a_Return content concatinated ARope rope; for (AXmlElement::CONST_CONTAINER::const_iterator cit = nodes.begin(); cit != nodes.end(); ++cit) (*cit)->emitContent(rope); const AString& str = rope.toAString(); lua_pushlstring(L, str.c_str(), str.getSize()); return 1; } else return 0; } }
/*! Emits the entire model as JSON thisfunction([indent = -1]) lua namespace: model lua param: (Optional) if 0 or greater, will indent the output. Default -1 will inline it. lua return: JSON string of default AXmlDocument model */ static int alibrary_Objects_Model_emitJson(lua_State *L) { ATemplateContext *pLuaContext = static_cast<ATemplateContext *>(L->acontext); AASSERT(NULL, pLuaContext); int indent = -1; if (lua_gettop(L) > 0) { indent = luaL_checkint(L, 1); } AString str; pLuaContext->useModel().useRoot().emitJson(str, indent); lua_pushlstring(L, str.c_str(), str.getSize()); return 1; }
/*! Gets text value for a given path thisfunction("element path") lua param: Element path lua return: Text content for a given element or nil if it doesn't exist */ static int alibrary_Objects_Model_getText(lua_State *L) { ATemplateContext *pLuaContext = static_cast<ATemplateContext *>(L->acontext); AASSERT(NULL, pLuaContext); size_t len = AConstant::npos; const char *s = luaL_checklstring(L, 1, &len); const AString& xmlpath = AString::wrap(s, len); AXmlElement *pElement = pLuaContext->useModel().useRoot().findElement(xmlpath); if (!pElement) { return 0; } else { AString str; pElement->emitContent(str); lua_pushlstring(L, str.c_str(), str.getSize()); return 1; } }
void ATextGenerator::generateFromTemplate(AOutputBuffer& target, const AString &strTemplate) { if (strTemplate.isEmpty()) return; //a_If the last is % and one before is not %, then expansion error will occur size_t end = strTemplate.getSize(); if (strTemplate[end - 1] == '%') { if (end < 1) { //a_Force early termination end = 0; } else if (strTemplate[end - 2] != '%') { end--; } } char cEscape; for (size_t x = 0; x < end; ++x) { cEscape = strTemplate[x]; if (cEscape == '%') { if (++x >= end) break; switch(strTemplate[x]) { case '%' : break; case 'z' : target.append(AString::fromInt(si_Counter++)); cEscape = '\x0'; break; case 'n' : cEscape = generateRandomNumeral(); break; case 'N' : if (ARandomNumberGenerator::get().nextRange(100) >= 50) cEscape = '+'; else cEscape = '-'; break; case 'l' : cEscape = generateRandomLowercaseLetter(); break; case 'L' : cEscape = generateRandomUppercaseLetter(); break; case 'r' : cEscape = (char)(ARandomNumberGenerator::get().nextRange(255) + 0x1); break; case 'R' : cEscape = ARandomNumberGenerator::get().nextU1(); break; case 's' : cEscape = generateRandomUppercaseLetter(); if (ARandomNumberGenerator::get().nextRange(100) >= 50) cEscape = (char)tolower(cEscape); break; case 't' : ATime().emitYYYYMMDDHHMMSS(target); cEscape = '\x0'; break; case 'T' : ATime().emitRFCtime(target); cEscape = '\x0'; break; default : //a_Escape character detected, but no valid control character found target.append(cEscape); //a_Keep the sequence untouched cEscape = strTemplate[x]; //a_Current char becomes escape to stay consistent with the add to follow } } if (cEscape != '\x0') target.append(cEscape); } }
void AWordUtility::getSoundexForm(const AString& source, AString& result, size_t minSize) { result.clear(); if (source.isEmpty()) return; //a_First character appended as is AString str(source); str.makeLower(); size_t sourceSize = str.getSize(); size_t pos = 0; while (pos < sourceSize) { switch(str.at(pos)) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'h': case 'w': case 'y': break; //--- case 'p': if (pos == 0 && sourceSize > 2) { if ('s' == str.at(pos+1)) { break; //a_ps => s at word start } else if ('h' == str.at(pos+1)) { ++pos; //a_pf => f, fallthrough } } case 'b': case 'f': case 'v': if (!result.isEmpty()) { if (str.at(pos) != result.at(result.getSize()-1)) result.append('1'); } else result.append('1'); break; //--- case 'd': if (pos+1 < sourceSize) { if ('g' == str.at(pos+1)) break; //a_dg => g } //a_Fallthough from d to t case 't': if (pos+1 < sourceSize && 'c' == str.at(pos+1)) { if (pos+2 < sourceSize && 'h' == str.at(pos+2)) { ++pos; break; //a_tch => ch } } if (!result.isEmpty()) { if (str.at(pos) != result.at(result.getSize()-1)) result.append('3'); } else result.append('3'); break; //--- case 'g': if (pos+1 < sourceSize) { if ('h' == str.at(pos+1)) { if (pos+2 < sourceSize) { if ('t' == str.at(pos+2)) { ++pos; break; //a_ght => t } else break; //a_gh => h } } else if ('n' == str.at(pos+1)) { break; //a_gn => n } } //a_Fallthrough case 'k': if (pos+1 < sourceSize && 'n' == str.at(pos+1)) { break; //a_kn => n } //a_Fallthrough case 'c': case 'j': case 'q': case 's': case 'x': case 'z': if (!result.isEmpty()) { if (str.at(pos) != result.at(result.getSize()-1)) result.append('2'); } else result.append('2'); break; //--- case 'l': if (!result.isEmpty()) { if (str.at(pos) != result.at(result.getSize()-1)) result.append('4'); } else result.append('4'); break; //--- case 'm': if ('b' == str.at(pos+1, '\x0')) { ++pos; //a_mb => m } //a_ Fallthrough case 'n': if (!result.isEmpty()) { if (str.at(pos) != result.at(result.getSize()-1)) result.append('5'); } else result.append('5'); //--- case 'r': if (!result.isEmpty()) { if (str.at(pos) != result.at(result.getSize()-1)) result.append('6'); } else result.append('6'); break; } ++pos; } if (result.getSize() < minSize) result.setSize(minSize, '0'); }
void AWordUtility::getPlural(const AString& one, AString& many) { many.clear(); //a_Words of size 1 or 2, just append s and return if (one.getSize() < 3) { many.assign(one); many.append('s'); return; } switch(one.last()) { case 's': { char c = one.at(one.getSize()-2); if ('i' == c) { //a_"is" -> "es" many.assign(one); many.set('i', many.getSize()-2); } else if ('u' == c) { //a_"us" -> "ii" one.peek(many, 0, one.getSize()-2); many.append("ii", 2); } else { many.assign(one); many.append("es", 2); } } break; case 'z': case 'x': many.assign(one); many.append("es", 2); break; case 'h': { char c = one.at(one.getSize()-2); if ('s' == c || 'c' == c) { many.assign(one); many.append("es", 2); } else { many.assign(one); many.append('s'); } } break; case 'y': { char c = one.at(one.getSize()-2); if (AConstant::npos != sstr_Vowels.find(c)) { //a_vowel+'y', add 's' many.assign(one); many.append('s'); } else { //a_consonant+'y', convert 'y' to 'ies' one.peek(many, 0, one.getSize()-1); many.append("ies", 3); } } break; default: many.assign(one); many.append('s'); break; } }
/* Sound conversions Pre-process Before After ght t Process ending Before After e (remove) es s ie i ies s ng n y i eau o Process Before After ch C ck k ea I gh g gn n ie i kh k kn n ks x mb m nc nk oo U ou u ph f ps s q(~u) k (q without u) qu kw sh S tia Sa th Z wh w ugh f zh Z Post-process (@-any vowel) ang@ anj@ Phonetics: ch = C (chair = Cair) sh = S (bash = baS) zh = Z (zhivago = Zivago) oo = U (boot = bUt) */ void AWordUtility::getPhoneticForm(const AString& source, AString& result) { AString work(source); work.makeLower(); const char IGNORE_CHAR = '_'; result.clear(); size_t workSize = work.getSize(); if (!workSize) return; //a_STEP 1 //a_Preprocess (before and after data must be same size) //a_These replacements take precedence int i; const int iiPreCount = 1; const AString preBefore[iiPreCount] = { "ght" }; const AString preAfter[iiPreCount] = { "t__" }; for (i=0; i<iiPreCount; ++i) work.replace(preBefore[i], preAfter[i]); //a_STEP 2 //a_Ending (data in reverse) (before and after data must be same size) const int iiEndingCount = 9; const AString endBefore[iiEndingCount] = { "e", "se", "sei", "ei", "yc", "gn", "uae", "y", "eu" }; const AString endAfter[iiEndingCount] = { "_", "s_", "s_i", "_i", "is", "_n", "__o", "i", "_i" }; work.reverse(); for (i=0; i<iiEndingCount; ++i) { if (0 == work.find(endBefore[i])) { work.overwrite(0, endAfter[i]); } } work.reverse(); //a_STEP 4 //a_Iterate and process sounds AString temp; u4 pos = 0; while(pos < workSize) { switch(work.at(pos)) { //a_ ch->C case 'c': if ('h' == work.at(pos+1, '\x0')) { temp.append('C'); ++pos; } else if ('k' == work.at(pos+1, '\x0')) { temp.append('k'); ++pos; } else temp.append('c'); break; //a_ ea->I case 'e': if ('a' == work.at(pos+1, '\x0')) { temp.append('I'); ++pos; } else temp.append('e'); break; //a_ gh->g, ght->t, gn->n case 'g': if ('n' == work.at(pos+1, '\x0')) { temp.append('n'); ++pos; } else if ('h' == work.at(pos+1, '\x0')) { temp.append('g'); ++pos; } else temp.append('g'); break; //a_ ie->i case 'i': if ('e' == work.at(pos+1, '\x0')) { temp.append('i'); ++pos; } else temp.append('i'); break; //a_kh->k, kn->n, ks->x case 'k': if ('h' == work.at(pos+1, '\x0')) { temp.append('k'); ++pos; } else if ('n' == work.at(pos+1, '\x0')) { temp.append('n'); ++pos; } else if ('s' == work.at(pos+1, '\x0')) { temp.append('x'); ++pos; } else temp.append('k'); break; //a_nc->nk case 'n': if ('c' == work.at(pos+1, '\x0')) { temp.append("nk"); ++pos; } else temp.append('n'); break; //a_ qu->kw case 'm': if ('b' == work.at(pos+1, '\x0')) { temp.append('m'); ++pos; } else temp.append('m'); break; //a_ oo->U case 'o': if ('o' == work.at(pos+1, '\x0')) { temp.append('U'); ++pos; } else if ('u' == work.at(pos+1, '\x0')) { temp.append('u'); ++pos; } else temp.append('o'); break; //a_ ph->f, ps->s case 'p': if ('h' == work.at(pos+1, '\x0')) { temp.append('f'); ++pos; } else if ('s' == work.at(pos+1, '\x0')) { temp.append('s'); ++pos; } else temp.append('p'); break; //a_ qu->kw case 'q': if ('u' == work.at(pos+1, '\x0')) { temp.append("kw", 2); ++pos; } else temp.append('k'); break; //a_ sh->S case 's': if ('h' == work.at(pos+1, '\x0')) { temp.append('S'); ++pos; } else temp.append('s'); break; //a_ th->s, tia->Sa case 't': if ('h' == work.at(pos+1, '\x0')) { temp.append('Z'); ++pos; } else if ('i' == work.at(pos+1, '\x0') && 'o' == work.at(pos+2, '\x0')) { temp.append("Su"); pos += 2; } else temp.append('t'); break; //a_ wh->w case 'w': if ('h' == work.at(pos+1, '\x0')) { temp.append('w'); ++pos; } else temp.append('w'); break; //a_ zh->Z case 'z': if ('h' == work.at(pos+1, '\x0')) { temp.append('Z'); ++pos; } else temp.append('z'); break; //a_Skip underscores case IGNORE_CHAR: break; default: temp.append(work.at(pos)); } ++pos; } //a_STEP 4 //a_Remove duplicates (by insering underscore which will be ignored later) workSize = temp.getSize(); pos = 0; while(pos < workSize) { if (temp.at(pos) == temp.at(pos+1, '\x0')) temp.use(pos) = IGNORE_CHAR; ++pos; } //a_STEP 6 //a_Post process pos = 0; workSize = temp.getSize(); while(pos < workSize) { switch(temp.at(pos)) { case 'a': if ('n' == temp.at(pos+1, '\x0') && 'g' == temp.at(pos+2, '\x0')) { char c = temp.at(pos+3,'\x0'); if (c && AConstant::npos != msstr_SoundVowels.find(c)) { result.append("anj", 3); pos += 2; } } else result.append('a'); break; case IGNORE_CHAR: break; default: result.append(temp.at(pos)); } ++pos; } }
void ATemplateNodeHandler_DADA::Node::_appendVariable(ADadaDataHolder *pddh, MAP_AString_AString& globals, const AString& strType, AOutputBuffer& target) { AASSERT(this, strType.getSize() > 0); AString strTypeName, strControl; LIST_AString listControlNames; size_t pos = strType.find(':'); if (AConstant::npos != pos) { strType.peek(strTypeName, 0, pos); strTypeName.makeLower(); strType.peek(strControl, pos+1); strControl.makeLower(); strControl.split(listControlNames, ',', AConstant::ASTRING_WHITESPACE); } else { strTypeName.assign(strType); strTypeName.makeLower(); } //a_Find it in the global lookup MAP_AString_AString::iterator it = globals.find(strTypeName); if (it != globals.end()) { AString str((*it).second); LIST_AString::iterator itN = listControlNames.begin(); while (itN != listControlNames.end()) { if (!(*itN).compare("article", 7)) { AString strTemp(str); if (AConstant::npos == AWordUtility::sstr_Vowels.find(str.at(0))) { str.assign("a ", 2); } else { str.assign("an ", 3); } str.append(strTemp); } if (!(*itN).compare("plural", 6)) { AString strTemp; AWordUtility::getPlural(str, strTemp); str.assign(strTemp); } if (!(*itN).compare("uppercase", 9)) { str.makeUpper(); } if (!(*itN).compare("lowercase", 9)) { str.makeLower(); } if (!(*itN).compare("proper", 6)) { str.use(0) = (u1)toupper(str.at(0)); size_t nextStart; size_t nextSpace = str.find(' ', 1); while (AConstant::npos != nextSpace) { nextStart = nextSpace + 1; if (nextStart < str.getSize()) str.use(nextStart) = (u1)toupper(str.at(nextStart)); else break; nextSpace = str.find(' ', nextStart); } } ++itN; } target.append(str); } else { //a_Not found in global map } }
size_t AFragmentString::parse(const AString& str) { size_t iRet = AConstant::npos; size_t iX = 0; AString strHold; while(iX < str.getSize()) { switch(str[iX]) { case '\\' : { ++iX; if (str.getSize() > iX) { strHold += str[iX]; iRet = iX; } else { //a_String truncated iRet = iX - 1; return iRet; } } break; case '(' : { iX++; if (str.getSize() > iX) { size_t iF = str.find(')', iX+1); if (iF != AConstant::npos) { AASSERT(this, iF >= iX); if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); iRet = iX-1; } AString strT; str.peek(strT, iX, iF-iX); iX = iF; // advance offset after extraction u1 b; u4 n[2]; b = (u1)strT.toInt(); if (b > 9) b = 9; if ((iF = strT.find(',')) == AConstant::npos) { // Only 1 number, the digit value long stop = 10; for (int i=1; i<b; ++i) stop *= 10; m_Container.push_back(new AFragmentCounter(b, u4(stop-1))); } else { AString str1; strT.peek(str1, iF + 1); if ((iF = str1.find(',')) == AConstant::npos) { n[0] = str1.toU4(); m_Container.push_back(new AFragmentCounter(b, n[0])); } else { AString strQ; str1.peek(strQ, 0, iF); n[0] = strQ.toU4(); strQ.clear(); str1.peek(strQ, iF+1); n[1] = strQ.toU4(); if ((iF = str1.find(',', iF+1)) == AConstant::npos) m_Container.push_back(new AFragmentCounter(b, n[0], n[1])); else { strQ.clear(); str1.peek(strQ, iF+1); m_Container.push_back(new AFragmentCounter(b, n[0], n[1], strQ.toInt())); } } } iRet = iX; } else { //a_Closing tag not found iRet = iX-1; return iRet; } } else { //a_String is truncated iRet = iX-1; return iRet; } } break; case '{' : { ++iX; if (str.getSize() > iX) { size_t iF = str.find('}', iX+1); if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); iRet = iX-1;} if (iF != AConstant::npos) { AASSERT(this, iF >= iX); AString strT; str.peek(strT, iX, iF-iX); char cX; while (!strT.isEmpty()) { cX = strT.get(); switch (cX) { case '#': m_Container.push_back(new AFragmentSet(AFragmentSet::Numeric)); break; case '&': m_Container.push_back(new AFragmentSet(AFragmentSet::LowercaseAlpha)); break; case '@': m_Container.push_back(new AFragmentSet(AFragmentSet::UppercaseAlpha)); break; case '%': m_Container.push_back(new AFragmentSet(AFragmentSet::LowercaseAlphaNumeric)); break; case '^': m_Container.push_back(new AFragmentSet(AFragmentSet::UppercaseAlphaNumeric)); break; case '?': m_Container.push_back(new AFragmentSet(AFragmentSet::AlphaNumeric)); break; default : strHold += cX; } } iX = iF; iRet = iX; } else { //a_Closing tag not found iRet = iX-1; return iRet; } } else { //a_String is truncated iRet = iX-1; return iRet; } } break; case '[' : { size_t iF = str.find(']', iX+1); if (iF != AConstant::npos) { AASSERT(this, iF >= iX); if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); } AString strT; str.peek(strT, iX + 1, iF - iX - 1); m_Container.push_back(new AFragmentSet(strT)); iX = iF; iRet = iX; } else { //a_Closing tag not found, return iRet at point of error iRet = iX; return iRet; } } break; case '<' : { size_t iF = str.find('>', iX+1); if (iF != AConstant::npos) { AASSERT(this, iF >= iX); if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); } AString strT; str.peek(strT, iX + 1, iF - iX - 1); m_Container.push_back(new AFragmentOdometer(strT.toSize_t())); iX = iF; iRet = iX; } else { //a_Closing tag not found, return iRet at point of error iRet = iX; return iRet; } } break; default : strHold += str[iX]; iRet = iX; } iX++; } if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); } //a_If we got here we have succeeded iRet = iX; m_Finished = false; return iRet; }
AOSContext::ReturnCode AOSOutput_Template::execute(AOSContext& context) { //a_See if extension for mime type set for the template(s) AString ext; if (context.getOutputParams().emitContentFromPath(AOS_BaseModules_Constants::MIME_EXTENSION, ext)) { m_Services.useConfiguration().setMimeTypeFromExt(ext, context); } else { //a_Set content type based on request URL extension m_Services.useConfiguration().setMimeTypeFromExt(context.useRequestUrl().getExtension(), context); } // Iterate parameters and build the template const AXmlElement::CONTAINER& container = context.getOutputParams().getContentContainer(); for (AXmlElement::CONTAINER::const_iterator cit = container.begin(); cit != container.end(); ++cit) { //a_Check "if" condition AString ifElement; if ((*cit)->getAttributes().get(ASW("if",2), ifElement)) { if (ifElement.getSize() > 0) { //a_Check condition, if not met continue with next template if (!context.useModel().exists(ifElement)) { if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) context.useEventVisitor().startEvent(ARope("Skipping conditional file template IF ")+ifElement, AEventVisitor::EL_DEBUG); continue; } } } //a_Check "ifnot" condition ifElement.clear(); if ((*cit)->getAttributes().get(ASW("ifnot",5), ifElement)) { if (ifElement.getSize() > 0) { //a_Check condition, if not met continue with next template if (context.useModel().exists(ifElement)) { if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) context.useEventVisitor().startEvent(ARope("Skipping conditional file template IFNOT ")+ifElement, AEventVisitor::EL_DEBUG); continue; } } } // // Now we check if this is inlined or filename // AString str(1024, 512); if ((*cit)->getName().equals(AOS_BaseModules_Constants::TEMPLATE)) { if (context.useEventVisitor().isLoggingDebug()) { context.useEventVisitor().startEvent(getClass() + ": Creating new inline template", AEventVisitor::EL_DEBUG); } // Create a new template AAutoPtr<ATemplate> pTemplate(m_Services.createTemplate(), true); // Add inline template str.clear(); (*cit)->emitContent(str); AFile_AString strfile(str); pTemplate->clear(); pTemplate->fromAFile(strfile); pTemplate->process(context.useLuaTemplateContext(), context.useOutputBuffer()); } else if ((*cit)->getName().equals(AOS_BaseModules_Constants::FILENAME)) { // Add filename based template AFilename filename(m_Services.useConfiguration().getAosBaseDataDirectory()); str.clear(); (*cit)->emitContent(str); filename.join(str, false); if (context.useEventVisitor().isLoggingDebug()) { context.useEventVisitor().startEvent(getClass()+": Fetching/parsing template for: "+filename, AEventVisitor::EL_DEBUG); } AAutoPtr<ATemplate> pT(NULL, false); if (ACacheInterface::NOT_FOUND == m_Services.useCacheManager().getTemplate(context, filename, pT)) { //a_Not found add error and continue if (context.useEventVisitor().isLogging(AEventVisitor::EL_WARN)) context.useEventVisitor().startEvent(ARope(getClass())+ASWNL(": Unable to find a template file: ")+filename+ASWNL(", ignoring and continuing"), AEventVisitor::EL_WARN); continue; } //a_Parse template if (context.useEventVisitor().isLogging(AEventVisitor::EL_DEBUG)) { context.useEventVisitor().startEvent(getClass()+"Processing template file: "+filename, AEventVisitor::EL_DEBUG); } AASSERT(this, pT.isNotNull()); pT->process(context.useLuaTemplateContext(), context.useOutputBuffer()); } } return AOSContext::RETURN_OK; }
void ATextOdometer::setSubset(const AString& strSubset) { AASSERT(this, strSubset.getSize() > 0); mstr_Subset = strSubset; clear(strSubset.getSize()); }