A Simple CString Tokenizer

As the name suggests, this is a simple class to extract tokens from a CSting. I wrote this class becuase during the course of my final year project at University I needed a simple way to extract 'tokens' from a CString. This is what I came up with. Its probably not the best or most effeicent way to accomplish the task - but it works which in the main thing.

To use the CToken class:

-First include the CToken header file in your porgram:

#include "Token.h"

-Then you are free to create and use an instance of CToken. For example:

CString str = "A B C D"
CString newTok;
CToken tok(str);
tok.SetToken(" ");
while(tok.MoreTokens())
{
   newTok = tok.GetToken()
}
Improvements:
If people can suggest any improvements or there bugs please drop me an email

Download demo project - 15 KB

Download source - 3 KB



Comments

  • Comment utiliser lisseur ghd

    Posted by ultjwn926 on 07/16/2013 12:57am

    Lorsqu'on l'interroge sur Mermaid photoshoot pour ghd, Katy Perry a déclaré: «Je l'aime parce que je suis un fan des films de Disney. Ariel est une si grande influence. C'est toujours amusant de se déguiser une fois dans la vie comme une sirène et avoir cette belle queue de poisson. David La Chapelle a fait un ensemble étonnant. C'était amusant - je dois avoir les cheveux violet qui préfigure la vraie cheveux violets j'ai eu l'automne dernier. C'est comme Lisa Frank avait fait La Petite Sirène. "Bien qu'il y ait beaucoup à avoir une couleur de cheveux que Katy Perry ne pouvait pas porter, les teintes plus foncées vraiment faire ressortir ses traits. De quelle couleur est la prochaine Katy Perry? Nous avons juste à attendre et voir! [url=http://ghdpascherfer.tripod.com/]ghd lisseur[/url] Défrisants GHD stylers sont tous azimuts comme forlater cheveux incroyablement joliment et beundringsverdig. Ces elementene est tellement portable et a noen egenskaper qui les rend difficiles agréable voyage de la rivière avec ou transporter. Dessuten rend tige droite, un bon cadeau pour un Kvinne sur bursdag sien et devient vraiment verdsatt av tout comme Mottar comme un cadeau. Noen Surprise confortables bursdag sienne avec GHD Ensemble-cadeau précieux. [url=http://ghdpascherferfr.webgarden.com/]ghd pas cher[/url] GHD Edition Limitée Noël Gift Set contient tout ce dont vous avez besoin précieux pour créer de superbes modèles saisonniers. La boîte est exquis pour trouver le cadeau parfait sous l'arbre. Vous trouverez dans la boîte de cadeau: argent et noir redresseurs ghd IV styler pas cher et sèche-cheveux Voyage sont présentés dans un beau sac paillettes roll-up rouleau métallique fermée avec une cravate de satin noir. Le fer à lisser et sèche-cheveux dans son propre individu résistant à la chaleur amovible avec fermeture à glissière est parfait pour les week-end célébration supplémentaire. Le sac de rouleau glamour sert aussi une surface résistante à la chaleur utile pour assurer la sécurité de style sur la route.

    Reply
  • Purple ghd rettetang billig for salg i Norge

    Posted by carpinteyrowsz on 06/14/2013 04:44am

    [url=http://www.rettetangnorgenews.net/]ghd rettetang pris[/url] Tredje, De tilbyr også avrundet fat som kan gjøre en mye mer allsidig GHD jern enn andre typer hår stylers i markedet. Hvis du liker å endre ditt hår er ofte en klar fordel at du bruker ghd hår straighteners kan også skape bølger, hopp og loops.Endelig, må du velge en GHD jern er konstruert for bruk i eksplosjoner eller frynser. GHD IV styler Mini er perfekt for mye kortere hår. Kombiner disse glimrende funksjonene den mest omfattende rettetang, men det er enklere å bruke på mindre biter av hair.Maybe du har vet hvilke ghd rettetang [url=http://www.rettetangnewsnorge.com/]ghd rettetang pris[/url] Fargeprosessen endrer overflatestrukturen en smule på farget og bleket hår. Derfor er det spesielt viktig å hindre mer stress til overflaten på det fargede håret.I tillegg er en av platene støttet av fjærer og gir etter hvis du bruker for mye krefter under stylingen.De patenterte bevegelige platene gir ekstra beskyttelse og er tre ganger glattere enn konvensjonelle plater og reduserer friksjon betydelig. I tillegg er en av platene støttet av en fjær og gir etter hvis du bruker for mye makt i løpet av stylingen. [url=http://www.rettetangnewsnorge.com/falske-ghd]rettetang ghd[/url] Rettetang med den avanserte teknologien innen keratin, gjør at du beskytter den naturlige glansen i håret ditt mens du styler. Den har klar til bruk-indikator, digitale innstillinger med justerbar varmed for å få et jevnt resultat og et enkelt låsesystem for praktisk oppbevaring.Profesjonell slettetang med ekstra lange plater for maksimal effekt på langt/fyldig hår.Tilpass temperaturen etter håret ditt.Høyresistent keramisk belegg med tourmaline for beste resultat.

    Reply
  • Trist omringd om te kunnen stroom gehecht aan klanten veranderen

    Posted by mrswanzi on 06/05/2013 07:31pm

    [url=http://koptelefoon-monsterbeats.manifo.com/]Beats by dre Goedkope[/url] Beats By Dre Kopen doe je bij een geautoriseerde dealer. Bij een geautoriseerde dealer weer je zeker dat je een originele beats by dre koopt. Tevens heeft het kopen bij een geautoriseerde dealer het voordeel dat je ook weet dat je garantie goed zit. De dealer handelt samen met jouw garantiekwesties af. Onofficiele gaan dit soort dingen het liefst uit de weg. [url=http://monsterkoptelefoon.npage.de/]beats by dre kopen[/url] Naast dat je je muziek wireless kunt beluisteren via bluetooth kun je er ook altijd nog voor kiezen om gewoon de meegeleverde kabel te gebruiken. Bijvoorbeeld wanneer je via een apparaat luisterd wat geen bluetooth ondersteund. Of als dat batterijen voor de bluetooth funcie leeg zijn (deze gaan ongeveer 10 uur lang mee).De komende de Monster Beats Dr Dre urBeats koptelefoon [url=http://koptelefoon-monsterbeats.webs.com/]Goedkope Beats by dre[/url] Nu is de welbekende Beats by Dr. Dre Studio-serie bijvoorbeeld aangevuld met een aantalfrisse kleuren. Zo bevat de nieuwe reeks een Beats by Dr. Dre Studio hoofdtelefoon zilver, een Beats by Dr. Dre Studio hoofdtelefoon blauw en een Beats by Dr. Dre Studio hoofdtelefoon paars. Mag het allemaal nog iets feller en frivoler Dan is de Beats by Dr. Dre Studio hoofdtelefoon oranje, de Beats by Dr. Dre Studio hoofdtelefoon groen of de Beats by Dr. Dre Studio hoofdtelefoon roze wellicht een goede optie.

    Reply
  • Qué colecciones con secador de pelo GHD alisadores

    Posted by hanmeihm on 05/30/2013 05:03am

    [url=http://www.planchasespanaghdtop.net/]GHD Plancha España[/url] Vamos a ser considerados la nica persona que es un empuje total sobre cualquier dispositivo actualmente Te adoramos, dentro de mi color favorito Supongo que son los individuos tanto como yo los tos de publicidad de todo el mundo haba estado financiero sobre cada vez que hay qu etapa asociada a dispositivos "girly" liberados - con todo lo que una persona entendida actualmente, publicado en rojo ... simplemente porque es exactamente lo que las mujeres, como! muy bien, muy aqua azul es en realidad el color de mi punto dbil, personal ... y yo soy el empuj®n ms para aquellas cuestiones aqua azul s®lo hay que observar el dedo del pie de selecci®n esmalte de uas personales o incluso las fotos que el nmero PIN en mi pequea ceremonia Panel pinterest motivaci®n boda con respecto a los vestidos bridesmiad (bastante establecido deseo de poner en la aguamarina calzado azul tambin), sino que es toda una persona publicar ... en este momento, para tomar en cuenta especialmente en el ltimo accesorio para los reales ghd seres queridos!ghd son perfectos elegir seoras definetley [url=http://www.planchasespanaghdtop.net/]Planchas GHD[/url] Una buena cantidad de crema grande, dulce o jugo de fruta, es realmente una preparacin suficiente, y tambin podr¢ ver el nmero de personas que adhieren a un ensayo corto no llegan a disfrutar de los granos con azcar, y luego se imaginara lo m¢s r¢pidamente de dispensacin de obtencin de una comida completamente relativa ghd espaa usando los granos.Todos estos se ofrecen en lnea para obtener un centro comercial significativamente mucho m¢s conveniente. Los rangos de precios de etiqueta de $ 20 a $ 300 o mucho m¢s lejos. | Ventajas de la oferta actual de la empresa CardsAmong los numerosos problemas en las organizaciones ser¢ el mantenimiento de una buena relacin con la utilizacin de los consumidores, empleados y clientes. [url=http://www.planchasghdbaratasonline.com/blog/]ghd planchas precios[/url] El principal culpable de la destruccin de pelo es el uso excesivo del estilo planchas ghd. Cuando se utiliza demasiadas herramientas y productos para peinar, que han perdido su forma natural y rebote. Una cosa que a menudo le ayudar a mantener su definicin es simplemente cortar y simplificar la rutina de modelado.

    Reply
  • More concessions with herveleger, more stagger!

    Posted by wolemrfqcm on 04/29/2013 08:39pm

    wenchpicayune shaverelationpurloinmaterialmarket in

    Reply
  • Nike Draught Max+instagram, wishes you contain the color to bear up on your feet!

    Posted by madytreathy on 04/23/2013 09:13pm

    Remember in 2008, if not earlier, when Nike launched winning of the separated shoe color projects, the catchword "Whiz Your Colours", "Nike PhotoiD" blueprint, [url=http://northernroofing.co.uk/roofins.cfm]nike free run[/url] response has not been as avid as expected. Think, 2008 Canon IXUS 80 IS Digital greetings card arcade but purely 8 million pixels, Nokia, the plastic phone market-place is the one leadership, NikeiD was promote to color in the photos as a infrastructure quest of sneakers duty color, although gripping, but does bother some. Instagram which cause this thing fun and simple, Nike PHOTOiD homeopathic upgrade customization services, recently [url=http://markwarren.org.uk/goodbuy.cfm]nike free uk[/url] released a strange plan. That such iD can you realize pictures as instagram account shoe color, for a short offer Nike Mood Max shoes and Nike Refresh Max 1, Nike Air Max 90 953 options. Interested in children's shoes, you [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] can ever conform with each other's legitimate website photoid.Nike.com, in beyond to flip other people's artistic work, or you can make an effort to upload your own instagram photo, erect your own Nike Air Max.

    Reply
  • help

    Posted by umar on 01/25/2013 02:11am

    hi, I am a beginner in C++. And i am very thankful to you if answer my question kindly. i want to know that if i save a file with a lot of data using ofstream then if i want to find a specific data from whole file. who can i do it.How can i make a struct or function for it. what is the coding please tell me.

    Reply
  • problem: blank tokens are trimmed!

    Posted by pamar on 11/15/2007 11:35am

    Whit this string: "A|B|C| " and | separator, last token must be " " but it is trimmed.

    Reply
  • i rewrote it : shorter & better

    Posted by Legacy on 03/10/2003 12:00am

    Originally posted by: joeri

    just for those in need, i thought this delimiter wasn't working well, so i rewrote it:

    class CToken
    {
    public:
    virtual CString GetNextToken(); // Returns the next token
    virtual BOOL MoreTokens(); // Do we have any more tokens to retrieve
    int m_nAmount;
    int m_nCurrent;
    CToken(CString str,CString token=" ");
    virtual ~CToken();

    protected:
    CString m_strToToken; // The original string to tokenize
    CString m_strLeft; // The string we have left after taking tokens out
    CString m_strToken; // What is the value to tokenize on?
    private:
    int GetAmount(CString str);
    };

    CToken::CToken(CString str, CString token)
    {
    str.TrimLeft();
    str.TrimRight();
    m_strToToken = str;
    m_strLeft = str;
    m_strToken = token;
    m_nAmount = GetAmount(str);
    m_nCurrent = 0;
    }

    CToken::~CToken()
    {

    }

    int CToken::GetAmount(CString str)
    {
    int count = 0;

    int pos, len;

    len = str.GetLength();
    pos = str.Find(m_strToken,0);
    while (pos != -1)
    {
    count++;
    pos++;
    str = str.Right(len - pos);
    str.TrimLeft();
    len = str.GetLength();
    pos = str.Find(m_strToken,0);
    }
    if (!str.IsEmpty()) count++;
    return count;
    }
    BOOL CToken::MoreTokens()
    {
    if (m_nCurrent < m_nAmount)
    return TRUE;
    else return FALSE;
    }


    CString CToken::GetNextToken()
    {

    if(!MoreTokens())
    return "";
    CString ret;
    int pos, len;

    len = m_strLeft.GetLength();
    pos = m_strLeft.Find(m_strToken,0);
    if (pos != -1)
    {
    ret = m_strLeft.Left(pos);
    pos++;
    m_strLeft = m_strLeft.Right(len - pos);
    m_strLeft.TrimLeft();
    }
    else ret = m_strLeft;
    m_nCurrent++;
    return ret;}

    Reply
  • lexiacal analyzing

    Posted by Legacy on 01/12/2003 12:00am

    Originally posted by: alan

    helloo  friend,
    
    i want a help from u?now i am doing a project with some lexiacal analysing data.actually my problem is i have to do this with a group of data.from the given passage or text i have to find out the stake hilders needs,alterables and constraints.i have to identify these thibgs from the text.for this i have to search each and every string.could u please suggest some tools to identify these things from a passage.if could it will a great help for me.and i am doing this with c++ and flex (unix programming toool).hindly plzz suggest some logics and better sites from there i could find sample codes....... thanking you
    alan

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: November 13, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT APIs can be a great source of competitive advantage. The practice of exposing backend services as APIs has become pervasive, however their use varies widely across companies and industries. Some companies leverage APIs to create internal, operational and development efficiencies, while others use them to drive ancillary revenue channels. Many companies successfully support both public and private programs from the same API by varying levels …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds