本文整理汇总了C++中wxString::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::Clear方法的具体用法?C++ wxString::Clear怎么用?C++ wxString::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxString
的用法示例。
在下文中一共展示了wxString::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxExtractSubString
/// Extracts the nth substring from a delimited string
/// This is a wxWidgets port of MFC's AfxExtractSubString
/// @param string Holds the returned substring
/// @param fullString String to extract the substring from
/// @param subString Zero-based index of the substring to extract
/// @param separator Character used to separator the substrings
/// @return True if the substring was extracted, false if not
bool wxExtractSubString(wxString& string, const wxChar* fullString,
wxUint32 subString, wxChar separator)
{
//------Last Verified------//
// - Nov 27, 2004
wxCHECK(fullString != (wxChar*)NULL, false);
string.Clear();
while (subString--)
{
fullString = wxStrchr(fullString, separator);
if (fullString == NULL)
{
string.Clear(); // return empty string as well
return (false);
}
fullString++; // point past the separator
}
const wxChar* end = wxStrchr(fullString, separator);
wxInt32 length = (end == NULL) ? wxStrlen_(fullString) :
(wxInt32)(end - fullString);
wxASSERT(length >= 0);
memcpy(string.GetWriteBuf(length), fullString, length * sizeof(wxChar));
string.UngetWriteBuf(); // Need to call ReleaseBuffer
// after calling GetBufferSetLength
return (true);
}
示例2: ReadFileContents
bool cbNetwork::ReadFileContents(const wxString& remote, wxString& buffer)
{
if (!Connect(remote))
return false;
m_Busy = true;
wxString name = wxFileName(remote).GetFullName();
FileInfo* info = PrivateGetFileInfo(remote);
Notify(cbEVT_CBNET_START_DOWNLOAD, name, info ? info->size : 0);
buffer.Clear();
wxTextInputStream tis(*m_pStream);
while (!m_Abort && !m_pStream->Eof())
{
buffer += tis.ReadLine() + _T('\n');
Notify(cbEVT_CBNET_PROGRESS, name, buffer.Length());
}
if (m_Abort)
{
Notify(cbEVT_CBNET_ABORTED, _("Aborted"));
buffer.Clear();
}
Notify(cbEVT_CBNET_END_DOWNLOAD, name, m_Abort ? -1 : 0);
m_Busy = false;
Disconnect();
return true;
}
示例3: UnSerializeString
bool SearchTreeNode::UnSerializeString(const wxString& s,wxString& result)
{
result.Clear();
size_t i;
int mode = 0;
wxString entity(_T(""));
unsigned int u;
for (i = 0;mode >=0 && i<s.length();i++)
{
wxChar ch = s[i];
if (ch==_T('"') || ch==_T('>') || ch==_T('<'))
{
mode = -1; // Error
break;
}
switch(mode)
{
case 0: // normal
if (ch==_T('&'))
{
mode = 1;
entity.Clear();
}
else
result << ch;
case 1: // escaped
if (ch==_T('&'))
{
mode = -1; // Error
break;
}
else if (ch==_T(';'))
{
mode = 0;
if (entity==_T("quot"))
ch = _T('"');
else if (entity==_T("amp"))
ch = _T('&');
else if (entity==_T("apos"))
ch = _T('\'');
else if (entity==_T("lt"))
ch = _T('<');
else if (entity==_T("gt"))
ch = _T('>');
else if (entity[0]==_T('#') && S2U(entity.substr(1),u))
ch = u;
else
{
mode = -1; // Error: Unrecognized entity
break;
}
result << ch;
}
break;
}
}
if (mode < 0)
result.Clear();
return (mode >= 0);
}
示例4: verbKey
bool
Verb::ReadFromRegistry(const wxRegKey & base, const wxString & verbName)
{
// Store descriptive verb name
m_name = verbName;
if (!base.HasSubKey(verbName))
return false;
wxRegKey verbKey(base, verbName);
// Read command key
const wxString commandKeyName(wxT("command"));
if (!verbKey.HasSubKey(commandKeyName))
return false;
wxRegKey commandKey(base, commandKeyName);
if (commandKey.HasValue(NULL))
commandKey.QueryValue(NULL, m_command);
// Attempt to read ddeexec key
m_ddeCommand.Clear();
m_ddeTopic.Clear();
m_ddeApplication.Clear();
const wxString ddeCommandKeyName(wxT("ddeexec"));
m_usesDde = verbKey.HasSubKey(ddeCommandKeyName);
if (m_usesDde)
{
wxRegKey ddeCommandKey(verbKey, ddeCommandKeyName);;
if (ddeCommandKey.HasValue(NULL))
ddeCommandKey.QueryValue(NULL, m_ddeCommand);
const wxString ddeTopicName(wxT("Topic"));
if (ddeCommandKey.HasSubKey(ddeTopicName))
{
wxRegKey ddeTopicKey(ddeCommandKey, ddeTopicName);
if (ddeTopicKey.HasValue(NULL))
ddeTopicKey.QueryValue(NULL, m_ddeTopic);
}
const wxString ddeApplicationName(wxT("Application"));
if (ddeCommandKey.HasSubKey(ddeApplicationName))
{
wxRegKey ddeApplicationKey(ddeCommandKey, ddeApplicationName);
if (ddeApplicationKey.HasValue(NULL))
ddeApplicationKey.QueryValue(NULL, m_ddeApplication);
}
}
return true;
}
示例5: GetMonitorProfile
void GetMonitorProfile(wxString& profileName, cmsHPROFILE& profile)
{
if (profile != NULL)
{
cmsCloseProfile(profile);
}
profileName.Clear();
profile = NULL;
detail::GetMonitorProfile(profileName, profile);
// check if monitor profile could be successful loaded, if not switch back to default sRGB profile
if (profile == NULL)
{
profile = cmsCreate_sRGBProfile();
profileName.Clear();
};
};
示例6: Read
bool WinProcessImpl::Read(wxString& buff)
{
DWORD le1(-1);
DWORD le2(-1);
buff.Clear();
if( !DoReadFromPipe(hChildStderrRdDup, buff) ) {
le2 = GetLastError();
}
if( !DoReadFromPipe(hChildStdoutRdDup, buff) ) {
le1 = GetLastError();
}
if( le1 == ERROR_NO_DATA && le2 == ERROR_NO_DATA) {
if ( IsAlive() ) {
wxThread::Sleep(15);
return true;
}
}
bool success = !buff.IsEmpty();
if(!success) {
DWORD dwExitCode;
if (GetExitCodeProcess(piProcInfo.hProcess, &dwExitCode)) {
SetProcessExitCode(GetPid(), (int)dwExitCode);
}
}
return success;
}
示例7: EllipseStringIfNeeded
void CSimplePanelBase::EllipseStringIfNeeded(wxString& s, wxWindow *win) {
int x, y;
int w, h;
wxSize sz = GetSize();
win->GetPosition(&x, &y);
int maxWidth = sz.GetWidth() - x - SIDEMARGINS;
win->GetTextExtent(s, &w, &h);
// Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents()
if (w > maxWidth) {
int ellipsisWidth;
win->GetTextExtent( wxT("..."), &ellipsisWidth, NULL);
if (ellipsisWidth > maxWidth) {
s.Clear();
w = 0;
} else {
do {
s.Truncate( s.length() - 1 );
win->GetTextExtent( s, &w, &h);
} while (((w + ellipsisWidth) > maxWidth) && s.length() );
s.append( wxT("...") );
w += ellipsisWidth;
}
}
}
示例8: __RemoveTerminalColoring
static void __RemoveTerminalColoring(const wxString& buffer, wxString& modbuffer)
{
modbuffer.Clear();
short state = BUFF_STATE_NORMAL;
wxString::const_iterator iter = buffer.begin();
for(; iter != buffer.end(); ++iter) {
wxChar ch = *iter;
switch(state)
{
case BUFF_STATE_NORMAL:
if(ch == 0x1B) { // found ESC char
state = BUFF_STATE_IN_ESC;
} else {
modbuffer << ch;
}
break;
case BUFF_STATE_IN_ESC:
if(ch == 'm') { // end of color sequence
state = BUFF_STATE_NORMAL;
}
break;
}
}
}
示例9: GetPhpFixerCommand
bool FormatOptions::GetPhpFixerCommand(const wxFileName& fileName, wxString& command)
{
command.Clear();
m_optionsPhp.Load();
wxString phar, php, parameters, filePath;
php = m_optionsPhp.GetPhpExe();
if(php.IsEmpty()) {
clDEBUG() << "CodeForamtter: GetPhpFixerCommand(): empty php command" << clEndl;
return false;
}
::WrapWithQuotes(php);
phar = GetPHPCSFixerPhar();
if(phar.IsEmpty()) {
clDEBUG() << "CodeForamtter: GetPhpFixerCommand(): empty php-cs-fixer phar path" << clEndl;
return false;
}
::WrapWithQuotes(phar);
parameters = GetPHPCSFixerPharOptions();
if(parameters.IsEmpty()) {
if(m_PHPCSFixerPharSettings & kPcfAllowRisky) {
parameters << " --allow-risky=yes";
}
parameters << GetPhpFixerRules(fileName);
}
parameters.Trim().Trim(false);
clDEBUG() << parameters << clEndl;
filePath = fileName.GetFullPath();
::WrapWithQuotes(filePath);
command << php << " " << phar << " fix " << parameters << " " << filePath;
return true;
}
示例10: AuthenticateServer
bool clSSH::AuthenticateServer(wxString& message)
{
int state;
unsigned char* hash = NULL;
char* hexa = NULL;
message.Clear();
state = ssh_is_server_known(m_session);
#if LIBSSH_VERSION_INT < SSH_VERSION_INT(0, 6, 1)
int hlen = 0;
hlen = ssh_get_pubkey_hash(m_session, &hash);
if(hlen < 0) { throw clException("Unable to obtain server public key!"); }
#else
size_t hlen = 0;
ssh_key key = NULL;
ssh_get_publickey(m_session, &key);
ssh_get_publickey_hash(key, SSH_PUBLICKEY_HASH_SHA1, &hash, &hlen);
if(hlen == 0) { throw clException("Unable to obtain server public key!"); }
#endif
switch(state) {
case SSH_SERVER_KNOWN_OK:
free(hash);
return true;
case SSH_SERVER_KNOWN_CHANGED:
hexa = ssh_get_hexa(hash, hlen);
message << _("Host key for server changed: it is now:\n") << hexa << "\n" << _("Accept server authentication?");
free(hexa);
free(hash);
return false;
case SSH_SERVER_FOUND_OTHER:
message << _("The host key for this server was not found but another type of key exists.\n")
<< _("An attacker might change the default server key to confuse your client into thinking the key "
"does not exist\n")
<< _("Accept server authentication?");
free(hash);
return false;
case SSH_SERVER_FILE_NOT_FOUND:
message << _("Could not find known host file.\n")
<< _("If you accept the host key here, the file will be automatically created.\n");
/* fallback to SSH_SERVER_NOT_KNOWN behavior */
case SSH_SERVER_NOT_KNOWN:
hexa = ssh_get_hexa(hash, hlen);
message << _("The server is unknown. Do you trust the host key?\n") << _("Public key hash: ") << hexa << "\n"
<< _("Accept server authentication?");
free(hexa);
free(hash);
return false;
default:
case SSH_SERVER_ERROR:
throw clException(wxString() << "An error occurred: " << ssh_get_error(m_session));
}
return false;
}
示例11: enumRegistryValue
bool enumRegistryValue(HKEY parent, DWORD index, wxString& valueNameOut, wxString& valueOut) {
valueNameOut.Clear();
valueOut.Clear();
WCHAR valueNameBuffer[512];
DWORD valueNameBufferSize = static_cast<DWORD>(sizeof(valueNameBuffer));
BYTE valueBuffer[512];
DWORD valueBufferSize = static_cast<DWORD>(sizeof(valueBuffer));
DWORD type;
LONG ret = RegEnumValueW(parent, index, valueNameBuffer, &valueNameBufferSize, NULL, &type, valueBuffer, &valueBufferSize);
if (ret != ERROR_SUCCESS) {
return false;
}
valueNameOut = wxString(valueNameBuffer, valueNameBufferSize);
switch (type) {
case REG_BINARY:
valueOut = wxString::From8BitData(reinterpret_cast<char*>(valueBuffer), valueBufferSize);
break;
case REG_DWORD:
{
ULONG val = *reinterpret_cast<ULONG*>(valueBuffer); // I feel dirty...
valueOut << val;
break;
}
case REG_QWORD:
{
ULONGLONG val = *reinterpret_cast<ULONGLONG*>(valueBuffer); // I feel dirty...
valueOut << val;
break;
}
case REG_SZ:
valueOut = wxString(reinterpret_cast<wchar_t*>(valueBuffer), (valueBufferSize / sizeof(WCHAR)) - 1);
break;
default:
return false;
}
return true;
}
示例12: DetectEncodingAndConvert
// Try converting a C-string from different encodings until a possible match is found.
// This tries the following encoding converters (in the same order):
// utf8, system, default and iso8859-1 to iso8859-15
wxFontEncoding DetectEncodingAndConvert(const char* strIn, wxString& strOut, wxFontEncoding possibleEncoding)
{
wxFontEncoding encoding = possibleEncoding;
strOut.Clear();
if (platform::unicode)
{
if (possibleEncoding != wxFONTENCODING_UTF16 &&
possibleEncoding != wxFONTENCODING_UTF16LE &&
possibleEncoding != wxFONTENCODING_UTF16BE &&
possibleEncoding != wxFONTENCODING_UTF32 &&
possibleEncoding != wxFONTENCODING_UTF32LE &&
possibleEncoding != wxFONTENCODING_UTF32BE)
{
// crashes deep in the runtime (windows, at least)
// if one of the above encodings, hence the guard
wxCSConv conv(possibleEncoding);
strOut = wxString(strIn, conv);
if (strOut.Length() == 0)
{
// oops! wrong encoding...
// try utf8 first, if that was not what was asked for
if (possibleEncoding != wxFONTENCODING_UTF8)
{
encoding = wxFONTENCODING_UTF8;
strOut = wxString(strIn, wxConvUTF8);
}
// check again: if still not right, try system encoding, default encoding and then iso8859-1 to iso8859-15
if (strOut.Length() == 0)
{
for (int i = wxFONTENCODING_SYSTEM; i < wxFONTENCODING_ISO8859_MAX; ++i)
{
encoding = (wxFontEncoding)i;
if (encoding == possibleEncoding)
continue; // skip if same as what was asked
wxCSConv csconv(encoding);
strOut = wxString(strIn, csconv);
if (strOut.Length() != 0)
break; // got it!
}
}
}
}
else
{
strOut = (const wxChar*) strIn;
}
}
else
{
strOut = (const wxChar*) strIn;
}
return encoding;
}
示例13: OSXOpenDebuggerTerminalAndGetTTY
void FileUtils::OSXOpenDebuggerTerminalAndGetTTY(const wxString& path, wxString& tty, long& pid)
{
tty.Clear();
wxString command;
wxString tmpfile;
wxString escapedPath = path;
if(escapedPath.Contains(" ")) {
escapedPath.Prepend("\"").Append("\"");
}
tmpfile << "/tmp/terminal.tty." << ::wxGetProcessId();
command << "osascript -e 'tell app \"Terminal\" to do script \"tty > " << tmpfile << " && clear && sleep 12345\"'";
CL_DEBUG("Executing: %s", command);
long res = ::wxExecute(command);
if(res == 0) {
CL_WARNING("Failed to execute command:\n%s", command);
return;
}
// Read the tty from the file, wait for it up to 10 seconds
wxFileName ttyFile(tmpfile);
pid = wxNOT_FOUND;
for(size_t i = 0; i < 10; ++i) {
if(!ttyFile.Exists()) {
::wxSleep(1);
continue;
}
ReadFileContent(ttyFile, tty);
tty.Trim().Trim(false);
// Remove the file
wxLogNull noLog;
::wxRemoveFile(ttyFile.GetFullPath());
// Get the parent process ID (we want the parent PID and not
// the sleep command PID)
wxString psCommand;
psCommand << "ps -A -o ppid,command";
wxString psOutput = ProcUtils::SafeExecuteCommand(psCommand);
CL_DEBUG("PS output:\n%s\n", psOutput);
wxArrayString lines = ::wxStringTokenize(psOutput, "\n", wxTOKEN_STRTOK);
for(size_t u = 0; u < lines.GetCount(); ++u) {
wxString l = lines.Item(u);
l.Trim().Trim(false);
if(l.Contains("sleep") && l.Contains("12345")) {
// we got a match
CL_DEBUG("Got a match!");
wxString ppidString = l.BeforeFirst(' ');
ppidString.ToCLong(&pid);
break;
}
}
break;
}
CL_DEBUG("PID is: %d\n", (int)pid);
CL_DEBUG("TTY is: %s\n", tty);
}
示例14: GetColumn
OCPNListCtrl::~OCPNListCtrl()
{
g_AisTargetList_column_spec.Clear();
for( int i = 0; i < tlSOG + 1; i++ ) {
wxListItem item;
GetColumn( i, item );
wxString sitem;
sitem.Printf( _T("%d;"), item.m_width );
g_AisTargetList_column_spec += sitem;
}
}
示例15: FixupVarNameForChange
void DebuggerTree::FixupVarNameForChange(wxString& str)
{
// remove everything from '=' and after
str = str.BeforeFirst(_T('='));
str.Trim(false);
str.Trim(true);
// if it contains invalid chars, clear it
if (str.find_first_of(_T(" \t")) != wxString::npos)
str.Clear();
}