本文整理汇总了C++中aws::String::size方法的典型用法代码示例。如果您正苦于以下问题:C++ String::size方法的具体用法?C++ String::size怎么用?C++ String::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aws::String
的用法示例。
在下文中一共展示了String::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RedirectHomeToTempIfAppropriate
void RedirectHomeToTempIfAppropriate()
{
#if !defined(DISABLE_HOME_DIR_REDIRECT)
//Set $HOME to tmp on unix systems
std::stringstream tempDir; //( P_tmpdir );
tempDir << P_tmpdir;
Aws::String dir = tempDir.str().c_str();
if (dir.size() > 0 && *(dir.c_str() + dir.size() - 1) != Aws::FileSystem::PATH_DELIM)
{
tempDir << Aws::FileSystem::PATH_DELIM;
}
Aws::Environment::SetEnv("HOME", tempDir.str().c_str(), 1);
#endif // !defined(DISABLE_HOME_DIR_REDIRECT)
}
示例2: 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;
}
示例3: setp
SimpleStreamBuf::SimpleStreamBuf(const Aws::String& value) :
m_buffer(nullptr),
m_bufferSize(0)
{
size_t baseSize = (std::max)(value.size(), static_cast<std::size_t>(DEFAULT_BUFFER_SIZE));
m_buffer = Aws::NewArray<char>(baseSize, SIMPLE_STREAMBUF_ALLOCATION_TAG);
m_bufferSize = baseSize;
std::memcpy(m_buffer, value.c_str(), value.size());
char* begin = m_buffer;
char* end = begin + m_bufferSize;
setp(begin + value.size(), end);
setg(begin, begin, begin);
}
示例4: str
void SimpleStreamBuf::str(const Aws::String& value)
{
char* begin = m_buffer;
char* end = begin + m_bufferSize;
setp(begin, end);
setg(begin, begin, begin);
xsputn(value.c_str(), value.size());
}
示例5: CreateDirectoryIfNotExists
bool CreateDirectoryIfNotExists(const char* path, bool createParentDirs)
{
Aws::String directoryName = path;
AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Creating directory " << directoryName);
// Create intermediate directories or create the target directory once.
for (size_t i = createParentDirs ? 0 : directoryName.size() - 1; i < directoryName.size(); i++)
{
// Create the intermediate directory if we find a delimiter and the delimiter is not the first char, or if this is the target directory.
if (i != 0 && (directoryName[i] == FileSystem::PATH_DELIM || i == directoryName.size() - 1))
{
// the last delimeter can be removed safely.
if (directoryName[i] == FileSystem::PATH_DELIM)
{
directoryName[i] = '\0';
}
if (CreateDirectoryW(ToLongPath(StringUtils::ToWString(directoryName.c_str())).c_str(), nullptr))
{
AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "Creation of directory " << directoryName.c_str() << " succeeded.");
}
else
{
DWORD errorCode = GetLastError();
if (errorCode != ERROR_ALREADY_EXISTS && errorCode != NO_ERROR) // in vs2013 the errorCode is NO_ERROR
{
AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, " Creation of directory " << directoryName.c_str() << " returned code: " << errorCode);
return false;
}
AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, " Creation of directory " << directoryName.c_str() << " returned code: " << errorCode);
}
// Restore the path. We are good even if we didn't change that char to '\0', because we are ready to return.
directoryName[i] = FileSystem::PATH_DELIM;
}
}
return true;
}
示例6: input
Aws::Vector<Aws::String> StringUtils::SplitOnLine(const Aws::String& toSplit)
{
Aws::StringStream input(toSplit);
Aws::Vector<Aws::String> returnValues;
Aws::String item;
while (std::getline(input, item))
{
if (item.size() > 0)
{
returnValues.push_back(item);
}
}
return std::move(returnValues);
}
示例7: GetHomeDirectory
Aws::String GetHomeDirectory()
{
static const char* HOME_DIR_ENV_VAR = "USERPROFILE";
AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Checking " << HOME_DIR_ENV_VAR << " for the home directory.");
Aws::String homeDir = Aws::Environment::GetEnv(HOME_DIR_ENV_VAR);
AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "Environment value for variable " << HOME_DIR_ENV_VAR << " is " << homeDir);
if(homeDir.empty())
{
AWS_LOGSTREAM_WARN(FILE_SYSTEM_UTILS_LOG_TAG, "Home dir not stored in environment, trying to fetch manually from the OS.");
HANDLE hToken;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken))
{
DWORD len = MAX_PATH;
WCHAR path[MAX_PATH];
if (GetUserProfileDirectoryW(hToken, path, &len))
{
homeDir = Aws::Utils::StringUtils::FromWString(path);
}
CloseHandle(hToken);
}
AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Pulled " << homeDir << " as home directory from the OS.");
}
Aws::String retVal = (homeDir.size() > 0) ? Aws::Utils::StringUtils::Trim(homeDir.c_str()) : "";
if (!retVal.empty())
{
if (retVal.at(retVal.length() - 1) != Aws::FileSystem::PATH_DELIM)
{
retVal += Aws::FileSystem::PATH_DELIM;
}
}
return retVal;
}
示例8: CreateFromXmlString
XmlDocument XmlDocument::CreateFromXmlString(const Aws::String& xmlText)
{
XmlDocument xmlDocument;
xmlDocument.m_doc->Parse(xmlText.c_str(), xmlText.size());
return xmlDocument;
}