VR-Forces 4.1 Class Documentation
parseCSV.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 #ifndef DtParseCSV_H_
14 #define DtParseCSV_H_
15 
16 #include <string>
17 
22 
23 template <typename Container>
24 void parseCSV (Container &container, std::string const &in)
25 {
26  const std::string::size_type len = in.length();
27  std::string::size_type i = 0;
28  std::string::size_type j = 0;
29 
30  while ( j < len )
31  {
32  i = in.find_first_of(",", i);
33  if (i == std::string::npos)
34  {
35  container.push_back(in.substr(j, len));
36  return;
37  }
38  if (i == j)
39  {
40  container.push_back("");
41  }
42  else
43  {
44  container.push_back(in.substr(j, i-j));
45  }
46  i++;
47  j=i;
48  }
49 }
50 
51 #endif

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)