/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui

« back to all changes in this revision

Viewing changes to apps/csv2root/csv.hpp

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _DS_CSV_H
 
2
#define _DS_CSV_H
 
3
 
 
4
#include <iostream>
 
5
#include <vector>
 
6
#include <string>
 
7
 
 
8
#include <boost/date_time/posix_time/ptime.hpp>
 
9
 
 
10
#include "string.hpp"
 
11
 
 
12
/* We are expecting the time in CSV to be in GMT using following format (Excel
 
13
compatible): 31-Jan-07 23:59:59 */
 
14
 
 
15
namespace ds {
 
16
 template <class TElement = double>
 
17
 class CSVCustom {
 
18
    std::istream *csv_stream;
 
19
    std::string date_format;
 
20
 
 
21
  public:
 
22
    CSVCustom(std::istream &in) : date_format("%d-%b-%y %H:%M:%S") {
 
23
        csv_stream = &in;
 
24
    }
 
25
    
 
26
    void set_date_format(string &format);
 
27
    void parse_time(boost::posix_time::ptime &parsed_time, std::string &string_time);
 
28
    
 
29
    
 
30
    void get_headers(std::vector<std::string> &headers);    
 
31
    bool skip_rows(boost::posix_time::ptime to);
 
32
    bool get_row(boost::posix_time::ptime &header, vector<TElement> &data);
 
33
    bool get_row(boost::posix_time::ptime &header, std::size_t n_columns, TElement *column);
 
34
    bool get_row(time_t &header, vector<TElement> &data);
 
35
    bool get_row(time_t &header, std::size_t n_columns, TElement *column);
 
36
 };
 
37
 
 
38
 typedef CSVCustom<> CSV;
 
39
};
 
40
 
 
41
#endif /* _DS_CSV_H */