- solidgraph_sources.zip
- solidgraph_sources
- ArMaX
- Boolean
- CxImage
- Debug
- DraftTemplates
- DT1.sdt
- DT2.sdt
- sgCore.dll
- ExGUILib
- jpeg
- Kinematic
- lua
- MaterialsEditor
- png
- Release
- sgCore.dll
- Scripts
- boxes.sgs
- circles.sgs
- cones.sgs
- cylinders.sgs
- ellipsoids.sgs
- lines.sgs
- points.sgs
- print.sgs
- Script.sgs
- spBands.sgs
- spheres.sgs
- toruses.sgs
- sgCore
- Solidgraph.sln
- Solidgraph
- SplashLib
- Standard2D
- arc.bmp
- circ.bmp
- Commands
- Dialogs
- line.bmp
- path.bmp
- pnt.bmp
- ReadMe.txt
- res
- circ_3p.bmp
- circ_c_r.bmp
- circ_edit_cen.bmp
- circ_edit_norm.bmp
- circ_edit_rad.bmp
- line_arc_end.bmp
- line_arc_perpendic_end.bmp
- line_edit.bmp
- line_line_extension.bmp
- line_line_perpendic_end.bmp
- line_point_increment.bmp
- line_point_vector.bmp
- line_two_points.bmp
- pnt_edit.bmp
- Spline_edit.bmp
- Standard2D.rc2
- resource.h
- spl.bmp
- Standard2D.cpp
- Standard2D.def
- Standard2D.rc
- Standard2D.vcproj
- StdAfx.cpp
- StdAfx.h
- toolbar.bmp
- toolbarBMP.bmp
- toolbarBMPOld.bmp
- Standard3D
- Surfaces
- tiff
- zlib
- solidgraph_bin.zip
- solidgraph_bin
- DraftTemplates
- DT1.sdt
- DT2.sdt
- Plugins
- Boolean.ppl
- Kinematic.ppl
- Standard2D.ppl
- Standard3D.ppl
- Surfaces.ppl
- sgCore.dll
- Solidgraph.exe
- SplashLib.dll
|
/* ==========================================================================
Class : CTokenizer
Date : 06/18/04
Purpose : "CTokenizer" is a very simple class to tokenize a string
into a string array.
Description : The string is chopped up and put into an internal
"CStringArray". With "GetAt", different types of data can
be read from the different elements.
Usage : Create an instance of "CTokenizer" on the stack. Set
the string to parse in the "ctor", and the delimiter if
not a comma. The "ctor" automatically tokenize the input
string.
Call "GetSize" to get the number of
tokens, and "GetAt" to get a specific token.
You can also reuse the tokenizer by calling "Init".
========================================================================
Changes : 28/8 2004 Changed a char to TCHAR to allow UNICODE
building (Enrico Detoma)
========================================================================*/
#include "stdafx.h"
#include "Tokenizer.h"
////////////////////////////////////////////////////////////////////
// Public functions
//
CTokenizer::CTokenizer( CString strInput, const CString & strDelimiter )
/* ============================================================
Function : CTokenizer::CTokenizer
Description : Constructor.
Access : Public
Return : void
Parameters : CString strInput - String to
tokenize
const CString & strDelimiter - Delimiter,
defaults to
comma.
Usage : Should normally be created on the stack.
============================================================*/
{
Init(strInput, strDelimiter);
}
void CTokenizer::Init( const CString & strInput, const CString & strDelimiter )
/* ============================================================
Function : CTokenizer::Init
Description : Reinitializes and tokenizes the tokenizer
with "strInput". "strDelimiter" is the
delimiter to use.
Access : Public
Return : void
Parameters : const CString & strInput - New string
const CString & strDelimiter - Delimiter,
defaults to
comma
Usage : Call to reinitialize the tokenizer.
============================================================*/
{
CString copy( strInput );
m_stra.RemoveAll();
int nFound = copy.Find( strDelimiter );
while(nFound != -1)
{
CString strLeft;
strLeft = copy.Left( nFound );
copy = copy.Right( copy.GetLength() - ( nFound + 1 ) );
m_stra.Add( strLeft );
nFound = copy.Find( strDelimiter );
}
m_stra.Add( copy );
}
int CTokenizer::GetSize( ) const
/* ============================================================
Function : CTokenizer::GetSize
Description : Gets the number of tokens in the tokenizer.
Access : Public
Return : int - Number of tokens.
Parameters : none
Usage : Call to get the number of tokens in the
tokenizer.
============================================================*/
{
return m_stra.GetSize();
}
void CTokenizer::GetAt( int nIndex, CString & str ) const
/* ============================================================
Function : CTokenizer::GetAt
Description : Get the token at "nIndex" and put it in
"str".
Access : Public
Return : void
Parameters : int nIndex - Index to get token from
CString & str - Result
Usage : Call to get the value of the token at
"index".
============================================================*/
{
if( nIndex < m_stra.GetSize() )
str = m_stra.GetAt( nIndex );
else
str = _T( "" );
}
void CTokenizer::GetAt( int nIndex, int & var ) const
/* ============================================================
Function : CTokenizer::GetAt
Description : Get the token at "nIndex" and put it in
"var".
Access : Public
Return : void
Parameters : int nIndex - Index to get token from
int & var - Result
Usage : Call to get the value of the token at
"index".
============================================================*/
{
if( nIndex < m_stra.GetSize() )
var = _ttoi( m_stra.GetAt( nIndex ) );
else
var = 0;
}
void CTokenizer::GetAt( int nIndex, WORD & var ) const
/* ============================================================
Function : CTokenizer::GetAt
Description : Get the token at "nIndex" and put it in
"var".
Access : Public
Return : void
Parameters : int nIndex - Index to get token from
WORD & var - Result
Usage : Call to get the value of the token at
"index".
============================================================*/
{
if( nIndex < m_stra.GetSize() )
var = static_cast< WORD >( _ttoi( m_stra.GetAt( nIndex ) ) );
else
var = 0;
}
void CTokenizer::GetAt( int nIndex, double & var ) const
/* ============================================================
Function : CTokenizer::GetAt
Description : Get the token at "nIndex" and put it in
"var".
Access : Public
Return : void
Parameters : int nIndex - Index to get token from
double & var - Result
Usage : Call to get the value of the token at
"index".
============================================================*/
{
TCHAR *stop;
if( nIndex < m_stra.GetSize() )
var = _tcstod( m_stra.GetAt( nIndex ), &stop );
else
var = 0.0;
}
void CTokenizer::GetAt( int nIndex, DWORD & var ) const
/* ============================================================
Function : CTokenizer::GetAt
Description : Get the token at "nIndex" and put it in
"var".
Access : Public
Return : void
Parameters : int nIndex - Index to get token from
DWORD & var - Result
Usage : Call to get the value of the token at
"index".
============================================================*/
{
if( nIndex < m_stra.GetSize() )
var = static_cast< DWORD >( _ttoi( m_stra.GetAt( nIndex ) ) );
else
var = 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.