00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <ppl-config.h>
00025 #include "Variables_Set.defs.hh"
00026 #include <iostream>
00027
00028 namespace PPL = Parma_Polyhedra_Library;
00029
00030 PPL::Variables_Set::Variables_Set(const Variable& v, const Variable& w)
00031 : Base() {
00032 for (dimension_type d = v.id(), last = w.id(); d <= last; ++d)
00033 insert(d);
00034 }
00035
00036 bool
00037 PPL::Variables_Set::OK() const {
00038 for (const_iterator i = begin(), set_end = end(); i != set_end; ++i)
00039 if (!Variable(*i).OK())
00040 return false;
00041 return true;
00042 }
00043
00045 std::ostream&
00046 PPL::IO_Operators::operator<<(std::ostream& s, const Variables_Set& vs) {
00047 s << '{';
00048 for (Variables_Set::const_iterator i = vs.begin(),
00049 vs_end = vs.end(); i != vs_end; ) {
00050 s << ' ' << Variable(*i++);
00051 if (i != vs_end)
00052 s << ',';
00053 }
00054 s << " }";
00055 return s;
00056 }
00057
00058 void
00059 PPL::Variables_Set::ascii_dump(std::ostream& s) const {
00060 dimension_type variables_set_size = size();
00061 s << "\nvariables( " << variables_set_size << " )\n";
00062 for (Variables_Set::const_iterator i = begin(),
00063 i_end = end(); i != i_end; ++i)
00064 s << *i << " ";
00065 }
00066
00067 PPL_OUTPUT_DEFINITIONS(Variables_Set)
00068
00069 bool
00070 PPL::Variables_Set::ascii_load(std::istream& s) {
00071 clear();
00072 std::string str;
00073 if (!(s >> str) || str != "variables(")
00074 return false;
00075
00076 dimension_type size;
00077
00078 if (!(s >> size))
00079 return false;
00080
00081 if (!(s >> str) || str != ")")
00082 return false;
00083
00084 dimension_type variable_value;
00085 for (dimension_type i = 0; i < size; ++i) {
00086 if (!(s >> variable_value))
00087 return false;
00088 insert(variable_value);
00089 }
00090 return true;
00091 }