本文整理汇总了C++中AString::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::isEmpty方法的具体用法?C++ AString::isEmpty怎么用?C++ AString::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: config
void SmartMote::config(){
AString conf;
AStringList * param = NULL;
bool flag;
/* se il bottone non è premuto */
if(!checkButton()){
/* ritorno */
return;
}
/* accendo l'uart */
openUART();
/* inizializzo il modulo come AP */
if(!m_net.initialize(AESP07::APMode)){
/* se fallisce notifico l'errore */
error();
}
/* setto il nome come SmartMote e password admin */
if(!m_net.configureAP("SmartMote", "smartmote")){
/* se fallisce notifico l'errore */
error();
}
/* imposto l'ip a 192.168.1.1 */
if(!m_net.setIp(AESP07::APMode, "192.168.1.1")){
/* se fallisce notifico l'errore */
error();
}
/* disabilito le connessioni multiple */
if(!m_net.setMultipleConnections(false)){
/* se fallisce notifico l'errore */
error();
}
/* apro il server sulla porta 8000 */
if(!m_net.listen(8000)){
/* se fallisce notifico l'errore */
error();
}
/* aspetto di ricevere la stringa */
while(conf.isEmpty()){
m_net.waitForData(conf);
}
/* prendo i parametri */
param = conf.split(' ');
/* se la stringlist è allocata correttamente */
if(param){
saveSSID(param->at(0));
saveKey(param->at(1));
saveHost(param->at(2));
RTCC.setHours(static_cast<uint32>(param->at(3).toInt32(flag)));
RTCC.setMinutes(static_cast<uint32>(param->at(3).toInt32(flag)));
RTCC.setSeconds(static_cast<uint32>(param->at(3).toInt32(flag)));
}else{
/* altrimenti notifico l'errore */
error();
}
/* spengo i led */
turnOffRed();
turnOffGreen();
}
示例2: executeSQL
size_t AMySQLServer::executeSQL(const AString& sqlQuery, AResultSet& target, AString& error)
{
target.clear();
MYSQL_RES *pmyresult = executeSQL(sqlQuery, error);
if (!pmyresult && !error.isEmpty())
return AConstant::npos;
target.useSQL().assign(sqlQuery);
return (pmyresult ? _processQueryAllRows(pmyresult, target) : 0);
}
示例3: _loadStaticData
void ATemplateNodeHandler_DADA::_loadStaticData()
{
AXmlElement::CONST_CONTAINER nodes;
m_Services.useConfiguration().getConfigRoot().find("AOS_DadaData/dataset", nodes);
AXmlElement::CONST_CONTAINER::iterator it;
for (it = nodes.begin(); it != nodes.end(); ++it)
{
AString strSet;
(*it)->getAttributes().get(ASW("name",4), strSet);
if (strSet.isEmpty())
ATHROW_EX(*it, AException::InvalidData, ASWNL("AOS_DadaData/dataset missing 'name' parameter"));
ADadaDataHolder *pddh = new ADadaDataHolder();
pddh->readData(m_Services, *it);
m_Objects.insert(strSet, pddh, true);
}
nodes.clear();
m_Services.useConfiguration().getConfigRoot().find(ASW("AOS_DadaData/template",21), nodes);
it = nodes.begin();
while (it != nodes.end())
{
AString str;
(*it)->emitContent(str);
AString strName;
if ((*it)->getAttributes().get(ASW("name",4), strName))
{
AFilename filename(m_Services.useConfiguration().getAosBaseDataDirectory(), str, false);
if (AFileSystem::exists(filename))
{
AFile_Physical file(filename, ASW("r", 1));
file.open();
str.clear();
while (AConstant::npos != file.readLine(str))
{
if ('#' != str.at(0, '\x0'))
{
m_Templates[strName].push_back(str);
}
str.clear();
}
}
else
m_Services.useLog().add(ARope("AOS_DadaData: Missing file: ")+filename, ALog::EVENT_WARNING);
}
else
m_Services.useLog().add(ASWNL("AOS_DadaData: AOS_DadaData/template missing 'name' attribute"), ALog::EVENT_FAILURE);
++it;
}
}
示例4: file
void ATemplateNodeHandler_DADA::Node::_generateLine(ADadaDataHolder *pddh, MAP_AString_AString& globals, const AString& format, ATemplateContext& context, AOutputBuffer& output)
{
if (format.isEmpty())
return;
AFile_AString file(format);
size_t readresult;
char c = '\x0';
AString target(1024, 1024), strType(64,128);
while (AConstant::npos != file.readUntil(target, S_DELIM_START, true, true))
{
file.read(c);
readresult = file.readUntil(strType, S_DELIM_END, true, true);
if (0 == readresult)
{
file.readUntilEOF(target);
output.append(target);
target.clear();
break;
}
//a_If not EOF process type
if (AConstant::npos != readresult)
{
if (strType.getSize() > 1)
{
switch (c)
{
case '%':
//a_Process the tag {%type:tag,tag,...}
_appendWordType(pddh, globals, strType, target);
break;
case '$':
//a_ {$variable}
_appendVariable(pddh, globals, strType, target);
break;
default:
//a_Passthru of unknown tags
target.append('{');
target.append(strType);
target.append('}');
context.useEventVisitor().addEvent(ASWNL("ATemplateNodeHandler_DADA::Node:") + " unknown type:" + strType, AEventVisitor::EL_WARN);
break;
}
strType.clear();
}
}
}
file.readUntilEOF(target);
output.append(target);
target.clear();
}
示例5: insert
void AOSAdminRegistry::insert(const AString& name, AOSAdminInterface& object)
{
if (name.isEmpty())
ATHROW(this, AException::InvalidParameter);
if (m_AdminObjects.find(name) != m_AdminObjects.end())
m_Log.add(ASWNL("Admin object already registered"), name, ALog::EVENT_WARNING);
//a_Insert/replace
m_AdminObjects[name] = &object;
}
示例6: splitSyllables
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;
}
示例7: getRhymeLevel
size_t AWordUtility::getRhymeLevel(const AString& wordOne, const AString& wordTwo)
{
//a_Check if one or both are empty
if (wordOne.isEmpty() || wordTwo.isEmpty())
return 0;
AString endOne, soundOne;
AString endTwo, soundTwo;
AWordUtility::getPhoneticForm(wordOne, endOne);
AWordUtility::getPhoneticForm(wordTwo, endTwo);
AWordUtility::getSoundsLikeForm(endOne, soundOne);
AWordUtility::getSoundsLikeForm(endTwo, soundTwo);
std::cout << endOne << ":" << endTwo << "=";
std::cout << soundOne << ":" << soundTwo << std::endl;
soundOne.reverse();
soundTwo.reverse();
size_t level = (soundOne.getSize() > soundTwo.getSize() ? soundOne.diff(soundTwo) : soundTwo.diff(soundOne));
return level;
}
示例8: setExtension
void AFilename::setExtension(const AString& ext)
{
size_t pos = m_Filename.rfind('.');
if (AConstant::npos != pos)
{
m_Filename.setSize(pos);
}
//a_Set extension if any, else clear extension
if (!ext.isEmpty())
{
m_Filename.append('.');
m_Filename.append(ext);
}
}
示例9: countSyllables
int AWordUtility::countSyllables(const AString& source)
{
if (source.isEmpty())
return 0;
int count = 0;
AString word(source);
word.stripTrailing(msstr_SilentEnd);
size_t pos = word.findOneOf(msstr_SyllableSeparators);
while (AConstant::npos != pos)
{
++count;
pos = word.findNotOneOf(msstr_SyllableSeparators, pos+1);
if (AConstant::npos != pos)
pos = word.findOneOf(msstr_SyllableSeparators, pos+1);
}
return count;
}
示例10: getFields
bool AMySQLServer::getFields(const AString& table, VECTOR_AString& sv, AString& error)
{
if (!isInitialized())
{
error.assign("Database has not been initialized;");
return false;
}
if (table.isEmpty())
{
error = "Please use a namespace;";
return false;
}
sv.clear();
AString query("SHOW COLUMNS FROM `");
query += table;
query += "`";
MYSQL_RES *pmyresult = executeSQL(query, error);
if (pmyresult)
{
MYSQL_ROW myrow;
int iSize = (int)mysql_num_rows(pmyresult);
for (int i=0; i < iSize; ++i)
{
myrow = mysql_fetch_row(pmyresult);
if (myrow)
{
sv.push_back(myrow[0]);
}
}
mysql_free_result(pmyresult);
}
else
return false;
return true;
}
示例11: parse
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 '{' :
{
//.........这里部分代码省略.........
示例12: ut_AString_Access
int ut_AString_Access()
{
std::cerr << "ut_AString_Access" << std::endl;
int iRet = 0x0;
//a_Peeking
AString strPeek;
AString str0 = "SomethingNew";
str0.peek(strPeek, 0);
ASSERT_UNIT_TEST(strPeek == "SomethingNew", "AString::peek", "0", iRet);
strPeek.clear();
str0.peek(strPeek, 0, 9);
ASSERT_UNIT_TEST(strPeek == "Something", "AString::peek", "1", iRet);
strPeek.clear();
str0.peek(strPeek, 9, 3);
ASSERT_UNIT_TEST(strPeek == "New", "AString::peek", "2", iRet);
ASSERT_UNIT_TEST(str0.peek(4) == 't', "AString::peek", "3", iRet);
int pos0 = 0;
str0 = "path0/path1/path2";
strPeek.clear();
pos0 = str0.peekUntil(strPeek, pos0, '/');
ASSERT_UNIT_TEST(strPeek.equals("path0"), "AString::peekUntil", "0", iRet);
strPeek.clear();
pos0 = str0.peekUntil(strPeek, pos0+1, '/');
ASSERT_UNIT_TEST(strPeek.equals("path1"), "AString::peekUntil", "1", iRet);
strPeek.clear();
pos0 = str0.peekUntil(strPeek, pos0+1, '/');
ASSERT_UNIT_TEST(strPeek.equals("path2"), "AString::peekUntil", "2", iRet);
ASSERT_UNIT_TEST(AConstant::npos == pos0, "AString::peekUntil", "3", iRet);
//a_Set
AString strSource0 = AString("New"), strSource1("Newer"), strSource2("123Now");
str0 = "This is old";
str0.set(strSource0, 8);
ASSERT_UNIT_TEST(str0.equals("This is New"), "AString::set", "0", iRet);
str0.set(strSource1, 8);
ASSERT_UNIT_TEST(str0.equals("This is Newer"), "AString::set", "1", iRet);
str0.set(strSource2, 8, 3, 3);
ASSERT_UNIT_TEST(str0.equals("This is Now"), "AString::set", "2", iRet);
str0.set('n', 8);
ASSERT_UNIT_TEST(str0.equals("This is now"), "AString::set", "3", iRet);
//a_Use
str0.use(10) = 't';
ASSERT_UNIT_TEST(str0.peek(10) == 't', "AString::use", "0", iRet);
//a_Get
AString strGet;
str0 = "YetMoreStuff!";
str0.get(strGet, 0, 3);
ASSERT_UNIT_TEST(strGet.equals("Yet"), "AString::get", "0", iRet);
str0.get(strGet, 0, 4);
ASSERT_UNIT_TEST(strGet.equals("More"), "AString::get", "1", iRet);
str0.get(strGet, 0, 5);
ASSERT_UNIT_TEST(strGet.equals("Stuff"), "AString::get", "2", iRet);
str0.get(strGet, 0, 0);
ASSERT_UNIT_TEST(strGet.isEmpty(), "AString::get", "3", iRet);
char cX = str0.get();
ASSERT_UNIT_TEST(cX == '!', "AString::get", "4", iRet);
ASSERT_UNIT_TEST(strGet.isEmpty(), "AString::get", "5", iRet);
str0 = "SomeMoreStuff!";
str0.get(strGet, 0);
ASSERT_UNIT_TEST(strGet.equals("SomeMoreStuff!"), "AString::get", "6", iRet);
ASSERT_UNIT_TEST(str0.isEmpty(), "AString::get", "7", iRet);
str0 = "SomeMoreStuff!";
str0.get(strGet, 0, 0);
ASSERT_UNIT_TEST(str0.equals("SomeMoreStuff!"), "AString::get", "8", iRet);
ASSERT_UNIT_TEST(strGet.isEmpty(), "AString::get", "9", iRet);
str0 = "path0/path1/path2";
str0.getUntil(strGet, '/');
ASSERT_UNIT_TEST(strGet.equals("path0"), "AString::getUntil", "0", iRet);
str0.getUntil(strGet, '/');
ASSERT_UNIT_TEST(strGet.equals("path1"), "AString::getUntil", "1", iRet);
str0.getUntil(strGet, '/');
ASSERT_UNIT_TEST(strGet.equals("path2"), "AString::getUntil", "2", iRet);
str0.getUntil(strGet, '/');
ASSERT_UNIT_TEST(str0.isEmpty(), "AString::getUntil", "3", iRet);
AString str1;
str0="find_file_1";
str0.peekUntil(str1, 2, "1");
//.........这里部分代码省略.........
示例13: execute
AOSContext::ReturnCode AOSModule_Template::execute(AOSContext& context, const AXmlElement& params)
{
const AXmlElement *pNode = params.findElement(ASW("template",8));
AAutoPtr<ATemplate> pTemplate(NULL, false);
AAutoPtr<AFile> pFile(NULL, false);
if (pNode)
{
//a_Element contains script
pTemplate.reset(m_Services.createTemplate(), true);
//a_Parse template
AFile_AString strfile;
pNode->emitContent(strfile);
pTemplate->fromAFile(strfile);
}
else
{
//a_Filename provided, use the cache
pNode = params.findElement(AOS_BaseModules_Constants::FILENAME);
if (pNode)
{
AString relativePath;
pNode->emitContent(relativePath);
//a_File to be used (may need caching for it, but for now keep it dynamic)
AFilename filename(m_Services.useConfiguration().getAosBaseDataDirectory(), true);
filename.join(relativePath, false);
if (ACacheInterface::NOT_FOUND == m_Services.useCacheManager().getTemplate(context, filename, pTemplate))
{
//a_Not found, return error
ARope rope;
rope.append(getClass());
rope.append(": Unable to find a template file: ",34);
rope.append(filename);
context.useEventVisitor().startEvent(rope, AEventVisitor::EL_ERROR);
return AOSContext::RETURN_ERROR;
}
}
else
{
context.addError(getClass(), ASWNL("Unable to find module/template nor module/filename, Template module did not execute, params"));
return AOSContext::RETURN_ERROR; //a_Did not find either module/template or module/filename
}
}
//a_Process and save output
ARope ropeOutput;
pTemplate->process(context.useLuaTemplateContext(), ropeOutput);
//a_Add template to debug
if (context.getDumpContextLevel() > 0)
{
AString str("debug/",6);
str.append(getClass());
str.append("/template",9);
AXmlElement& base = context.useModel().addElement(str);
pTemplate->emitXml(base);
}
//a_Insert output into outpath (if any)
pNode = params.findElement(AOS_BaseModules_Constants::PATH);
if (pNode)
{
AString xmlpath;
pNode->emitContent(xmlpath);
if (!xmlpath.isEmpty())
{
//a_Add output as CDATA
context.useModel().addElement(xmlpath).addData(ropeOutput, AXmlElement::ENC_CDATADIRECT);
}
}
else
{
context.useEventVisitor().addEvent(ASWNL("Unable to find module/path, output from template discarded"), AEventVisitor::EL_WARN);
}
return AOSContext::RETURN_OK;
}
示例14: generateFromTemplate
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);
}
}
示例15: getSoundexForm
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
//.........这里部分代码省略.........