wxRegKey::StdKey wxRegKey::ExtractKeyName(wxString& strKey) { wxString strRoot = strKey.BeforeFirst(REG_SEPARATOR); size_t ui; for ( ui = 0; ui < nStdKeys; ui++ ) { if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 || strRoot.CmpNoCase(aStdKeys[ui].szShortName) == 0 ) { break; } } if ( ui == nStdKeys ) { wxFAIL_MSG(wxT("invalid key prefix in wxRegKey::ExtractKeyName.")); ui = HKCR; } else { strKey = strKey.After(REG_SEPARATOR); if ( !strKey.empty() && strKey.Last() == REG_SEPARATOR ) strKey.Truncate(strKey.Len() - 1); } return (StdKey)ui; }
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; } } }
void Page::SetName(wxString& myname) { myname.Trim(FALSE);myname.Trim(TRUE);myname.Truncate(100); if(!myname.IsEmpty()) { name = myname; } else { name = file.GetFullName(); } }
wxString SectionFieldDescriptor::Format(wxString& value) { if ( value.Length() > GetSize() ) { return value.Truncate(GetSize()); } else { wxString addon(GetFiller(), GetSize() - value.Length()); if ( GetAlignment() == FA_LEFT ) { return value + addon; } else { return addon + value; } } }
/** @brief Read a string from an input stream * * @param in wxInputStream& * @param out_String wxString& * @return bool * */ static bool ReadString( wxInputStream& in, wxString& out_String ) { int len; if (!ReadInt(in, len)) return false; if (len == 0) { out_String = out_String.Truncate(0); return true; } if (!in.CanRead()) return false; char buffer[len + 1]; in.Read( buffer, len ); buffer[len] = '\0'; out_String = wxString::FromUTF8(buffer); return true; }
inline void ConfigManager::Collapse(wxString& str) const { const wxChar *src = str.c_str(); wxChar *dst = (wxChar*) src; wxChar c; size_t len = 0; while ((c = *src)) { ++src; *dst = c; ++dst; ++len; if (c == _T('/')) while (*src == _T('/')) ++src; } str.Truncate(len); }
inline void RemoveTrailingSeparator(wxString& str) { if ( !str.empty() && str.Last() == REG_SEPARATOR ) str.Truncate(str.Len() - 1); }
void DebuggerTree::ParseEntry(WatchTreeEntry& entry, Watch* watch, wxString& text, long array_index) { if (text.IsEmpty()) return; // Manager::Get()->GetLogManager()->DebugLog(F(_T("DebuggerTree::ParseEntry(): %s"), text.c_str())); while (1) { // trim the string from left and right text.Trim(true); text.Trim(false); // find position of '{', '}' and ',' ***outside*** of any quotes. // decide which is nearer to the start int braceOpenPos = FindCharOutsideQuotes(text, _T('{')); if (braceOpenPos == -1) braceOpenPos = 0xFFFFFE; int braceClosePos = FindCharOutsideQuotes(text, _T('}')); if (braceClosePos == -1) braceClosePos = 0xFFFFFE; int commaPos = FindCommaPos(text); if (commaPos == -1) commaPos = 0xFFFFFE; int pos = std::min(commaPos, std::min(braceOpenPos, braceClosePos)); if (pos == 0xFFFFFE) { // no comma, opening or closing brace if (text.Right(3).Matches(_T(" = "))) text.Truncate(text.Length() - 3); if (!text.IsEmpty()) { entry.AddChild(text, watch); text.Clear(); } break; } else { // display array on a single line? // normal (multiple lines) display is taken care below, with array indexing if (watch && watch->is_array && braceOpenPos != 0xFFFFFE && braceClosePos != 0xFFFFFE) { wxString tmp = text.Left(braceClosePos + 1); // if more than one opening/closing brace, then it's a complex array so // ignore single-line if (text.Freq(_T('{')) == 1 && text.Freq(_T('}')) == 1) { // array on single line for up to 8 (by default) elements // if more elements, fall through to the multi-line display int commas = Manager::Get()->GetConfigManager(_T("debugger"))->ReadInt(_T("/single_line_array_elem_count"), 8); if (tmp.Freq(_T(',')) < commas) { // array watch type tmp[braceOpenPos] = _T('['); tmp.Last() = _T(']'); entry.AddChild(tmp, watch); text.Remove(0, braceClosePos + 1); continue; } } } wxString tmp = text.Left(pos); WatchTreeEntry* newchild = 0; if (tmp.Right(3).Matches(_T(" = "))) tmp.Truncate(tmp.Length() - 3); // remove " = " if last in string if (!tmp.IsEmpty()) { // take array indexing into account (if applicable) if (array_index != -1) { tmp.Prepend(wxString::Format(_T("[%ld]: "), array_index)); // if array element would occur multiple times, gdb adds as default "<repeated xx times> to the output // so we have to look for it and increase the array_index correctly // as default we increase by 1 long incIndex = 1; if (reRepeatedElements.Matches(tmp)) { reRepeatedElements.GetMatch(tmp, 1).ToLong(&incIndex); } array_index += incIndex; } newchild = &entry.AddChild(tmp, watch); } text.Remove(0, pos + 1); if (pos == braceOpenPos) { if (!newchild) newchild = &entry; // enable array indexing (if applicable) bool no_indexing = array_index == -1; if (watch && watch->is_array && no_indexing && text.Freq(_T('{')) == 0 && text.Freq(_T('}')) == 1) // don't index complex arrays { array_index = 0; } ParseEntry(*newchild, watch, text, array_index); // proceed one level deeper // reset array indexing if (no_indexing) array_index = -1; } else if (pos == braceClosePos) break; // return one level up } } }
// Returns a legal new section name, based on the input channel name. wxString get_legal_new_channel_section( wxString string_to_convert ) { wxString buf; // If it was a string of nothing then set it to plkrUNNAMED_CHANNEL_NAME // to avoid any asserts working on NULL strings. if ( string_to_convert == wxT( "" ) ) { string_to_convert = plkrUNNAMED_CHANNEL_NAME; } // Remove any illegal characters. string_to_convert = utils_string::remove_illegal_characters( string_to_convert, legal_section_name_characters ); // If it was a string of nothing but illegal characters, and we now have just // an empty string, then set it to plkrUNNAMED_CHANNEL_NAME to avoid any // asserts working on NULL strings. if ( string_to_convert == wxT( "" ) ) { string_to_convert = plkrUNNAMED_CHANNEL_NAME; } // Strip it down to 25 letters (Mac filesystem stops at 31. That gives us 999999 // identical section with the same base name, but a different number at the end. string_to_convert.Truncate( plkrMAXIMUM_BASE_SECTION_LENGTH ); // If it is a reserved section name by now, then stick a _ after the last character if ( is_reserved_section( string_to_convert ) ) { string_to_convert += wxT( "_" ); } // Store how long the base name is (so know where to truncate when adding on numbers. size_t base_section_length = string_to_convert.Length(); wxLogDebug( wxT( "Before loop to append unique number, string_to_convert=" ) + string_to_convert ); // Can't use a section name that already exists, so if it exists, keep incrementing the // suffix number until get a section (aka "group") that doesn't exist already. Note that // sections ("groups") are not case-sensitive. This is fortunate, since can't have // different sections with a different case difference, since can't have 2 directories // on MSW with only a difference in case between them, so wouldn't be able to make // the new channel subdirectory. // The loop condition also makes sure that a directory by the new name doesn't already // exist in the channels subdir (it shouldn't, but may be an artifact if people // cleaned out their .ini file manually, but didn't erase directorys from channels // subdirectory. Also the MSW uninstall doesn't remove channels, for protection of // user created files. for ( long n = 1; the_configuration->HasGroup( string_to_convert ) || wxDirExists( get_plucker_directory( CHANNELS ) + wxT( "/" ) + string_to_convert ); n++ ) { // Cut off any number extensions that may have been added in a previous // iteration of the loop. wxLogDebug( wxT( "Before truncate, string_to_convert=" ) + string_to_convert ); string_to_convert.Truncate( base_section_length ); wxLogDebug( wxT( "After truncate, string_to_convert=" ) + string_to_convert ); // Append the new number. buf.Printf( wxT( "%ld" ), n ); string_to_convert = string_to_convert + buf; wxLogDebug( wxT( "After appending unique id, string_to_convert=" ) + string_to_convert ); } // All done. Ship it. return string_to_convert; }
void Page::SetDescription(wxString& mydescription) { mydescription.Trim(FALSE);mydescription.Trim(TRUE);mydescription.Truncate(1024); description = mydescription; }