VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
csvUtil.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: parseCSV.h,v $ $Revision: 1.1 $ $State: Exp $
7 *******************************************************************************/
8 
11 
12 
13 #pragma once
14 
15 #include <string>
16 
21 
22 template <typename Container>
23 void parseCsv (Container &container, std::string const &in)
24 {
25  const std::string::size_type len = in.length();
26  std::string::size_type i = 0;
27  std::string::size_type j = 0;
28 
29  while ( j < len )
30  {
31  i = in.find_first_of(",", i);
32  if (i == std::string::npos)
33  {
34  container.push_back(in.substr(j, len));
35  return;
36  }
37  if (i == j)
38  {
39  container.push_back("");
40  }
41  else
42  {
43  container.push_back(in.substr(j, i-j));
44  }
45  i++;
46  j=i;
47  }
48 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)