本文整理汇总了C++中aws::String::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ String::substr方法的具体用法?C++ String::substr怎么用?C++ String::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aws::String
的用法示例。
在下文中一共展示了String::substr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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("/");
}
}
示例2: if
AWSError<CoreErrors> AWSErrorMarshaller::Marshall(const Aws::String& exceptionName, const Aws::String& message) const
{
auto locationOfPound = exceptionName.find_first_of('#');
auto locationOfColon = exceptionName.find_first_of(':');
Aws::String formalExceptionName;
if (locationOfPound != Aws::String::npos)
{
formalExceptionName = exceptionName.substr(locationOfPound + 1);
}
else if (locationOfColon != Aws::String::npos)
{
formalExceptionName = exceptionName.substr(0, locationOfColon);
}
else
{
formalExceptionName = exceptionName;
}
AWSError<CoreErrors> error = FindErrorByName(formalExceptionName.c_str());
if (error.GetErrorType() != CoreErrors::UNKNOWN)
{
AWS_LOG_WARN(logTag, "Encountered AWSError\n%s\n%s:", formalExceptionName.c_str(), message.c_str());
error.SetExceptionName(formalExceptionName);
error.SetMessage(message);
return error;
}
AWS_LOG_WARN(logTag, "Encountered Unknown AWSError\n%s\n%s:", exceptionName.c_str(), message.c_str());
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, exceptionName, "Unable to parse ExceptionName: " + exceptionName + " Message: " + message, false);
}
示例3: 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();
}
示例4: GetQueryStringParameters
QueryStringParameterCollection URI::GetQueryStringParameters(bool decode) const
{
Aws::String queryString = GetQueryString();
QueryStringParameterCollection parameterCollection;
//if we actually have a query string
if (queryString.size() > 0)
{
size_t currentPos = 1, locationOfNextDelimiter = 1;
//while we have params left to parse
while (currentPos < queryString.size())
{
//find next key/value pair
locationOfNextDelimiter = queryString.find('&', currentPos);
Aws::String keyValuePair;
//if this isn't the last parameter
if (locationOfNextDelimiter != Aws::String::npos)
{
keyValuePair = queryString.substr(currentPos, locationOfNextDelimiter - currentPos);
}
//if it is the last parameter
else
{
keyValuePair = queryString.substr(currentPos);
}
//split on =
size_t locationOfEquals = keyValuePair.find('=');
Aws::String key = keyValuePair.substr(0, locationOfEquals);
Aws::String value = keyValuePair.substr(locationOfEquals + 1);
if(decode)
{
parameterCollection[StringUtils::URLDecode(key.c_str())] = StringUtils::URLDecode(value.c_str());
}
else
{
parameterCollection[key] = value;
}
currentPos += keyValuePair.size() + 1;
}
}
return parameterCollection;
}
示例5: ExtractAndSetQueryString
void URI::ExtractAndSetQueryString(const Aws::String& uri)
{
size_t queryStart = uri.find('?');
if (queryStart != Aws::String::npos)
{
queryString = uri.substr(queryStart);
}
}
示例6: GetProfileDirectory
Aws::String ProfileConfigFileAWSCredentialsProvider::GetProfileDirectory()
{
Aws::String profileFileName = GetCredentialsProfileFilename();
auto lastSeparator = profileFileName.find_last_of(DIRECTORY_JOIN);
if (lastSeparator != std::string::npos)
{
return profileFileName.substr(0, lastSeparator);
}
else
{
return "";
}
}
示例7: ExtractAndSetScheme
void URI::ExtractAndSetScheme(const Aws::String& uri)
{
size_t posOfSeparator = uri.find(SEPARATOR);
if (posOfSeparator != Aws::String::npos)
{
Aws::String schemePortion = uri.substr(0, posOfSeparator);
SetScheme(SchemeMapper::FromString(schemePortion.c_str()));
}
else
{
SetScheme(Scheme::HTTP);
}
}
示例8: ExtractAndSetAuthority
void URI::ExtractAndSetAuthority(const Aws::String& uri)
{
size_t authorityStart = uri.find(SEPARATOR);
if (authorityStart == Aws::String::npos)
{
authorityStart = 0;
}
else
{
authorityStart += 3;
}
size_t posOfEndOfAuthorityPort = uri.find(':', authorityStart);
size_t posOfEndOfAuthoritySlash = uri.find('/', authorityStart);
size_t posOfEndOfAuthorityQuery = uri.find('?', authorityStart);
size_t posEndOfAuthority = std::min({posOfEndOfAuthorityPort, posOfEndOfAuthoritySlash, posOfEndOfAuthorityQuery});
if (posEndOfAuthority == Aws::String::npos)
{
posEndOfAuthority = uri.length();
}
SetAuthority(uri.substr(authorityStart, posEndOfAuthority - authorityStart));
}