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