VR-Forces 4.0.4 Class Documentation
include/vrfutil/parseCSV.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2005 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: parseCSV.h,v $ $Revision: 1.1 $ $State: Exp $
00007 *******************************************************************************/
00008 
00011 
00012 
00013 #ifndef DtParseCSV_H_
00014 #define DtParseCSV_H_
00015 
00016 #include <string>
00017 
00022 
00023 template <typename Container>
00024 void parseCSV (Container &container, std::string const &in)
00025 {
00026    const std::string::size_type len = in.length();
00027    std::string::size_type i = 0;
00028    std::string::size_type j = 0;
00029 
00030    while ( j < len )
00031    {
00032       i = in.find_first_of(",", i);
00033       if (i == std::string::npos)
00034       {
00035          container.push_back(in.substr(j, len));
00036          return;
00037       }
00038       if (i == j)
00039       {
00040          container.push_back("");
00041       }
00042       else 
00043       {
00044          container.push_back(in.substr(j, i-j));
00045       }
00046       i++;      
00047       j=i;
00048    }
00049 }
00050 
00051 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)