1. NOT_FOUND -> wxNOT_FOUND

2. wxString::Left(), Right(), Before(), After() clean up
3. wxLocale updates


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-01-14 14:33:56 +00:00
parent afcaf277af
commit 3c67202dee
19 changed files with 482 additions and 595 deletions

View File

@@ -99,7 +99,7 @@ int name::Index(const T& Item, bool bFromEnd) const \
} \
} \
\
return NOT_FOUND; \
return wxNOT_FOUND; \
}
// redefine the macro so that now it will generate the class implementation

View File

@@ -195,7 +195,7 @@ class WXDLLEXPORT wxEvent;
/** symbolic constant used by all Find()-like functions returning positive
integer on success as failure indicator */
#define NOT_FOUND (-1)
#define wxNOT_FOUND (-1)
// ----------------------------------------------------------------------------
// Error codes

View File

@@ -123,8 +123,8 @@ protected:
/**
Search the element in the array, starting from the either side
@param bFromEnd if TRUE, start from the end
@return index of the first item matched or NOT_FOUND
@see NOT_FOUND
@return index of the first item matched or wxNOT_FOUND
@see wxNOT_FOUND
*/
int Index(long lItem, bool bFromEnd = FALSE) const;
/// search for an item using binary search in a sorted array
@@ -193,7 +193,7 @@ public: \
void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); } \
void Remove(T Item) \
{ int iIndex = Index(Item); \
wxCHECK2_MSG( iIndex != NOT_FOUND, return, \
wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
"removing inexisting element in wxArray::Remove" ); \
wxBaseArray::Remove((size_t)iIndex); } \
\
@@ -246,7 +246,7 @@ public: \
void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); } \
void Remove(T Item) \
{ int iIndex = Index(Item); \
wxCHECK2_MSG( iIndex != NOT_FOUND, return, \
wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
"removing inexisting element in wxArray::Remove" ); \
wxBaseArray::Remove((size_t)iIndex); } \
\

View File

@@ -327,7 +327,7 @@ public:
// create new entry/subgroup returning pointer to newly created element
ConfigGroup *AddSubgroup(const wxString& strName);
ConfigEntry *AddEntry (const wxString& strName, int nLine = NOT_FOUND);
ConfigEntry *AddEntry (const wxString& strName, int nLine = wxNOT_FOUND);
// will also recursively set parent's dirty flag
void SetDirty();

View File

@@ -103,8 +103,9 @@ WXDLLEXPORT char* wxExpandPath(char *dest, const char *path);
// Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib)
// and make (if under the home tree) relative to home
// [caller must copy-- volatile]
WXDLLEXPORT char* wxContractPath (const wxString& filename,
const wxString& envname = wxEmptyString, const wxString& user = wxEmptyString);
WXDLLEXPORT char* wxContractPath(const wxString& filename,
const wxString& envname = "",
const wxString& user = "");
// Destructive removal of /./ and /../ stuff
WXDLLEXPORT char* wxRealPath(char *path);

View File

@@ -165,7 +165,7 @@ protected:
void *GetData() const { return m_data; }
void SetData(void *data) { m_data = data; }
// get 0-based index of this node within the list or NOT_FOUND
// get 0-based index of this node within the list or wxNOT_FOUND
int IndexOf() const;
virtual void DeleteData() { }
@@ -276,7 +276,7 @@ protected:
// by key
wxNodeBase *Find(const wxListKey& key) const;
// get 0-based index of object or NOT_FOUND
// get 0-based index of object or wxNOT_FOUND
int IndexOf( void *object ) const;
// this function allows the sorting of arbitrary lists by giving

View File

@@ -78,7 +78,7 @@ public:
virtual wxString GetHelpString(int id) const ;
// find item
// Finds the item id matching the given string, NOT_FOUND if not found.
// Finds the item id matching the given string, wxNOT_FOUND if not found.
virtual int FindItem(const wxString& itemString) const ;
// Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL.
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;

File diff suppressed because it is too large Load Diff

View File

@@ -188,7 +188,7 @@ int wxBaseArray::Index(long lItem, bool bFromEnd) const
}
}
return NOT_FOUND;
return wxNOT_FOUND;
}
// search for an item in a sorted array (binary search)
@@ -211,7 +211,7 @@ int wxBaseArray::Index(long lItem, CMPFUNC fnCompare) const
return i;
}
return NOT_FOUND;
return wxNOT_FOUND;
}
// add item at the end
void wxBaseArray::Add(long lItem)
@@ -275,7 +275,7 @@ void wxBaseArray::Remove(long lItem)
{
int iIndex = Index(lItem);
wxCHECK_RET( iIndex != NOT_FOUND,
wxCHECK_RET( iIndex != wxNOT_FOUND,
"removing inexistent item in wxArray::Remove" );
Remove((size_t)iIndex);

View File

@@ -1228,7 +1228,7 @@ void wxFileConfig::ConfigEntry::SetValue(const wxString& strValue, bool bUser)
}
else {
// add a new line to the file
wxASSERT( m_nLine == NOT_FOUND ); // consistency check
wxASSERT( m_nLine == wxNOT_FOUND ); // consistency check
m_pLine = Group()->Config()->LineListInsert(strLine,
Group()->GetLastEntryLine());

View File

@@ -445,7 +445,7 @@ bool wxLocale::Init(const char *szName,
void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
{
if ( s_searchPrefixes.Index(prefix) == NOT_FOUND )
if ( s_searchPrefixes.Index(prefix) == wxNOT_FOUND )
{
s_searchPrefixes.Add(prefix);
}

View File

@@ -131,7 +131,7 @@ wxNodeBase::~wxNodeBase()
int wxNodeBase::IndexOf() const
{
wxCHECK_MSG( m_list, NOT_FOUND, "node doesn't belong to a list in IndexOf");
wxCHECK_MSG( m_list, wxNOT_FOUND, "node doesn't belong to a list in IndexOf");
// It would be more efficient to implement IndexOf() completely inside
// wxListBase (only traverse the list once), but this is probably a more
@@ -337,7 +337,7 @@ int wxListBase::IndexOf(void *object) const
{
wxNodeBase *node = Find( object );
return node ? node->IndexOf() : NOT_FOUND;
return node ? node->IndexOf() : wxNOT_FOUND;
}
void wxListBase::DoDeleteNode(wxNodeBase *node)

View File

@@ -560,11 +560,11 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
// the format is the following: <full path to file>, <icon index>
// NB: icon index may be negative as well as positive and the full
// path may contain the environment variables inside '%'
wxString strFullPath = strIcon.Before(','),
strIndex = strIcon.Right(',');
wxString strFullPath = strIcon.BeforeLast(','),
strIndex = strIcon.AfterLast(',');
// index may be omitted, in which case Before(',') is empty and
// Right(',') is the whole string
// index may be omitted, in which case BeforeLast(',') is empty and
// AfterLast(',') is the whole string
if ( strFullPath.IsEmpty() ) {
strFullPath = strIndex;
strIndex = "0";
@@ -810,23 +810,23 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
// first look for an exact match
int index = m_aTypes.Index(mimetype);
if ( index == NOT_FOUND ) {
if ( index == wxNOT_FOUND ) {
// then try to find "text/*" as match for "text/plain" (for example)
// NB: if mimeType doesn't contain '/' at all, Left() will return the
// whole string - ok.
wxString strCategory = mimetype.Left('/');
// NB: if mimeType doesn't contain '/' at all, BeforeFirst() will return
// the whole string - ok.
wxString strCategory = mimetype.BeforeFirst('/');
size_t nCount = m_aTypes.Count();
for ( size_t n = 0; n < nCount; n++ ) {
if ( (m_aTypes[n].Before('/') == strCategory ) &&
m_aTypes[n].Right('/') == "*" ) {
if ( (m_aTypes[n].BeforeFirst('/') == strCategory ) &&
m_aTypes[n].AfterFirst('/') == "*" ) {
index = n;
break;
}
}
}
if ( index != NOT_FOUND ) {
if ( index != wxNOT_FOUND ) {
wxFileType *fileType = new wxFileType;
fileType->m_impl->Init(this, index);
@@ -955,7 +955,7 @@ void wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName)
}
int index = m_aTypes.Index(strMimeType);
if ( index == NOT_FOUND ) {
if ( index == wxNOT_FOUND ) {
// add a new entry
m_aTypes.Add(strMimeType);
m_aEntries.Add(NULL);
@@ -1055,7 +1055,7 @@ void wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName)
switch ( currentToken ) {
case Field_Type:
strType = curField;
if ( strType.Find('/') == NOT_FOUND ) {
if ( strType.Find('/') == wxNOT_FOUND ) {
// we interpret "type" as "type/*"
strType += "/*";
}
@@ -1077,7 +1077,7 @@ void wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName)
// is this something of the form foo=bar?
const char *pEq = strchr(curField, '=');
if ( pEq != NULL ) {
wxString lhs = curField.Left('='),
wxString lhs = curField.Before('='),
rhs = curField.After('=');
lhs.Trim(TRUE); // from right
@@ -1170,7 +1170,7 @@ void wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName)
strType.MakeLower();
int nIndex = m_aTypes.Index(strType);
if ( nIndex == NOT_FOUND ) {
if ( nIndex == wxNOT_FOUND ) {
// new file type
m_aTypes.Add(strType);
@@ -1186,7 +1186,7 @@ void wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName)
// before, thus we Append() the new entry to the list if it has
// already occured in _this_ file, but Prepend() it if it
// occured in some of the previous ones.
if ( aEntryIndices.Index(nIndex) == NOT_FOUND ) {
if ( aEntryIndices.Index(nIndex) == wxNOT_FOUND ) {
// first time in this file
aEntryIndices.Add(nIndex);
entry->Prepend(m_aEntries[nIndex]);

View File

@@ -672,11 +672,11 @@ wxString wxString::Right(size_t nCount) const
// get all characters after the last occurence of ch
// (returns the whole string if ch not found)
wxString wxString::Right(char ch) const
wxString wxString::AfterLast(char ch) const
{
wxString str;
int iPos = Find(ch, TRUE);
if ( iPos == NOT_FOUND )
if ( iPos == wxNOT_FOUND )
str = *this;
else
str = c_str() + iPos + 1;
@@ -697,7 +697,7 @@ wxString wxString::Left(size_t nCount) const
// get all characters before the first occurence of ch
// (returns the whole string if ch not found)
wxString wxString::Left(char ch) const
wxString wxString::BeforeFirst(char ch) const
{
wxString str;
for ( const char *pc = m_pchData; *pc != '\0' && *pc != ch; pc++ )
@@ -708,11 +708,11 @@ wxString wxString::Left(char ch) const
/// get all characters before the last occurence of ch
/// (returns empty string if ch not found)
wxString wxString::Before(char ch) const
wxString wxString::BeforeLast(char ch) const
{
wxString str;
int iPos = Find(ch, TRUE);
if ( iPos != NOT_FOUND && iPos != 0 )
if ( iPos != wxNOT_FOUND && iPos != 0 )
str = wxString(c_str(), iPos);
return str;
@@ -720,11 +720,11 @@ wxString wxString::Before(char ch) const
/// get all characters after the first occurence of ch
/// (returns empty string if ch not found)
wxString wxString::After(char ch) const
wxString wxString::AfterFirst(char ch) const
{
wxString str;
int iPos = Find(ch);
if ( iPos != NOT_FOUND )
if ( iPos != wxNOT_FOUND )
str = c_str() + iPos + 1;
return str;
@@ -911,7 +911,7 @@ wxString& wxString::Truncate(size_t uiLen)
}
// ---------------------------------------------------------------------------
// finding (return NOT_FOUND if not found and index otherwise)
// finding (return wxNOT_FOUND if not found and index otherwise)
// ---------------------------------------------------------------------------
// find a character
@@ -919,7 +919,7 @@ int wxString::Find(char ch, bool bFromEnd) const
{
const char *psz = bFromEnd ? strrchr(m_pchData, ch) : strchr(m_pchData, ch);
return (psz == NULL) ? NOT_FOUND : psz - m_pchData;
return (psz == NULL) ? wxNOT_FOUND : psz - m_pchData;
}
// find a sub-string (like strstr)
@@ -927,7 +927,7 @@ int wxString::Find(const char *pszSub) const
{
const char *psz = strstr(m_pchData, pszSub);
return (psz == NULL) ? NOT_FOUND : psz - m_pchData;
return (psz == NULL) ? wxNOT_FOUND : psz - m_pchData;
}
// ---------------------------------------------------------------------------
@@ -1385,7 +1385,7 @@ int wxArrayString::Index(const char *sz, bool bCase, bool bFromEnd) const
}
}
return NOT_FOUND;
return wxNOT_FOUND;
}
// add item at the end
@@ -1436,7 +1436,7 @@ void wxArrayString::Remove(const char *sz)
{
int iIndex = Index(sz);
wxCHECK_RET( iIndex != NOT_FOUND,
wxCHECK_RET( iIndex != wxNOT_FOUND,
_("removing inexistent element in wxArrayString::Remove") );
Remove(iIndex);

View File

@@ -579,7 +579,7 @@ wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const
wxArrayTreeItems& siblings = parent->GetChildren();
int index = siblings.Index(i);
wxASSERT( index != NOT_FOUND ); // I'm not a child of my parent?
wxASSERT( index != wxNOT_FOUND ); // I'm not a child of my parent?
size_t n = (size_t)(index + 1);
return n == siblings.Count() ? wxTreeItemId() : wxTreeItemId(siblings[n]);
@@ -599,7 +599,7 @@ wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const
wxArrayTreeItems& siblings = parent->GetChildren();
int index = siblings.Index(i);
wxASSERT( index != NOT_FOUND ); // I'm not a child of my parent?
wxASSERT( index != wxNOT_FOUND ); // I'm not a child of my parent?
return index == 0 ? wxTreeItemId()
: wxTreeItemId(siblings[(size_t)(index - 1)]);
@@ -707,7 +707,7 @@ wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parentId,
}
int index = parent->GetChildren().Index(idPrevious.m_pItem);
wxASSERT_MSG( index != NOT_FOUND,
wxASSERT_MSG( index != wxNOT_FOUND,
"previous item in wxTreeCtrl::InsertItem() is not a sibling" );
return DoInsertItem(parentId, (size_t)index, text, image, selImage, data);
}

View File

@@ -89,7 +89,7 @@ wxIniConfig::wxIniConfig(const wxString& strAppName, const wxString& strVendor,
// append the extension if none given and it's not an absolute file name
// (otherwise we assume that they know what they're doing)
if ( !wxIsPathSeparator(m_strLocalFilename[0u]) &&
m_strLocalFilename.Find('.') == NOT_FOUND )
m_strLocalFilename.Find('.') == wxNOT_FOUND )
{
m_strLocalFilename << ".ini";
}

View File

@@ -57,11 +57,11 @@ bool wxMatchMimeType(const wxString& mime_obj, const wxString& type)
if (mime_obj.Find('*') != -1) {
wxString part_str1[2], part_str2[2];
part_str1[0] = mime_obj.Left('/');
part_str1[1] = mime_obj.After('/');
part_str1[0] = mime_obj.BeforeFirst('/');
part_str1[1] = mime_obj.AfterFirst('/');
part_str2[0] = type.Left('/');
part_str2[1] = type.After('/');
part_str2[0] = type.BeforeFirst('/');
part_str2[1] = type.AfterFirst('/');
if (part_str1[0] == "*" && part_str1[1] == "*")
return TRUE;

View File

@@ -33,7 +33,13 @@
* and things like that.
*
* $Log$
* Revision 1.4 1999/01/14 14:33:39 VZ
* 1. NOT_FOUND -> wxNOT_FOUND
* 2. wxString::Left(), Right(), Before(), After() clean up
* 3. wxLocale updates
*
* Revision 1.3 1998/12/17 17:53:31 RD
*
* wxPython 0.5.2
* Minor fixes and SWIG code generation for RR's changes. MSW and GTK
* versions are much closer now!
@@ -1172,7 +1178,7 @@ SWIGEXPORT(void,initwxc)() {
PyDict_SetItemString(d,"wxMAJOR_VERSION", PyInt_FromLong((long) wxMAJOR_VERSION));
PyDict_SetItemString(d,"wxMINOR_VERSION", PyInt_FromLong((long) wxMINOR_VERSION));
PyDict_SetItemString(d,"wxRELEASE_NUMBER", PyInt_FromLong((long) wxRELEASE_NUMBER));
PyDict_SetItemString(d,"NOT_FOUND", PyInt_FromLong((long) NOT_FOUND));
PyDict_SetItemString(d,"wxNOT_FOUND", PyInt_FromLong((long) NOT_FOUND));
PyDict_SetItemString(d,"wxVSCROLL", PyInt_FromLong((long) wxVSCROLL));
PyDict_SetItemString(d,"wxHSCROLL", PyInt_FromLong((long) wxHSCROLL));
PyDict_SetItemString(d,"wxCAPTION", PyInt_FromLong((long) wxCAPTION));

View File

@@ -33,7 +33,13 @@
* and things like that.
*
* $Log$
* Revision 1.4 1999/01/14 14:33:56 VZ
* 1. NOT_FOUND -> wxNOT_FOUND
* 2. wxString::Left(), Right(), Before(), After() clean up
* 3. wxLocale updates
*
* Revision 1.3 1998/12/21 19:59:01 RD
*
* Now compiles with /GX- on MSW.
*
************************************************************************/
@@ -1216,7 +1222,7 @@ SWIGEXPORT(void,initwxc)() {
PyDict_SetItemString(d,"wxMAJOR_VERSION", PyInt_FromLong((long) wxMAJOR_VERSION));
PyDict_SetItemString(d,"wxMINOR_VERSION", PyInt_FromLong((long) wxMINOR_VERSION));
PyDict_SetItemString(d,"wxRELEASE_NUMBER", PyInt_FromLong((long) wxRELEASE_NUMBER));
PyDict_SetItemString(d,"NOT_FOUND", PyInt_FromLong((long) NOT_FOUND));
PyDict_SetItemString(d,"wxNOT_FOUND", PyInt_FromLong((long) NOT_FOUND));
PyDict_SetItemString(d,"wxVSCROLL", PyInt_FromLong((long) wxVSCROLL));
PyDict_SetItemString(d,"wxHSCROLL", PyInt_FromLong((long) wxHSCROLL));
PyDict_SetItemString(d,"wxCAPTION", PyInt_FromLong((long) wxCAPTION));