本文整理汇总了C++中core::string::size方法的典型用法代码示例。如果您正苦于以下问题:C++ string::size方法的具体用法?C++ string::size怎么用?C++ string::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core::string
的用法示例。
在下文中一共展示了string::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//! returns the directory part of a filename, i.e. all until the first
//! slash or backslash, excluding it. If no directory path is prefixed, a '.'
//! is returned.
core::string<c16> CFileSystem::getFileDir(const core::string<c16>& filename) const
{
// find last forward or backslash
s32 lastSlash = filename.findLast('/');
const s32 lastBackSlash = filename.findLast('\\');
lastSlash = lastSlash > lastBackSlash ? lastSlash : lastBackSlash;
if ((u32)lastSlash < filename.size())
return filename.subString(0, lastSlash);
else
return ".";
}
示例2: if
//! returns the base part of a filename, i.e. all except for the directory
//! part. If no directory path is prefixed, the full name is returned.
core::string<c16> CFileSystem::getFileBasename(const core::string<c16>& filename, bool keepExtension) const
{
// find last forward or backslash
s32 lastSlash = filename.findLast('/');
const s32 lastBackSlash = filename.findLast('\\');
lastSlash = core::max_(lastSlash, lastBackSlash);
s32 end = 0;
if (!keepExtension)
{
end = filename.findLast('.');
if (end == -1)
end=0;
else
end = filename.size()-end;
}
if ((u32)lastSlash < filename.size())
return filename.subString(lastSlash+1, filename.size()-lastSlash-1-end);
else if (end != 0)
return filename.subString(0, filename.size()-end);
else
return filename;
}
示例3: defined
core::string<c16> CFileSystem::getAbsolutePath(const core::string<c16>& filename) const
{
c16 *p=0;
#if defined(_IRR_USE_WINDOWS_CE_DEVICE_)
return filename;
#elif defined(_IRR_WINDOWS_API_)
#if defined(_IRR_WCHAR_FILESYSTEM )
c16 fpath[_MAX_PATH];
p = _wfullpath(fpath, filename.c_str(), _MAX_PATH);
#else
c8 fpath[_MAX_PATH];
p = _fullpath(fpath, filename.c_str(), _MAX_PATH);
#endif
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
c8 fpath[4096];
fpath[0]=0;
p = realpath(filename.c_str(), fpath);
if (!p)
{
// content in fpath is undefined at this point
if ('0'==fpath[0]) // seems like fpath wasn't altered
{
// at least remove a ./ prefix
if ('.'==filename[0] && '/'==filename[1])
return filename.subString(2, filename.size()-2);
else
return filename;
}
else
return core::string<c16>(fpath);
}
#endif
return core::string<c16>(p);
}
示例4: encrypt
NNT_BEGIN_HEADER_C
# include <openssl/des.h>
# include <math.h>
NNT_END_HEADER_C
NNT_BEGIN_CXX
void des::encrypt(char const* key, core::string const& in, core::vector<byte>& out)
{
DES_cblock key_block;
DES_key_schedule schedule;
DES_string_to_key(key, &key_block);
DES_set_key_checked(&key_block, &schedule);
usize sz = (usize)ceil((double)in.size() / sizeof(DES_cblock)) * sizeof(DES_cblock);
out.resize(sz);
core::string::const_iterator iter = in.begin();
DES_cblock* output = (DES_cblock*)core::pointer(out);
DES_cblock input;
while (iter != in.end())
{
usize sz = in.end() - iter;
if (sz >= 8)
sz = 8;
else
memset(input, 0, sizeof(DES_cblock));
memcpy(input, &*iter, sz);
DES_ecb_encrypt(&input, output, &schedule, DES_ENCRYPT);
iter += sz;
output += 1;
}
}