Compare commits
1 Commits
CPPUNIT_1_
...
TOKENZR_OR
Author | SHA1 | Date | |
---|---|---|---|
|
5599379cc6 |
@@ -1,80 +0,0 @@
|
||||
dnl
|
||||
dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_CPPUNIT,
|
||||
[
|
||||
|
||||
AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
|
||||
cppunit_config_prefix="$withval", cppunit_config_prefix="")
|
||||
AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
|
||||
cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
|
||||
|
||||
if test x$cppunit_config_exec_prefix != x ; then
|
||||
cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
|
||||
if test x${CPPUNIT_CONFIG+set} != xset ; then
|
||||
CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
|
||||
fi
|
||||
fi
|
||||
if test x$cppunit_config_prefix != x ; then
|
||||
cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
|
||||
if test x${CPPUNIT_CONFIG+set} != xset ; then
|
||||
CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
|
||||
cppunit_version_min=$1
|
||||
|
||||
AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
|
||||
no_cppunit=""
|
||||
if test "$CPPUNIT_CONFIG" = "no" ; then
|
||||
no_cppunit=yes
|
||||
else
|
||||
CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
|
||||
CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
|
||||
cppunit_version=`$CPPUNIT_CONFIG --version`
|
||||
|
||||
cppunit_major_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
cppunit_minor_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
cppunit_micro_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
|
||||
cppunit_major_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
cppunit_minor_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
cppunit_micro_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
|
||||
cppunit_version_proper=`expr \
|
||||
$cppunit_major_version \> $cppunit_major_min \| \
|
||||
$cppunit_major_version \= $cppunit_major_min \& \
|
||||
$cppunit_minor_version \> $cppunit_minor_min \| \
|
||||
$cppunit_major_version \= $cppunit_major_min \& \
|
||||
$cppunit_minor_version \= $cppunit_minor_min \& \
|
||||
$cppunit_micro_version \>= $cppunit_micro_min `
|
||||
|
||||
if test "$cppunit_version_proper" = "1" ; then
|
||||
AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
no_cppunit=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$no_cppunit" = x ; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
CPPUNIT_CFLAGS=""
|
||||
CPPUNIT_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
|
||||
AC_SUBST(CPPUNIT_CFLAGS)
|
||||
AC_SUBST(CPPUNIT_LIBS)
|
||||
])
|
||||
|
||||
|
||||
|
57
include/wx/tokenzr.h
Normal file
57
include/wx/tokenzr.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tokenzr.h
|
||||
// Purpose: String tokenizer
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: 04/22/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TOKENZRH
|
||||
#define _WX_TOKENZRH
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/filefn.h"
|
||||
|
||||
class WXDLLEXPORT wxStringTokenizer : public wxObject
|
||||
{
|
||||
public:
|
||||
wxStringTokenizer(const wxString& to_tokenize,
|
||||
const wxString& delims = " \t\r\n",
|
||||
bool ret_delim = FALSE);
|
||||
wxStringTokenizer() { m_retdelims = FALSE;}
|
||||
virtual ~wxStringTokenizer();
|
||||
|
||||
int CountTokens() const;
|
||||
bool HasMoreTokens();
|
||||
|
||||
wxString NextToken();
|
||||
wxString GetNextToken() { return NextToken(); };
|
||||
|
||||
wxString GetString() const { return m_string; }
|
||||
|
||||
void SetString(const wxString& to_tokenize,
|
||||
const wxString& delims = " \t\r\n",
|
||||
bool ret_delim = FALSE)
|
||||
{
|
||||
m_string = to_tokenize;
|
||||
m_delims = delims;
|
||||
m_retdelims = ret_delim;
|
||||
}
|
||||
|
||||
protected:
|
||||
off_t FindDelims(const wxString& str, const wxString& delims) const;
|
||||
void EatLeadingDelims();
|
||||
|
||||
wxString m_string, m_delims;
|
||||
bool m_retdelims;
|
||||
};
|
||||
|
||||
#endif // _WX_TOKENZRH
|
138
src/common/tokenzr.cpp
Normal file
138
src/common/tokenzr.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tokenzr.cpp
|
||||
// Purpose: String tokenizer
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: 04/22/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "tokenzr.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
wxStringTokenizer::wxStringTokenizer(const wxString& to_tokenize,
|
||||
const wxString& delims,
|
||||
bool ret_delims)
|
||||
{
|
||||
m_string = to_tokenize;
|
||||
m_delims = delims;
|
||||
m_retdelims = ret_delims;
|
||||
}
|
||||
|
||||
wxStringTokenizer::~wxStringTokenizer()
|
||||
{
|
||||
}
|
||||
|
||||
off_t wxStringTokenizer::FindDelims(const wxString& str, const wxString& delims) const
|
||||
{
|
||||
for ( size_t i = 0; i < str.Length(); i++ )
|
||||
{
|
||||
wxChar c = str[i];
|
||||
|
||||
for ( size_t j = 0; j < delims.Length() ; j++ )
|
||||
{
|
||||
if ( delims[j] == c )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxStringTokenizer::CountTokens() const
|
||||
{
|
||||
wxString p_string = m_string;
|
||||
bool found = TRUE;
|
||||
int pos, count = 1;
|
||||
|
||||
if (p_string.Length() == 0)
|
||||
return 0;
|
||||
|
||||
while (found)
|
||||
{
|
||||
pos = FindDelims(p_string, m_delims);
|
||||
if (pos != -1)
|
||||
{
|
||||
count++;
|
||||
p_string = p_string(pos+1, p_string.Length());
|
||||
}
|
||||
else
|
||||
{
|
||||
found = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
bool wxStringTokenizer::HasMoreTokens()
|
||||
{
|
||||
return !m_string.IsEmpty();
|
||||
}
|
||||
|
||||
// needed to fix leading whitespace / mult. delims bugs
|
||||
void wxStringTokenizer::EatLeadingDelims()
|
||||
{
|
||||
int pos;
|
||||
|
||||
// while leading delims trim 'em from the left
|
||||
while ( ( pos = FindDelims(m_string, m_delims)) == 0 )
|
||||
{
|
||||
m_string = m_string.Mid((size_t)1);
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxStringTokenizer::NextToken()
|
||||
{
|
||||
off_t pos, pos2;
|
||||
wxString r_string;
|
||||
|
||||
if ( m_string.IsEmpty() )
|
||||
return m_string;
|
||||
|
||||
if ( !m_retdelims )
|
||||
EatLeadingDelims();
|
||||
|
||||
pos = FindDelims(m_string, m_delims);
|
||||
if (pos == -1)
|
||||
{
|
||||
r_string = m_string;
|
||||
m_string = wxEmptyString;
|
||||
|
||||
return r_string;
|
||||
}
|
||||
|
||||
if (m_retdelims)
|
||||
{
|
||||
if (!pos)
|
||||
{
|
||||
pos++;
|
||||
pos2 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = pos;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = pos + 1;
|
||||
}
|
||||
|
||||
r_string = m_string.Left((size_t)pos);
|
||||
m_string = m_string.Mid((size_t)pos2);
|
||||
|
||||
return r_string;
|
||||
}
|
Reference in New Issue
Block a user