本文整理汇总了C++中STRING::compare方法的典型用法代码示例。如果您正苦于以下问题:C++ STRING::compare方法的具体用法?C++ STRING::compare怎么用?C++ STRING::compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STRING
的用法示例。
在下文中一共展示了STRING::compare方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNumberOfFilesAndSubfolders
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Retrieves number of folders and files in the specified folder path
/// pre-condition: assumes dirpath is a valid folder
///
void MgUnmanagedDataManager::GetNumberOfFilesAndSubfolders(CREFSTRING dirpath, INT32& numFolders, INT32& numFiles)
{
ACE_DIR* directory = ACE_OS::opendir(ACE_TEXT_WCHAR_TO_TCHAR(dirpath.c_str()));
if (directory != NULL)
{
dirent* direntry = NULL;
// Go through the directory entries
while ((direntry = ACE_OS::readdir(directory)) != NULL)
{
STRING entryName = MG_TCHAR_TO_WCHAR(direntry->d_name);
STRING fullDataPathname = dirpath;
if (!MgFileUtil::EndsWithSlash(fullDataPathname))
MgFileUtil::AppendSlashToEndOfPath(fullDataPathname);
fullDataPathname += entryName;
if (MgFileUtil::IsFile(fullDataPathname))
{
++numFiles;
}
else if (MgFileUtil::IsDirectory(fullDataPathname)
&& entryName.compare(L"..") != 0 // skip ..
&& entryName.compare(L".") != 0) // skip .
{
++numFolders;
}
}
ACE_OS::closedir(directory);
}
}
示例2: GetFilesAndFolders
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Recursive method that returns all files and/or folders for a given mapping
/// name
///
void MgUnmanagedDataManager::GetFilesAndFolders(string& list, CREFSTRING mappingName, CREFSTRING rootdir, CREFSTRING subdir, const MgStringCollection* filters, bool storeFolders, bool storeFiles, bool recursive)
{
STRING fulldir = rootdir;
if (!MgFileUtil::EndsWithSlash(fulldir))
MgFileUtil::AppendSlashToEndOfPath(fulldir);
if (!subdir.empty())
{
fulldir += subdir;
if (!MgFileUtil::EndsWithSlash(fulldir))
MgFileUtil::AppendSlashToEndOfPath(fulldir);
}
// Open the directory
ACE_DIR* directory = ACE_OS::opendir(ACE_TEXT_WCHAR_TO_TCHAR(fulldir.c_str()));
if (directory != NULL)
{
dirent* direntry = NULL;
// Go through the directory entries
while ((direntry = ACE_OS::readdir(directory)) != NULL)
{
STRING entryName = MG_TCHAR_TO_WCHAR(direntry->d_name);
STRING fullDataPathname = fulldir + entryName;
if (MgFileUtil::IsFile(fullDataPathname)
&& storeFiles
&& FilterFile(entryName, filters))
{
INT64 fileSize = MgFileUtil::GetFileSize(fullDataPathname);
MgDateTime createdDate = MgFileUtil::GetFileCreationTime(fullDataPathname);
MgDateTime modifiedDate = MgFileUtil::GetFileModificationTime(fullDataPathname);
AddFile(list, mappingName, subdir, entryName, fileSize, createdDate, modifiedDate);
}
else if (MgFileUtil::IsDirectory(fullDataPathname)
&& entryName.compare(L"..") != 0 // skip ..
&& entryName.compare(L".") != 0) // skip .
{
if (storeFolders)
{
// Add folders
INT32 numFolders = 0;
INT32 numFiles = 0;
GetNumberOfFilesAndSubfolders(fullDataPathname, numFolders, numFiles);
MgDateTime createdDate = MgFileUtil::GetFileCreationTime(fullDataPathname);
MgDateTime modifiedDate = MgFileUtil::GetFileModificationTime(fullDataPathname);
AddFolder(list, mappingName, subdir, entryName, numFolders, numFiles, createdDate, modifiedDate);
}
// recursive call to get files in subfolders
if (recursive)
GetFilesAndFolders(list, mappingName, rootdir, FormatSubdir(subdir) + entryName, filters, storeFolders, storeFiles, recursive);
}
}
ACE_OS::closedir(directory);
}
}
示例3: GetCloudMapFilePath
// NOTE : the value of MapType must be matched with ResourceID of ResourceFile(MapResourceFile)
STRING GooRoomClient::GetCloudMapFilePath(StageLevel stageLevel)
{
std::ostringstream mapFileName;
const STRING fileName = this->GetGooRoomResourceVersionManager().GetResourceFileName(static_cast<ResourceID>(stageLevel));
if( fileName.compare("")==0 )
{
ASSERT_DEBUG(fileName.compare("")!=0);
return "";
}
return this->GetWritableFilePath(fileName.c_str());
}
示例4: main
int main() {
// Verify sizes of all datatypes in data.h
BYTE m_byte;
CHAR m_char;
WORD m_word;
INT16 m_int16;
SHORT m_short;
BOOL m_bool;
DWORD m_dword;
UINT m_uint;
LONG m_long;
INT m_int;
FLOAT m_float;
DOUBLE m_double;
assert(sizeof(m_byte) == 1);
assert(sizeof(m_char) == 1);
assert(sizeof(m_word) == 2);
assert(sizeof(m_int16) == 2);
assert(sizeof(m_short) == 2);
assert(sizeof(m_bool) == 4);
assert(sizeof(m_dword) == 4);
assert(sizeof(m_uint) == 4);
assert(sizeof(m_int) == 4);
assert(sizeof(m_long) == 4);
assert(sizeof(m_float) == 4);
assert(sizeof(m_double) == 8);
cout << "All primitive data types are the correct size." << endl;
// Now testing if bitreader works
// ifstream input("/home/nwadhwa/Downloads/pipeOrgan04_200FPS.cine", ios::in|ios::binary);
ifstream input("testfile.dat", ios::in|ios::binary);
bitreader br(&input);
m_byte = br.readBYTE(); assert(m_byte == 84);
m_char = br.readCHAR(); assert(m_char == 104);
m_word = br.readWORD(); assert(m_word == 29545);
m_int16 = br.readINT16(); assert(m_int16 == 26912);
m_short = br.readSHORT(); assert(m_short == 8307);
m_bool = br.readBOOL(); assert(m_bool == 1768038497);
m_dword = br.readDWORD(); assert(m_dword == 2037539182);
m_uint = br.readUINT(); assert(m_uint == 1818846752);
m_long = br.readLONG(); assert(m_long == 1752440933);
m_int = br.readINT(); assert(m_int == 1746957409);
m_float = br.readFLOAT(); assert(abs(m_float-1.849871e+20) < 1e-6);
m_double = br.readDOUBLE(); assert(abs(m_double-2.139469e+161)<1e-6);
// Verify that we read structures correctly
TIME64 m_time64 = br.readTIME64();
WBGAIN m_wbgain = br.readWBGAIN();
IMFILTER m_imfilter = br.readIMFILTER();
assert(m_time64.Fractions == 543517794);
assert(m_time64.Seconds == 1229148993);
assert(abs(m_wbgain.R-1.772777e+28) < 1e-6);
assert(abs(m_wbgain.B - 1.726007e+25) < 1e-6);
assert(m_imfilter.Dim == 539912046);
assert(m_imfilter.Shifts == 1746957385);
assert(m_imfilter.Bias == 1864397665);
cout << "All data input tests passed." << endl;
cout << "Note that we haven't verified the sign of any variables yet" << endl;
input.close();
//Test actual cine file
ifstream inputCine("/home/nwadhwa/Downloads/drumhead_20140613.cine", ios::in|ios::binary);
CINEFILEHEADER cineheader(&inputCine);
cout << cineheader;
/*
BITMAPINFOHEADER bitmapheader(&inputCine, cineheader);
cout << bitmapheader;
IMAGEOFFSETS pimage(&inputCine, cineheader);
CINEIMAGE im(&inputCine, pimage.getPointer(1000), bitmapheader);
*/
SETUP setup(&inputCine, cineheader);
cout << setup;
// im.saveToTIFF("spice.tiff");
// String test
ifstream inputStr("/home/nwadhwa/Downloads/drumhead_20140613.cine", ios::in|ios::binary);
br = bitreader(&inputStr);
STRING out = br.readZeroTerminatedSTRING();
assert(out.compare("CI,"));
cout << "All string tests passed" << endl;
}