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