本文整理汇总了C++中String::EndsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ String::EndsWith方法的具体用法?C++ String::EndsWith怎么用?C++ String::EndsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::EndsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
void Audio::Create(const String& nameRef)
{
TCHAR buffer[100];
String sendString;
if (nameRef.EndsWith(".mp3")) sendString = String("open \"") + m_FileName + "\" type mpegvideo alias " + m_Alias;
else if (nameRef.EndsWith(".wav")) sendString = String("open \"") + m_FileName + "\" type waveaudio alias " + m_Alias;
else if (nameRef.EndsWith(".mid")) sendString = String("open \"") + m_FileName + "\" type sequencer alias " + m_Alias;
int result = mciSendString(sendString.ToTChar(), 0, 0, 0);
if (result != 0) return;
sendString = String("set ") + m_Alias + " time format milliseconds";
mciSendString(sendString.ToTChar(), 0, 0, 0);
sendString = String("status ") + m_Alias + " length";
mciSendString(sendString.ToTChar(), buffer, 100, 0);
m_Duration = String(buffer).ToInteger();
// Create a window to catch the MM_MCINOTIFY message with
m_hWnd = CreateWindow(TEXT("STATIC"), TEXT(""), 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(0), 0);
SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG) AudioProcStatic); // set the custom message loop (subclassing)
SetWindowLong(m_hWnd, GWL_USERDATA, (LONG) this); // set this object as the parameter for the Proc
}
示例2: TryCreateStorage
AssetStoragePtr HttpAssetProvider::TryCreateStorage(HashMap<String, String> &storageParams, bool fromNetwork)
{
if (!storageParams.Contains("src") || !IsValidRef(storageParams["src"], ""))
return AssetStoragePtr();
if (storageParams.Contains("type") && storageParams["type"].Compare("HttpAssetStorage", false) != 0)
return AssetStoragePtr();
String baseUrl = storageParams["src"];
if (!baseUrl.EndsWith("/") && baseUrl.Contains("/"))
baseUrl = baseUrl.Substring(0, baseUrl.FindLast('/')+1);
if (!baseUrl.EndsWith("/"))
return AssetStoragePtr();
String name = UniqueName(storageParams["name"]);
// @todo liveupdate, liveupload, autodiscoverable etc. when actually needed
AssetStoragePtr storage = StorageForBaseURL(baseUrl);
if (!storage)
{
storage = AssetStoragePtr(new HttpAssetStorage(framework_->GetContext(), name, baseUrl, storageParams["localdir"]));
httpStorages_.Push(storage);
}
storage->SetReplicated(Urho3D::ToBool(storageParams["replicated"]));
return storage;
}
示例3: Error
void PixInsightX11Installer::CopyFiles( const String& targetDir, const String& sourceDir )
{
if ( !targetDir.BeginsWith( '/' ) )
throw Error( "CopyFiles(): Relative target directory." );
if ( !sourceDir.BeginsWith( '/' ) )
throw Error( "CopyFiles(): Relative source directory." );
if ( targetDir.EndsWith( '/' ) || sourceDir.EndsWith( '/' ) )
throw Error( "CopyFiles(): Incorrectly terminated directories." );
if ( !File::DirectoryExists( targetDir ) )
throw Error( "CopyFiles(): Nonexistent target directory." );
if ( !File::DirectoryExists( sourceDir ) )
throw Error( "CopyFiles(): Nonexistent source directory." );
StringList sourceItems = SearchDirectory( sourceDir );
size_type sourceDirLen = sourceDir.Length();
for ( StringList::const_iterator i = sourceItems.Begin(); i != sourceItems.End(); ++i )
{
String relSourcePath = *i;
relSourcePath.DeleteLeft( sourceDirLen );
String targetPath = targetDir + relSourcePath;
if ( targetPath.EndsWith( '/' ) )
{
/*
* Create a subdirectory
*/
targetPath.Delete( targetPath.UpperBound() );
if ( !File::DirectoryExists( targetPath ) )
{
File::CreateDirectory( targetPath );
String sourcePath = *i;
sourcePath.Delete( sourcePath.UpperBound() );
File::CopyTimesAndPermissions( targetPath, sourcePath );
}
}
else
{
/*
* Copy a file
*/
/*
* ### N.B. We don't have to create subdirectories here becase they
* have been reported by SearchDirectory(), and we are creating them
* before copying files. SearchDirectory() promises that all
* subdirectories are reported before their contained files.
*/
/*
String targetSubdir = File::ExtractDirectory( targetPath );
if ( targetSubdir.EndsWith( '/' ) )
targetSubdir.Delete( targetSubdir.UpperBound() );
if ( !File::DirectoryExists( targetSubdir ) )
File::CreateDirectory( targetSubdir );
*/
File::CopyFile( targetPath, *i );
}
}
}
示例4: Combine
String Path::Combine(const String & path1, const String & path2)
{
StringBuilder sb(path1.Length()+path2.Length()+2);
sb.Append(path1);
if (!path1.EndsWith(L'\\') && !path1.EndsWith(L'/'))
sb.Append(L'\\');
sb.Append(path2);
return sb.ProduceString();
}
示例5: Combine
String Path::Combine(const String & path1, const String & path2)
{
if (path1.Length() == 0) return path2;
StringBuilder sb(path1.Length()+path2.Length()+2);
sb.Append(path1);
if (!path1.EndsWith('\\') && !path1.EndsWith('/'))
sb.Append(PathDelimiter);
sb.Append(path2);
return sb.ProduceString();
}
示例6: String
Audio::Audio(String const& nameRef) : m_Playing(false), m_Paused(false), m_MustRepeat(false), m_hWnd(0), m_Volume(100)
{
if (nameRef.EndsWith(".mp3") || nameRef.EndsWith(".wav") || nameRef.EndsWith(".mid"))
{
m_Alias = String("audio") + m_nr++;
m_FileName = nameRef;
Create(nameRef);
}
}
示例7: WriteZipFileAux
static status_t WriteZipFileAux(zipFile zf, const String & baseName, const Message & msg, int compressionLevel, zip_fileinfo * fileInfo)
{
for (MessageFieldNameIterator iter = msg.GetFieldNameIterator(); iter.HasData(); iter++)
{
const String & fn = iter.GetFieldName();
uint32 fieldType;
if (msg.GetInfo(fn, &fieldType) != B_NO_ERROR) return B_ERROR;
switch(fieldType)
{
case B_MESSAGE_TYPE:
{
String newBaseName = baseName;
if ((newBaseName.HasChars())&&(newBaseName.EndsWith('/') == false)) newBaseName += '/';
newBaseName += fn;
// Message fields we treat as sub-directories
MessageRef subMsg;
for (int32 i=0; msg.FindMessage(fn, i, subMsg) == B_NO_ERROR; i++) if (WriteZipFileAux(zf, newBaseName, *subMsg(), compressionLevel, fileInfo) != B_NO_ERROR) return B_ERROR;
}
break;
case B_RAW_TYPE:
{
String fileName = baseName;
if ((fileName.HasChars())&&(fileName.EndsWith('/') == false)) fileName += '/';
fileName += fn;
const void * data;
uint32 numBytes;
for (int32 i=0; msg.FindData(fn, B_RAW_TYPE, i, &data, &numBytes) == B_NO_ERROR; i++)
{
if (zipOpenNewFileInZip2(zf,
fileName(), // file name
fileInfo, // file info
NULL, // const void* extrafield_local,
0, // uInt size_extrafield_local,
NULL, // const void* extrafield_global,
0, // uInt size_extrafield_global,
NULL, // const char* comment,
(compressionLevel>0)?Z_DEFLATED:0, // int method,
compressionLevel, // int compressionLevel
0) != ZIP_OK) return B_ERROR;
if (zipWriteInFileInZip(zf, data, numBytes) != ZIP_OK) return B_ERROR;
if (zipCloseFileInZip(zf) != ZIP_OK) return B_ERROR;
}
}
break;
}
}
return B_NO_ERROR;
}
示例8:
String
FileUtilities::Combine(const String &path1, const String &path2)
{
String firstHalf = path1;
String secondHalf = path2;
if (firstHalf.EndsWith(_T("\\")) || firstHalf.EndsWith(_T("/")))
firstHalf = firstHalf.Mid(0, firstHalf.GetLength() -1);
if (secondHalf.StartsWith(_T("\\")) || secondHalf.StartsWith(_T("/")))
secondHalf = secondHalf.Mid(1);
String result = firstHalf + "\\" + secondHalf;
return result;
}
示例9:
bool ResourceOps::CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError)
{
Editor* editor = GetSubsystem<Editor>();
Project* project = editor->GetProject();
String fullpath = resourcePath + resourceName;
if (!resourceName.EndsWith(".tmx"))
fullpath += ".tmx";
FileSystem* fs = GetSubsystem<FileSystem>();
if (fs->FileExists(fullpath))
{
if (reportError)
{
String errorMsg;
errorMsg.AppendWithFormat("The level:\n\n%s\n\nalready exists", fullpath.CString());
editor->PostModalError("Create 2D Level Error", errorMsg);
}
return false;
}
return true;
}
示例10:
String PixInsightX11Installer::Unquoted( const String& s )
{
String r = s;
if ( s.BeginsWith( '\"' ) )
if ( s.EndsWith( '\"' ) )
{
r.DeleteRight( r.UpperBound() );
r.DeleteLeft( 1 );
}
if ( s.BeginsWith( '\'' ) )
if ( s.EndsWith( '\'' ) )
{
r.DeleteRight( r.UpperBound() );
r.DeleteLeft( 1 );
}
return r;
}
示例11: IsWritable
bool FilterLibrary::IsWritable() const
{
/*
* If wheter this is a new library, or the current library file does not
* exist, or it is a read-only file, then this library is not writable.
*/
if ( filePath.IsEmpty() )
return false;
if ( !File::Exists( filePath ) )
return false;
if ( File::IsReadOnly( filePath ) )
return false;
/*
* Do not allow rewriting the default filter collection.
*/
#ifdef __PCL_WINDOWS
// Windows filesystem is case-insensitive
if ( filePath.CompareIC( DefaultLibraryPath() ) == 0 )
#else
if ( filePath == DefaultLibraryPath() )
#endif
return false;
/*
* Attempt to create a file on the same directory where we have the current
* filter collection file. If we can create a file, then the current filter
* library is (should be) writable.
*/
try
{
String dirPath = File::ExtractDrive( filePath ) + File::ExtractDirectory( filePath );
if ( !File::DirectoryExists( dirPath ) ) // ?? cannot happen
return false;
if ( !dirPath.EndsWith( '/' ) )
dirPath += '/';
String testFileName = dirPath + "test_file";
if ( File::Exists( testFileName ) )
{
String baseName = testFileName;
unsigned i = 0;
do
testFileName = baseName + String( ++i );
while ( File::Exists( testFileName ) );
}
File f;
f.CreateForWriting( testFileName );
f.Close();
File::Remove( testFileName );
return true;
}
catch ( ... )
{
return false;
}
}
示例12: GetRealLineNumber
int JSVM::GetRealLineNumber(const String& fileName, const int lineNumber) {
int realLineNumber = lineNumber;
String path = fileName;
if (!path.EndsWith(".js.map"))
path += ".js.map";
if (path.EndsWith(".js")) {
return realLineNumber;
}
SharedPtr<File> mapFile(GetSubsystem<ResourceCache>()->GetFile(path));
//if there's no source map file, maybe you use a pure js, so give an error, or maybe forgot to generate source-maps :(
if (mapFile.Null())
{
return realLineNumber;
}
String map;
mapFile->ReadText(map);
int top = duk_get_top(ctx_);
duk_get_global_string(ctx_, "require");
duk_push_string(ctx_, "AtomicEditor/Script/jsutils");
if (duk_pcall(ctx_, 1))
{
printf("Error: %s\n", duk_safe_to_string(ctx_, -1));
duk_set_top(ctx_, top);
return false;
}
duk_get_prop_string(ctx_, -1, "getRealLineNumber");
duk_push_string(ctx_, map.CString());
duk_push_int(ctx_, lineNumber);
bool ok = true;
if (duk_pcall(ctx_, 2))
{
ok = false;
printf("Error: %s\n", duk_safe_to_string(ctx_, -1));
}
else
{
realLineNumber = duk_to_int(ctx_, -1);
}
duk_set_top(ctx_, top);
return realLineNumber;
}
示例13: DebugOutput
Void DebugOutput(const TChar* format, ...)
{
va_list argList;
va_start(argList, format);
String buffer;
buffer.FormatV(format, argList);
if (!buffer.EndsWith(Text("\n")))
{
buffer += Text("\n");
}
::OutputDebugString(buffer);
}
示例14: CleanupDNSLabel
String CleanupDNSLabel(const String & s, const String & optAdditionalAllowedChars)
{
const uint32 len = muscleMin(s.Length(), (uint32)63); // DNS spec says maximum 63 chars per label!
String ret; if (ret.Prealloc(len) != B_NO_ERROR) return ret;
const char * p = s();
for (uint32 i=0; i<len; i++)
{
const char c = p[i];
switch(c)
{
case '\'': case '\"': case '(': case ')': case '[': case ']': case '{': case '}':
// do nothing -- we will omit delimiters
break;
default:
if ((muscleInRange(c, '0', '9'))||(muscleInRange(c, 'A', 'Z'))||(muscleInRange(c, 'a', 'z'))||(optAdditionalAllowedChars.Contains(c))) ret += c;
else if ((ret.HasChars())&&(ret.EndsWith('-') == false)) ret += '-';
break;
}
}
while(ret.EndsWith('-')) ret -= '-'; // remove any trailing dashes
return ret;
}
示例15: Load
bool DynLibImpl::Load(const String& libraryPath, String* errorMessage)
{
String path = libraryPath;
if (!path.EndsWith(".dll"))
path += ".dll";
m_handle = LoadLibraryExW(path.GetWideString().data(), nullptr, (File::IsAbsolute(path)) ? LOAD_WITH_ALTERED_SEARCH_PATH : 0);
if (m_handle)
return true;
else
{
*errorMessage = Error::GetLastSystemError();
return false;
}
}