dune-grid
2.2.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
grid
io
file
dgfparser
blocks
basic.hh
Go to the documentation of this file.
1
#ifndef DUNE_DGF_BASICBLOCK_HH
2
#define DUNE_DGF_BASICBLOCK_HH
3
4
#include <cassert>
5
#include <iostream>
6
#include <string>
7
#include <sstream>
8
9
#include <dune/common/stdstreams.hh>
10
#include <
dune/grid/io/file/dgfparser/entitykey.hh
>
11
#include <
dune/grid/io/file/dgfparser/dgfexception.hh
>
12
13
namespace
Dune
14
{
15
16
namespace
dgf
17
{
18
19
inline
void
makeupcase
( std :: string &s )
20
{
21
for
(
size_t
i=0;i<s.size();i++)
22
s[i]=toupper(s[i]);
23
}
24
25
class
BasicBlock
26
{
27
int
pos;
// line number
28
bool
active;
// block was found
29
bool
empty;
// block was found but was empty
30
std::string identifier;
// identifier of this block
31
int
linecount;
// total number of lines in the block
32
std::stringstream block;
// the block itself
33
std::string oneline;
// the active line in the block
34
35
// get the block (if it exists)
36
void
getblock ( std::istream &in );
37
38
// count the number of lines in the block
39
// int countlines ();
40
41
protected
:
42
std::stringstream
line
;
// the active line as string buffer
43
// for use in the derived classes
44
45
// go back to beginning of block
46
void
reset
()
47
{
48
pos = -1;
49
block.clear();
50
block.seekg( 0 );
51
}
52
53
// get next line and store in string stream
54
bool
getnextline
();
55
56
// get next entry in line
57
template
<
class
ENTRY >
58
bool
getnextentry
( ENTRY &entry )
59
{
60
line
>> entry;
61
return
line
;
62
}
63
64
bool
gettokenparam
( std :: string token, std :: string &entry );
65
bool
findtoken
( std :: string token );
66
67
public
:
68
// search for block in file and store in buffer
69
BasicBlock
( std::istream &in,
const
char
*
id
);
70
71
// some information on this block
72
bool
isactive
()
73
{
74
return
active;
75
}
76
77
bool
isempty
()
78
{
79
return
empty;
80
}
81
82
int
&
noflines
()
83
{
84
return
linecount;
85
}
86
87
int
linenumber
()
88
{
89
return
pos;
90
}
91
92
const
std::string &
id
()
const
93
{
94
return
identifier;
95
}
96
97
// for error messages
98
friend
std :: ostream &
operator<<
( std :: ostream &os,
const
BasicBlock
&b )
99
{
100
return
os <<
"block "
<< b.identifier <<
" (line "
<< b.pos <<
")"
;
101
}
102
103
};
104
105
}
// end namespace dgf
106
107
}
// end namespace Dune
108
109
#endif
110
Generated on Tue Feb 26 2013 17:21:27 for dune-grid by
1.8.1.2