本文整理汇总了C++中aws::String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String::length方法的具体用法?C++ String::length怎么用?C++ String::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aws::String
的用法示例。
在下文中一共展示了String::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateSummary
Aws::String GenerateSummary(time_t now)
{
time_t tempEndTime = (activeState == COMPLETE) ? endTime : now;
time_t tempStartTime = (startTime != 0) ? startTime : now;
Aws::String temp;
temp = std::to_string(tempEndTime - tempStartTime).c_str();
while (temp.length() < 12)
temp = " " + temp;
temp += " ms, ";
switch (finishState)
{
case PASSED: temp += "pass: "; break;
case FAILED: temp += "FAILED: "; break;
case SKIPPED: temp += "SKIPPED: "; break;
case TIMEDOUT: temp += "TIMED OUT: "; break;
}
temp += testName;
if (testResultMsg.length() > 0)
{
temp += " - ";
temp += testResultMsg;
}
return temp;
}
示例2: signingKey
Aws::String AWSAuthV4Signer::GenerateSignature(const AWSCredentials& credentials, const Aws::String& stringToSign, const Aws::String& simpleDate, const Aws::String& regionName) const
{
AWS_LOGSTREAM_DEBUG(v4LogTag, "Final String to sign: " << stringToSign);
Aws::StringStream ss;
//now we do the complicated part of deriving a signing key.
Aws::String signingKey(SIGNING_KEY);
signingKey.append(credentials.GetAWSSecretKey());
//we use digest only for the derivation process.
auto hashResult = m_HMAC->Calculate(ByteBuffer((unsigned char*)simpleDate.c_str(), simpleDate.length()),
ByteBuffer((unsigned char*)signingKey.c_str(), signingKey.length()));
if (!hashResult.IsSuccess())
{
AWS_LOGSTREAM_ERROR(v4LogTag, "Failed to hmac (sha256) date string \"" << simpleDate << "\"");
return "";
}
auto kDate = hashResult.GetResult();
hashResult = m_HMAC->Calculate(ByteBuffer((unsigned char*)regionName.c_str(), regionName.length()), kDate);
if (!hashResult.IsSuccess())
{
AWS_LOGSTREAM_ERROR(v4LogTag, "Failed to hmac (sha256) region string \"" << regionName << "\"");
return "";
}
auto kRegion = hashResult.GetResult();
hashResult = m_HMAC->Calculate(ByteBuffer((unsigned char*)m_serviceName.c_str(), m_serviceName.length()), kRegion);
if (!hashResult.IsSuccess())
{
AWS_LOGSTREAM_ERROR(v4LogTag, "Failed to hmac (sha256) service string \"" << m_serviceName << "\"");
return "";
}
auto kService = hashResult.GetResult();
hashResult = m_HMAC->Calculate(ByteBuffer((unsigned char*)AWS4_REQUEST, strlen(AWS4_REQUEST)), kService);
if (!hashResult.IsSuccess())
{
AWS_LOGSTREAM_ERROR(v4LogTag, "Unable to hmac (sha256) request string \"" << AWS4_REQUEST << "\"");
return "";
}
auto kSigning = hashResult.GetResult();
hashResult = m_HMAC->Calculate(ByteBuffer((unsigned char*)stringToSign.c_str(), stringToSign.length()), kSigning);
if (!hashResult.IsSuccess())
{
AWS_LOGSTREAM_ERROR(v4LogTag, "Unable to hmac (sha256) final string \"" << stringToSign << "\"");
return "";
}
//now we finally sign our request string with our hex encoded derived hash.
auto finalSigningDigest = hashResult.GetResult();
auto finalSigningHash = HashingUtils::HexEncode(finalSigningDigest);
AWS_LOGSTREAM_DEBUG(v4LogTag, "Final computed signing hash: " << finalSigningHash);
return finalSigningHash;
}
示例3: ExtractAndSetPath
void URI::ExtractAndSetPath(const Aws::String& uri)
{
size_t authorityStart = uri.find(SEPARATOR);
if (authorityStart == Aws::String::npos)
{
authorityStart = 0;
}
else
{
authorityStart += 3;
}
size_t pathEnd = uri.find('?');
if (pathEnd == Aws::String::npos)
{
pathEnd = uri.length();
}
Aws::String authorityAndPath = uri.substr(authorityStart, pathEnd - authorityStart);
size_t pathStart = authorityAndPath.find('/');
if (pathStart != Aws::String::npos)
{
SetPath(authorityAndPath.substr(pathStart, pathEnd - pathStart), false);
}
else
{
SetPath("/");
}
}
示例4: hash
HashResult Sha256CommonCryptoImpl::Calculate(const Aws::String& str)
{
ByteBuffer hash(CC_SHA256_DIGEST_LENGTH);
CC_SHA256(str.c_str(), str.length(), hash.GetUnderlyingData());
return HashResult(std::move(hash));
}
示例5: SetPath
void URI::SetPath(const Aws::String& value, bool shouldEncode)
{
//we need to url encode the path parts (mainly to take care of spaces that a user might put here)
if (shouldEncode)
{
Aws::Vector<Aws::String> pathParts = StringUtils::Split(value, '/');
Aws::StringStream ss;
for (Aws::Vector<Aws::String>::iterator iter = pathParts.begin(); iter != pathParts.end(); ++iter)
{
ss << '/' << StringUtils::URLEncode(iter->c_str());
}
//if the last character was also a slash, then add that back here.
if (value[value.length() - 1] == '/')
{
ss << '/';
}
path = ss.str();
}
else
{
path = value;
}
}
示例6: hash
HashResult MD5CommonCryptoImpl::Calculate(const Aws::String& str)
{
ByteBuffer hash(CC_MD5_DIGEST_LENGTH);
CC_MD5(str.c_str(), static_cast<CC_LONG>(str.length()), hash.GetUnderlyingData());
return HashResult(std::move(hash));
}
示例7: WriteHeader
size_t CurlHttpClient::WriteHeader(char* ptr, size_t size, size_t nmemb, void* userdata)
{
if (ptr)
{
AWS_LOGSTREAM_TRACE(CURL_HTTP_CLIENT_TAG, ptr);
HttpResponse* response = (HttpResponse*) userdata;
Aws::String headerLine(ptr);
Aws::Vector<Aws::String> keyValuePair = StringUtils::Split(headerLine, ':');
if (keyValuePair.size() > 1)
{
Aws::String headerName = keyValuePair[0];
headerName = StringUtils::Trim(headerName.c_str());
Aws::String headerValue = headerLine.substr(headerName.length() + 1).c_str();
headerValue = StringUtils::Trim(headerValue.c_str());
response->AddHeader(headerName, headerValue);
}
return size * nmemb;
}
return 0;
}
示例8: Join
Aws::String Join(char delimiter, const Aws::String& leftSegment, const Aws::String& rightSegment)
{
Aws::StringStream ss;
if (!leftSegment.empty())
{
if (leftSegment.back() == delimiter)
{
ss << leftSegment.substr(0, leftSegment.length() - 1);
}
else
{
ss << leftSegment;
}
}
ss << delimiter;
if (!rightSegment.empty())
{
if (rightSegment.front() == delimiter)
{
ss << rightSegment.substr(1);
}
else
{
ss << rightSegment;
}
}
return ss.str();
}
示例9: WriteCompact
void JsonValue::WriteCompact(Aws::OStream& ostream, bool treatAsObject) const
{
if (treatAsObject && m_value.isNull())
{
ostream << "{}";
return;
}
Aws::String compactString = WriteCompact();
ostream.write(compactString.c_str(), compactString.length());
}
示例10: escapedHexStr
UUID::UUID(const Aws::String& uuidToConvert)
{
//GUID has 2 characters per byte + 4 dashes = 36 bytes
assert(uuidToConvert.length() == UUID_STR_SIZE);
memset(m_uuid, 0, sizeof(m_uuid));
Aws::String escapedHexStr(uuidToConvert);
StringUtils::Replace(escapedHexStr, "-", "");
assert(escapedHexStr.length() == UUID_BINARY_SIZE * 2);
ByteBuffer&& rawUuid = HashingUtils::HexDecode(escapedHexStr);
memcpy(m_uuid, rawUuid.GetUnderlyingData(), rawUuid.GetLength());
}
示例11: policy
TEST_F(QueueOperationTest, TestPermissions)
{
Aws::String queueUrl = CreateDefaultQueue(PERMISSIONS_QUEUE_NAME);
ASSERT_TRUE(queueUrl.find(PERMISSIONS_QUEUE_NAME) != Aws::String::npos);
AddPermissionRequest addPermissionRequest;
addPermissionRequest.AddAWSAccountIds(m_accountId).AddActions("ReceiveMessage").WithLabel("Test").WithQueueUrl(
queueUrl);
AddPermissionOutcome permissionOutcome = sqsClient->AddPermission(addPermissionRequest);
ASSERT_TRUE(permissionOutcome.IsSuccess());
GetQueueAttributesRequest queueAttributesRequest;
queueAttributesRequest.AddAttributeNames(QueueAttributeName::Policy).WithQueueUrl(queueUrl);
GetQueueAttributesOutcome queueAttributesOutcome = sqsClient->GetQueueAttributes(queueAttributesRequest);
ASSERT_TRUE(queueAttributesOutcome.IsSuccess());
Aws::String policyString = queueAttributesOutcome.GetResult().GetAttributes().find(QueueAttributeName::Policy)->second;
EXPECT_TRUE(policyString.length() > 0);
JsonValue policy(policyString);
EXPECT_EQ(addPermissionRequest.GetLabel(), policy.GetArray("Statement")[0].GetString("Sid"));
EXPECT_EQ(m_accountId, policy.GetArray("Statement")[0].GetObject("Principal").GetString("AWS"));
EXPECT_EQ("SQS:ReceiveMessage", policy.GetArray("Statement")[0].GetString("Action"));
RemovePermissionRequest removePermissionRequest;
removePermissionRequest.WithLabel("Test").WithQueueUrl(queueUrl);
RemovePermissionOutcome removePermissionOutcome = sqsClient->RemovePermission(removePermissionRequest);
ASSERT_TRUE(removePermissionOutcome.IsSuccess());
queueAttributesOutcome = sqsClient->GetQueueAttributes(queueAttributesRequest);
ASSERT_TRUE(queueAttributesOutcome.IsSuccess());
policyString = queueAttributesOutcome.GetResult().GetAttributes().find(QueueAttributeName::Policy)->second;
EXPECT_TRUE(policyString.length() > 0);
JsonValue emptyPolicy(policyString);
EXPECT_EQ(0uL, emptyPolicy.GetArray("Statement").GetLength());
DeleteQueueRequest deleteQueueRequest;
deleteQueueRequest.WithQueueUrl(queueUrl);
DeleteQueueOutcome deleteQueueOutcome = sqsClient->DeleteQueue(deleteQueueRequest);
ASSERT_TRUE(deleteQueueOutcome.IsSuccess());
}
示例12:
TEST(StringUtilsTest, TestWStringNonAsciiToString)
{
AWS_BEGIN_MEMORY_TEST(16, 10)
Aws::WString startString;
// Toss in a couple ascii characters to start, then go over 127
const char startVal = 115;
int addValue = startVal;
const char incrementVal = 10;
const char loopCount = 10;
for (char i = 0; i < loopCount; ++i)
{
startString.push_back(static_cast<wchar_t>(addValue));
addValue += incrementVal;
}
Aws::String outString = StringUtils::FromWString(startString.c_str());
ASSERT_EQ(outString.length(), loopCount);
for (size_t i = 0; i < outString.length(); ++i)
{
char testValue = outString[i];
ASSERT_EQ(testValue, static_cast<char>(startVal + incrementVal * i));
}
// This loop will cross the byte limit
for (char i = 0; i < loopCount; ++i)
{
startString.push_back(static_cast<wchar_t>(addValue));
addValue += incrementVal;
}
// Verify the length, not the values though
outString = StringUtils::FromWString(startString.c_str());
ASSERT_EQ(outString.length(), loopCount * 2);
AWS_END_MEMORY_TEST
}
示例13:
TEST(UUIDTest, TestPlatformGeneratesUUID)
{
Aws::Set<Aws::String> generatedUUids;
for(size_t i = 0u; i < 1000u; ++i)
{
UUID uuid = UUID::RandomUUID();
Aws::String uuidStr = uuid;
ASSERT_EQ(36u, uuidStr.length());
ByteBuffer rawUUID = uuid;
ASSERT_EQ(16u, rawUUID.GetLength());
ASSERT_EQ(0x40u, 0x40u & rawUUID[6]);
ASSERT_EQ(0x80u, 0x80u & rawUUID[8]);
ASSERT_EQ(generatedUUids.end(), generatedUUids.find(uuidStr));
generatedUUids.insert(uuidStr);
}
}
示例14: URLEncodePath
Aws::String URI::URLEncodePath(const Aws::String& path)
{
Aws::Vector<Aws::String> pathParts = StringUtils::Split(path, '/');
Aws::StringStream ss;
for (Aws::Vector<Aws::String>::iterator iter = pathParts.begin(); iter != pathParts.end(); ++iter)
{
ss << '/' << StringUtils::URLEncode(iter->c_str());
}
//if the last character was also a slash, then add that back here.
if (path[path.length() - 1] == '/')
{
ss << '/';
}
return ss.str();
}
示例15: Calculate
HashResult BCryptHashImpl::Calculate(const Aws::String& str)
{
if (!IsValid())
{
return HashResult();
}
std::lock_guard<std::mutex> locker(m_algorithmMutex);
BCryptHashContext context(m_algorithmHandle, m_hashObject, m_hashObjectLength);
if (!context.IsValid())
{
AWS_LOG_ERROR(logTag, "Error creating hash handle.");
return HashResult();
}
return HashData(context, (PBYTE)str.c_str(), static_cast<ULONG>(str.length()));
}