本文整理汇总了C++中AString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::size方法的具体用法?C++ AString::size怎么用?C++ AString::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: H
static void H(const AString &s, AString *out) {
out->clear();
MD5_CTX m;
MD5_Init(&m);
MD5_Update(&m, s.c_str(), s.size());
uint8_t key[16];
MD5_Final(key, &m);
for (size_t i = 0; i < 16; ++i) {
char nibble = key[i] >> 4;
if (nibble <= 9) {
nibble += '0';
} else {
nibble += 'a' - 10;
}
out->append(&nibble, 1);
nibble = key[i] & 0x0f;
if (nibble <= 9) {
nibble += '0';
} else {
nibble += 'a' - 10;
}
out->append(&nibble, 1);
}
}
示例2: Save
bool cScoreboardSerializer::Save(void)
{
cFastNBTWriter Writer;
SaveScoreboardToNBT(Writer);
Writer.Finish();
#ifdef _DEBUG
cParsedNBT TestParse(Writer.GetResult().data(), Writer.GetResult().size());
ASSERT(TestParse.IsValid());
#endif // _DEBUG
cFile File;
if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite))
{
return false;
}
AString Compressed;
int res = CompressStringGZIP(Writer.GetResult().data(), Writer.GetResult().size(), Compressed);
if (res != Z_OK)
{
return false;
}
File.Write(Compressed.data(), Compressed.size());
File.Close();
return true;
}
示例3: Start
Bool HawkProfiler::Start(const AString& sAddr)
{
if (!m_bRunning)
{
if (sAddr.size())
m_sAddr = sAddr;
GetProcessorNumber();
GetTotalMem();
GetCpuUsage();
GetMemUsage();
if(!m_sSocket.Create(AF_INET,SOCK_DGRAM,IPPROTO_UDP))
{
HawkPrint("Profiler Init Socket Error.");
return false;
}
m_sSocket.SetNoDelay(true);
m_sSocket.SetBlocking(false);
if(!m_sSocket.Bind(SocketAddr(m_sAddr)))
{
HawkPrint("Profiler Bind Socket Error.");
return false;
}
m_bRunning = true;
m_pThread = new HawkThread(hawk_ProfilerRoutine);
m_pThread->Start(this);
return true;
}
return false;
}
示例4: TrustSession
Bool HsGateway::TrustSession(void* pSession, OctetsStream* pIBuffer)
{
if (pSession && pIBuffer)
{
//QQ平台网关校验信息过滤
if (m_iPlatform == 1)
{
if (pIBuffer->AvailableSize() >= TGW_BUFFER_SIZE)
{
AString sTgw = (Char*)pIBuffer->AvailableData();
#ifdef _DEBUG
HawkFmtPrint("TGW: %s", sTgw.c_str());
#endif
Bool bStart = HawkStringUtil::BeginWith<AString>(sTgw, "tgw_l7_forward");
Bool bEnd = HawkStringUtil::EndWith<AString>(sTgw, "\r\n\r\n");
if (bStart && bEnd)
{
UInt32 iCrc = HawkOSOperator::CalcCrc((const UChar*)sTgw.c_str(),(UInt32)sTgw.size());
UInt32* pCrc = (UInt32*)((Char*)pIBuffer->AvailableData() + (TGW_BUFFER_SIZE - sizeof(UInt32)));
if (pCrc && iCrc == *pCrc)
{
pIBuffer->MoveNonius(TGW_BUFFER_SIZE);
return true;
}
}
}
return false;
}
}
return true;
}
示例5: LoadFromSchematicFile
bool cSchematicFileSerializer::LoadFromSchematicFile(cBlockArea & a_BlockArea, const AString & a_FileName)
{
// Un-GZip the contents:
AString Contents;
cGZipFile File;
if (!File.Open(a_FileName, cGZipFile::fmRead))
{
LOG("Cannot open the schematic file \"%s\".", a_FileName.c_str());
return false;
}
int NumBytesRead = File.ReadRestOfFile(Contents);
if (NumBytesRead < 0)
{
LOG("Cannot read GZipped data in the schematic file \"%s\", error %d", a_FileName.c_str(), NumBytesRead);
return false;
}
File.Close();
// Parse the NBT:
cParsedNBT NBT(Contents.data(), Contents.size());
if (!NBT.IsValid())
{
LOG("Cannot parse the NBT in the schematic file \"%s\".", a_FileName.c_str());
return false;
}
return LoadFromSchematicNBT(a_BlockArea, NBT);
}
示例6: AppendCommonResponse
status_t WifiDisplaySource::sendM16(int32_t sessionID) {
AString request = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
AppendCommonResponse(&request, mNextCSeq);
CHECK_EQ(sessionID, mClientSessionID);
request.append(
StringPrintf("Session: %d\r\n", mClientInfo.mPlaybackSessionID));
request.append("\r\n"); // Empty body
status_t err =
mNetSession->sendRequest(sessionID, request.c_str(), request.size());
if (err != OK) {
return err;
}
registerResponseHandler(
sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM16Response);
++mNextCSeq;
scheduleKeepAlive(sessionID);
return OK;
}
示例7: DataReceived
void cProtocolRecognizer::DataReceived(const char * a_Data, int a_Size)
{
if (m_Protocol == NULL)
{
if (!m_Buffer.Write(a_Data, a_Size))
{
m_Client->Kick("Unsupported protocol version");
return;
}
if (!TryRecognizeProtocol())
{
return;
}
// The protocol has just been recognized, dump the whole m_Buffer contents into it for parsing:
AString Dump;
m_Buffer.ResetRead();
m_Buffer.ReadAll(Dump);
m_Protocol->DataReceived(Dump.data(), Dump.size());
}
else
{
m_Protocol->DataReceived(a_Data, a_Size);
}
}
示例8: LoadFromString
bool cPrefabPiecePool::LoadFromString(const AString & a_Contents, const AString & a_FileName, bool a_LogWarnings)
{
// If the contents start with GZip signature, ungzip and retry:
if (a_Contents.substr(0, 3) == "\x1f\x8b\x08")
{
AString Uncompressed;
auto res = UncompressStringGZIP(a_Contents.data(), a_Contents.size(), Uncompressed);
if (res == Z_OK)
{
return LoadFromString(Uncompressed, a_FileName, a_LogWarnings);
}
else
{
CONDWARNING(a_LogWarnings, "Failed to decompress Gzip data in file %s: %d", a_FileName.c_str(), res);
return false;
}
}
// Search the first 8 KiB of the file for the format auto-detection string:
auto Header = a_Contents.substr(0, 8192);
if (Header.find("CubesetFormatVersion =") != AString::npos)
{
return LoadFromCubeset(a_Contents, a_FileName, a_LogWarnings);
}
CONDWARNING(a_LogWarnings, "Cannot load prefabs from file %s, unknown file format", a_FileName.c_str());
return false;
}
示例9: Push
void cLuaState::Push(const AString & a_String)
{
ASSERT(IsValid());
lua_pushlstring(m_LuaState, a_String.data(), a_String.size());
m_NumCurrentFunctionArgs += 1;
}
示例10: Initialize
bool cHTTPServer::Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6)
{
// Read the HTTPS cert + key:
AString CertFile = cFile::ReadWholeFile("webadmin/httpscert.crt");
AString KeyFile = cFile::ReadWholeFile("webadmin/httpskey.pem");
if (!CertFile.empty() && !KeyFile.empty())
{
m_Cert.reset(new cX509Cert);
int res = m_Cert->Parse(CertFile.data(), CertFile.size());
if (res == 0)
{
m_CertPrivKey.reset(new cCryptoKey);
int res2 = m_CertPrivKey->ParsePrivate(KeyFile.data(), KeyFile.size(), "");
if (res2 != 0)
{
// Reading the private key failed, reset the cert:
LOGWARNING("WebServer: Cannot read HTTPS certificate private key: -0x%x", -res2);
m_Cert.reset();
}
}
else
{
LOGWARNING("WebServer: Cannot read HTTPS certificate: -0x%x", -res);
}
}
// Notify the admin about the HTTPS / HTTP status
if (m_Cert.get() == NULL)
{
LOGWARNING("WebServer: The server is running in unsecure HTTP mode.");
}
else
{
LOGINFO("WebServer: The server is running in secure HTTPS mode.");
}
// Open up requested ports:
bool HasAnyPort;
HasAnyPort = m_ListenThreadIPv4.Initialize(a_PortsIPv4);
HasAnyPort = m_ListenThreadIPv6.Initialize(a_PortsIPv6) || HasAnyPort;
if (!HasAnyPort)
{
return false;
}
return true;
}
示例11: StartTLSServer
AString cLuaTCPLink::StartTLSServer(
const AString & a_OwnCertData,
const AString & a_OwnPrivKeyData,
const AString & a_OwnPrivKeyPassword,
const AString & a_StartTLSData
)
{
// Check preconditions:
if (m_SslContext != nullptr)
{
return "TLS is already active on this link";
}
if (a_OwnCertData.empty() || a_OwnPrivKeyData.empty())
{
return "Provide the server certificate and private key";
}
// Create the SSL context:
m_SslContext.reset(new cLinkSslContext(*this));
m_SslContext->Initialize(false);
// Create the peer cert:
auto OwnCert = std::make_shared<cX509Cert>();
int res = OwnCert->Parse(a_OwnCertData.data(), a_OwnCertData.size());
if (res != 0)
{
m_SslContext.reset();
return Printf("Cannot parse server certificate: -0x%x", res);
}
auto OwnPrivKey = std::make_shared<cCryptoKey>();
res = OwnPrivKey->ParsePrivate(a_OwnPrivKeyData.data(), a_OwnPrivKeyData.size(), a_OwnPrivKeyPassword);
if (res != 0)
{
m_SslContext.reset();
return Printf("Cannot parse server private key: -0x%x", res);
}
m_SslContext->SetOwnCert(OwnCert, OwnPrivKey);
m_SslContext->SetSelf(cLinkSslContextWPtr(m_SslContext));
// Push the initial data:
m_SslContext->StoreReceivedData(a_StartTLSData.data(), a_StartTLSData.size());
// Start the handshake:
m_SslContext->Handshake();
return "";
}
示例12:
cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) :
m_CurrentStack(0)
{
m_Stack[0].m_Type = TAG_Compound;
m_Result.reserve(100 * 1024);
m_Result.push_back(TAG_Compound);
WriteString(a_RootTagName.data(), a_RootTagName.size());
}
示例13: sendTrigger
status_t WifiDisplaySource::sendTrigger(
int32_t sessionID, TriggerType triggerType) {
AString body = "wfd_trigger_method: ";
switch (triggerType) {
case TRIGGER_SETUP:
body.append("SETUP");
break;
case TRIGGER_TEARDOWN:
ALOGI("Sending TEARDOWN trigger.");
body.append("TEARDOWN");
break;
case TRIGGER_PAUSE:
body.append("PAUSE");
break;
case TRIGGER_PLAY:
body.append("PLAY");
break;
default:
TRESPASS();
}
body.append("\r\n");
AString request = "SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
AppendCommonResponse(&request, mNextCSeq);
request.append("Content-Type: text/parameters\r\n");
request.append(AStringPrintf("Content-Length: %d\r\n", body.size()));
request.append("\r\n");
request.append(body);
status_t err =
mNetSession->sendRequest(sessionID, request.c_str(), request.size());
if (err != OK) {
return err;
}
registerResponseHandler(
sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM5Response);
++mNextCSeq;
return OK;
}
示例14: splitString
bool splitString(const AString &s, const AString &delimiter, AString *s1, AString *s2) {
ssize_t pos = s.find(delimiter.c_str());
if (pos < 0) {
return false;
}
*s1 = AString(s, 0, pos);
*s2 = AString(s, pos + 1, s.size() - pos - 1);
return true;
}
示例15: Lock
void cProtocol125::SendEntityMetadata(const cEntity & a_Entity)
{
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_METADATA);
WriteInt (a_Entity.GetUniqueID());
AString MetaData = GetEntityMetaData(a_Entity);
SendData(MetaData.data(), MetaData.size());
Flush();
}