PPL  1.2
Variables_Set.cc
Go to the documentation of this file.
1 /* Variables_Set class implementation (non-inline functions).
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #include "ppl-config.h"
25 #include "Variables_Set_defs.hh"
26 #include <iostream>
27 
28 namespace PPL = Parma_Polyhedra_Library;
29 
31  : Base() {
32  for (dimension_type d = v.id(), last = w.id(); d <= last; ++d) {
33  insert(d);
34  }
35 }
36 
37 bool
39  for (const_iterator i = begin(), set_end = end();
40  i != set_end; ++i) {
41  if (!Variable(*i).OK()) {
42  return false;
43  }
44  }
45  return true;
46 }
47 
49 std::ostream&
50 PPL::IO_Operators::operator<<(std::ostream& s, const Variables_Set& vs) {
51  s << '{';
52  for (Variables_Set::const_iterator i = vs.begin(),
53  vs_end = vs.end(); i != vs_end; ) {
54  s << ' ' << Variable(*i);
55  ++i;
56  if (i != vs_end) {
57  s << ',';
58  }
59  }
60  s << " }";
61  return s;
62 }
63 
64 void
65 PPL::Variables_Set::ascii_dump(std::ostream& s) const {
66  const dimension_type variables_set_size = size();
67  s << "\nvariables( " << variables_set_size << " )\n";
68  for (Variables_Set::const_iterator i = begin(),
69  i_end = end(); i != i_end; ++i) {
70  s << *i << " ";
71  }
72 }
73 
75 
76 bool
77 PPL::Variables_Set::ascii_load(std::istream& s) {
78  clear();
79  std::string str;
80  if (!(s >> str) || str != "variables(") {
81  return false;
82  }
83 
84  dimension_type size;
85 
86  if (!(s >> size)) {
87  return false;
88  }
89 
90  if (!(s >> str) || str != ")") {
91  return false;
92  }
93 
94  for (dimension_type i = 0; i < size; ++i) {
95  dimension_type variable_value;
96  if (!(s >> variable_value)) {
97  return false;
98  }
99  insert(variable_value);
100  }
101  return true;
102 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
An std::set of variables' indexes.
bool OK() const
Checks if all the invariants are satisfied.
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
The standard C++ namespace.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Variable.cc:34
dimension_type id() const
Returns the index of the Cartesian axis associated to the variable.
A dimension of the vector space.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type ascii_load(std::istream &s, T &t)
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
#define PPL_OUTPUT_DEFINITIONS(class_name)
The entire library is confined to this namespace.
Definition: version.hh:61
void insert(Variable v)
Inserts the index of variable v into the set.
Variables_Set()
Builds the empty set of variable indexes.