当前位置: 首页>>代码示例>>C++>>正文


C++ AString::toInt方法代码示例

本文整理汇总了C++中AString::toInt方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::toInt方法的具体用法?C++ AString::toInt怎么用?C++ AString::toInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AString的用法示例。


在下文中一共展示了AString::toInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getInt

int AXmlElement::getInt(const AString& path, int iDefault) const
{
  AString str;
  if (emitContentFromPath(path, str))
    return str.toInt();
  else
    return iDefault;
}
开发者ID:achacha,项目名称:AOS,代码行数:8,代码来源:AXmlElement.cpp

示例2: 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 '{' :
      {
//.........这里部分代码省略.........
开发者ID:achacha,项目名称:AOS,代码行数:101,代码来源:AFragmentString.cpp

示例3: adminProcessAction

void AOSContextManager::adminProcessAction(AXmlElement& eBase, const AHTTPRequestHeader& request)
{
  AString str;
  if (request.getUrl().getParameterPairs().get(ASW("property",8), str))
  {
    if (str.equals(ASWNL("AOSContextManager.log_level")))
    {
      str.clear();
      if (request.getUrl().getParameterPairs().get(ASW("Set",3), str))
      {
        int level = str.toInt();
        if (level >= AEventVisitor::EL_NONE && level <= AEventVisitor::EL_DEBUG)
        {
          m_DefaultEventLogLevel = level;
        }
        else
        {
          adminAddError(eBase, ASWNL("Invalid log level, must be (0-5)"));
        }
      }
    }
    else if (str.equals(ASWNL("AOSContextManager.clear_history")))
    {
      str.clear();
      if (request.getUrl().getParameterPairs().get(ASW("Clear",5), str))
      {
        int level = str.toInt();
        switch(level)
        {
          case 0:
            _clearHistory();
            _clearErrorHistory();
          break;

          case 1:
            _clearHistory();
          break;

          case 2:
            _clearErrorHistory();
          break;

          default:
            adminAddError(eBase, ASWNL("Invalid level for history clearing, must be (0,1,2)"));
        }
      }
    }
    else if (str.equals(ASWNL("AOSContextManager.history.max_size")))
    {
      str.clear();
      if (request.getUrl().getParameterPairs().get(ASW("Set",3), str))
      {
        int i = str.toInt();
        if (i >= 0)
        {
          m_HistoryMaxSize = i;
        }
        else
        {
          adminAddError(eBase, ASWNL("Invalid maximum size, must be >=0"));
        }
      }
    }
    else if (str.equals(ASWNL("AOSContextManager.error_history.max_size")))
    {
      str.clear();
      if (request.getUrl().getParameterPairs().get(ASW("Set",3), str))
      {
        int i = str.toInt();
        if (i >= 0)
        {
          m_ErrorHistoryMaxSize = i;
        }
        else
        {
          adminAddError(eBase, ASWNL("Invalid maximum size, must be >=0"));
        }
      }
    }
    else if (str.equals(ASWNL("AOSContextManager.freestore.max_size")))
    {
      str.clear();
      if (request.getUrl().getParameterPairs().get(ASW("Set",3), str))
      {
        int i = str.toInt();
        if (i >= 0)
        {
          m_FreeStoreMaxSize = i;
        }
        else
        {
          adminAddError(eBase, ASWNL("Invalid maximum size, must be >=0"));
        }
      }
    }
  }
}
开发者ID:,项目名称:,代码行数:97,代码来源:


注:本文中的AString::toInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。