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


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

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


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

示例1: testPeek

void testPeek()
{
  AFile_AString strfile;
  ARope rope(ASWNL("0123456789"), 4);

  size_t r;
  r = rope.peek(strfile, 3);
  std::cout << r << ":" << strfile << std::endl;

  AString str;
  r = rope.peek(str);
  std::cout << r << ":" << str << std::endl;

  str.clear();
  r = rope.peek(str, 7, 2);
  std::cout << r << ":" << str << std::endl;

  str.clear();
  r = rope.peek(str, 7, 0);
  std::cout << r << ":" << str << std::endl;

  str.clear();
  r = rope.peek(str, 1, 50);
  std::cout << r << ":" << str << std::endl;

  str.clear();
  r = rope.peek(str, 10, 1);
  std::cout << r << ":" << str << std::endl;
}
开发者ID:achacha,项目名称:AOS,代码行数:29,代码来源:tRope.cpp

示例2: _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;
  }
}
开发者ID:,项目名称:,代码行数:54,代码来源:

示例3: ut_AFragmentString_General

int ut_AFragmentString_General(void)
{
  int iRet = 0x0;

  std::cerr << "ut_AFragmentString_General" << std::endl;

	AFragmentString fstr("foo-[1c]\\\\(4,3,1)");
	AString str;
  fstr.next(str);
	int i;
  ASSERT_UNIT_TEST(fstr.getPermutations() == 6, "AFragmentString getPermutations", "0", iRet);

  for (i=0; i<4; ++i) {
		str.clear();
    fstr.next(str);
	}
  ASSERT_UNIT_TEST(str.equals("foo-c\\0002"), "AFragmentString next", "0", iRet);

  //
	fstr.clear();
	fstr.parse("<4>");
  ASSERT_UNIT_TEST(fstr.getPermutations() == 10000, "AFragmentString getPermutations", "1", iRet);

  //
	fstr.clear();
	fstr.parse("(2)");
  ASSERT_UNIT_TEST(fstr.getPermutations() == 100, "AFragmentString getPermutations", "2", iRet);

	//
  fstr.clear();
	fstr.parse("(4,100,112,-3)");
  ASSERT_UNIT_TEST(fstr.getPermutations() == 5, "AFragmentString getPermutations", "3", iRet);
  str.clear();
	fstr.next(str);
  ASSERT_UNIT_TEST(str.equals("0112"), "AFragmentString next", "1", iRet);
	for (i=0; i<2; ++i) {
		str.clear();
    fstr.next(str);
	}
  ASSERT_UNIT_TEST(str.equals("0106"), "AFragmentString next", "2", iRet);
	for (i=0; i<2; ++i) {
		str.clear();
    fstr.next(str);
	}
  ASSERT_UNIT_TEST(str.equals("0100"), "AFragmentString next", "3", iRet);
	
	return iRet;
}
开发者ID:achacha,项目名称:AOS,代码行数:48,代码来源:ut_AFragmentString_General.cpp

示例4: sizeof

void cSHA1Checksum::DigestToJava(const Checksum & a_Digest, AString & a_Out)
{
	Checksum Digest;
	memcpy(Digest, a_Digest, sizeof(Digest));
	
	bool IsNegative = (Digest[0] >= 0x80);
	if (IsNegative)
	{
		// Two's complement:
		bool carry = true;  // Add one to the whole number
		for (int i = 19; i >= 0; i--)
		{
			Digest[i] = ~Digest[i];
			if (carry)
			{
				carry = (Digest[i] == 0xff);
				Digest[i]++;
			}
		}
	}
	a_Out.clear();
	a_Out.reserve(40);
	for (int i = 0; i < 20; i++)
	{
		AppendPrintf(a_Out, "%02x", Digest[i]);
	}
	while ((a_Out.length() > 0) && (a_Out[0] == '0'))
	{
		a_Out.erase(0, 1);
	}
	if (IsNegative)
	{
		a_Out.insert(0, "-");
	}
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例5: ReadString

bool cByteBuffer::ReadString(AString & a_String, int a_Count)
{
	CHECK_THREAD;
	CheckValid();
	ASSERT(a_Count >= 0);
	NEEDBYTES(a_Count);
	a_String.clear();
	a_String.reserve(a_Count);
	int BytesToEndOfBuffer = m_BufferSize - m_ReadPos;
	ASSERT(BytesToEndOfBuffer >= 0);  // Sanity check
	if (BytesToEndOfBuffer <= a_Count)
	{
		// Reading across the ringbuffer end, read the first part and adjust parameters:
		if (BytesToEndOfBuffer > 0)
		{
			a_String.assign(m_Buffer + m_ReadPos, BytesToEndOfBuffer);
			a_Count -= BytesToEndOfBuffer;
		}
		m_ReadPos = 0;
	}

	// Read the rest of the bytes in a single read (guaranteed to fit):
	if (a_Count > 0)
	{
		a_String.append(m_Buffer + m_ReadPos, a_Count);
		m_ReadPos += a_Count;
	}
	return true;
}
开发者ID:Xury,项目名称:MCServer,代码行数:29,代码来源:ByteBuffer.cpp

示例6: ut_ATextGenerator_General

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;
}
开发者ID:achacha,项目名称:AOS,代码行数:27,代码来源:ut_ATextGenerator_General.cpp

示例7: DigestToJava

// Converts a raw 160-bit SHA1 digest into a Java Hex representation
// According to http://wiki.vg/wiki/index.php?title=Protocol_Encryption&oldid=2802
static void DigestToJava(byte a_Digest[20], AString & a_Out)
{
	bool IsNegative = (a_Digest[0] >= 0x80);
	if (IsNegative)
	{
		// Two's complement:
		bool carry = true;  // Add one to the whole number
		for (int i = 19; i >= 0; i--)
		{
			a_Digest[i] = ~a_Digest[i];
			if (carry)
			{
				carry = (a_Digest[i] == 0xff);
				a_Digest[i]++;
			}
		}
	}
	a_Out.clear();
	a_Out.reserve(40);
	for (int i = 0; i < 20; i++)
	{
		AppendPrintf(a_Out, "%02x", a_Digest[i]);
	}
	while ((a_Out.length() > 0) && (a_Out[0] == '0'))
	{
		a_Out.erase(0, 1);
	}
	if (IsNegative)
	{
		a_Out.insert(0, "-");
	}
}
开发者ID:l0ud,项目名称:MCServer,代码行数:34,代码来源:Protocol132.cpp

示例8: convert

bool AMySQLServer::convert(MYSQL_ROW row, int index, AString& result)
{
  const char *p = row[index];
  result.clear();
  if (p)
    result = p;

  return true;
}
开发者ID:achacha,项目名称:AOS,代码行数:9,代码来源:AMySQLServer.cpp

示例9: main

int main()
{
  AFile_IOStream iosfile;
  AString str;
  while (AString::npos != iosfile.readLine(str))
  {
    std::cout << "'" << str << "'=" << str.getHash() << "\t" << str.getHash(0xff) << "\t" << str.getHash(0xf) << std::endl;
    str.clear();
  }
}
开发者ID:achacha,项目名称:AOS,代码行数:10,代码来源:tAStringHash.cpp

示例10: testXml

void testXml(int& iRet)
{
  //a_XML value parsing
  AString str;
  ANameValuePair nvPair(ANameValuePair::XML);
  size_t pos = 0;

  nvPair.parse("  \t \t   \n \r \r\n  iam   \r = \n \t  \"a'b'c'\" \r\n ", pos);
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str == "iam=\"a'b'c'\"", "Handling of single quote in double quote error", "0", iRet);

  pos = 0;
  str.clear();
  nvPair.parse("  \t \t   \n \r \r\n  iam   \r = \t  \"Myvalue's value\"  ", pos);
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str == "iam=\"Myvalue's value\"", "Handling of single quote in double quote error", "1", iRet);

  pos = 0;
  str.clear();
  nvPair.parse("iam = 'is \"quoted\" often'", pos);
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str == "iam='is \"quoted\" often'", "Handling of double quote in single quote error", "", iRet);
}
开发者ID:achacha,项目名称:AOS,代码行数:23,代码来源:ut_ANameValuePair_General.cpp

示例11: testSelect

void testSelect(ADatabase& db)
{
  AString error;
  AResultSet rs;
  
  u4 rows = db.executeSQL("SELECT * from global", rs, error);
  if (AString::npos == rows)
  {
    std::cerr << error << std::endl;
  }
  else
  {
    std::cout << "Selected " << rows << " rows." << std::endl;
    
    AXmlElement root("root");
    rs.emit(root);
    ARope rope;
    root.emitXml(rope, 0);
    std::cout << rope << std::endl;
  }

  u4 myNameCol = rs.getFieldIndex("name");
  u4 myValueCol = rs.getFieldIndex("value");
  for (u4 row=0; row<rs.getRowCount(); ++row)
  {
    const AString& name = rs.getData(row, myNameCol);
    if (name.equals("test_query"))
    {
      AQueryString qs(rs.getData(row, myValueCol));
      AString str;
      qs.emit(str);
      std::cout << "Query string detected: " << str << std::endl;
    }
    else if (name.equals("flags"))
    {
      ABitArray flags(rs.getData(row, myValueCol));
      AString str;
      flags.emit(str);
      std::cout << "Flags found: " << str << std::endl;

      str.clear();
      flags.setOutputMode(ABitArray::Binary);
      flags.emit(str);
      std::cout << "Flags found: " << str << std::endl;
    }
  }
}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例12: alibrary_Objects_Model_emitContentFromPath

/*!
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;
    }
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例13: main

int main(int argc, char* argv[])
{
  if (argc < 2)
  {
    std::cout << "Usage: this <database name> <query>" << std::endl;
    std::cout << "If <query> is omitted, database metadata is dumped" << std::endl;
    return -1;
  }

  AMySQLServer server(argv[1]);
  AString strError;
  if (!server.init(strError))
  {
    std::cout << strError << std::endl;
    return -1;
  }
  
  AString strQuery("select * from item where id=2");
  ADatabaseObject qr("myquery");
  if (!server.executeSQL(qr, strQuery, strError))
  {
    std::cout << strError << std::endl;
    return -1;
  }

  AElement element;
  AString result;
  qr.publish(&element);
  element.asXml(result);
  std::cout << result << std::endl;

  std::cout << "Only row 0" << std::endl;
  result.clear();
  const AObjectContainer& ns = qr.getRow(0);
  std::cout <<
    "id=" <<
    ns.getAs<AString>("id") <<
    " name=" <<
    ns.getAs<AString>("name") << 
    " weight=" << 
    ns.getAs<AString>("creator") << 
    std::endl;

  return 0;
}
开发者ID:achacha,项目名称:AOS,代码行数:45,代码来源:tMySQL_ADatabaseObject_generic_query.cpp

示例14: GetLineInternal

bool cSocketInputStream::GetLineInternal(AString & a_OutLine)
{
	a_OutLine.clear();
	for (;;)
	{
		char c;
		if (recv(m_Socket, &c, 1, 0) != 1)
		{
			return false;
		}
		if (c == 10)
		{
			return true;
		}
		else if (c != 13)
		{
			a_OutLine.push_back(c);
		}
	}
}
开发者ID:Seadragon91,项目名称:MCSchematicToPng,代码行数:20,代码来源:InputStream.cpp

示例15: generateRequest

String8 InitDataParser::generateRequest(const Vector<const uint8_t*>& keyIds) {
    const String8 kRequestPrefix("{\"kids\":[");
    const String8 kRequestSuffix("],\"type\":\"temporary\"}");
    const String8 kBase64Padding("=");

    String8 request(kRequestPrefix);
    AString encodedId;
    for (size_t i = 0; i < keyIds.size(); ++i) {
        encodedId.clear();
        android::encodeBase64Url(keyIds[i], kKeyIdSize, &encodedId);
        if (i != 0) {
            request.append(",");
        }
        request.appendFormat("\"%s\"", encodedId.c_str());
    }
    request.append(kRequestSuffix);

    // Android's Base64 encoder produces padding. EME forbids padding.
    request.removeAll(kBase64Padding);
    return request;
}
开发者ID:MIPS,项目名称:frameworks-av,代码行数:21,代码来源:InitDataParser.cpp


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