contiifstream.h 2.28 KB
Newer Older
1
2
3
4
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Copyright Projet JRL-Japan, 2007
 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
5
6
 * File:      Contiifstream.h
 * Project:   DYNAMIC-GRAPH
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 * Author:    Nicolas Mansard
 *
 * Version control
 * ===============
 *
 *  $Id$
 *
 * Description
 * ============
 *
 *
 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/



#ifndef __CONTIIFSTREAM_HH__
#define __CONTIIFSTREAM_HH__

/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */


#include <iostream>
#include <fstream>
#include <sstream>
#ifndef WIN32
#include <unistd.h>
#endif
#include <list>

38
#include <dynamic-graph/interpreter.h>
39
40
41
42
43
44
45
46
47
#ifndef WIN32
#include <pthread.h>
#endif
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */

#if defined (WIN32) 
#  if defined (sotContiifstream_EXPORTS)
48
#    define DYNAMICGRAPHCONTIIFSTREAM_EXPORT __declspec(dllexport)
49
#  else  
50
#    define DYNAMICGRAPHCONTIIFSTREAM_EXPORT __declspec(dllimport)
51
52
#  endif 
#else
53
#  define DYNAMICGRAPHCONTIIFSTREAM_EXPORT
54
#endif
55
56

namespace dynamicgraph {
57
58
59
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
60
class DYNAMICGRAPHCONTIIFSTREAM_EXPORT Contiifstream
61
62
63
64
65
66
67
68
69
70
{
protected:
  std::string filename;
  unsigned int cursor;
  static const unsigned int BUFFER_SIZE = 256;
  char buffer[BUFFER_SIZE];
  std::list< std::string > reader;
  bool first;
 
public: /* --- Constructor --- */
71
72
  Contiifstream( const std::string& n="" );
  ~Contiifstream( void );
73
74
75
76
77
78
79
80
81
82
83
  void open( const std::string& n ) { filename=n; cursor=0; }
  
public: /* --- READ FILE --- */
  bool loop( void );
  
public: /* --- READ LIST --- */
  inline bool ready( void ) { return 0<reader.size();}
  std::string next( void ) ;
  

};
84
} // namespace dynamicgraph
85
86
87
88
89
90

#endif /* #ifndef __CONTIIFSTREAM_HH__ */