Percy++
A C++ implementation of Private Information Retrieval (PIR) protocols
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
percyresult.h
1 // Percy++ Copyright 2007,2012,2013,2014
2 // Ian Goldberg <iang@cs.uwaterloo.ca>,
3 // Casey Devet <cjdevet@uwaterloo.ca>,
4 // Ryan Henry <rhenry@cs.uwaterloo.ca>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of version 2 of the GNU General Public License as
8 // published by the Free Software Foundation.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // There is a copy of the GNU General Public License in the COPYING file
16 // packaged with this plugin; if you cannot find it, write to the Free
17 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 
20 #ifndef __PERCYRESULT_H__
21 #define __PERCYRESULT_H__
22 
23 #include <vector>
24 #include <string>
25 #include <iostream>
26 #include "percytypes.h"
27 
28 using namespace std;
29 
30 struct PercyResult {
31  PercyResult(vector<nservers_t> G, string sigma) : G(G), sigma(sigma) {}
32  vector<nservers_t> G;
33  string sigma;
34 
35  void dump(ostream &out, unsigned int depth = 0) const {
36  string leader(2*depth, ' ');
37  out << leader << "PercyResult {" << endl;
38  out << leader << " G = <";
39  for (vector<nservers_t>::const_iterator i=G.begin(); i != G.end(); ++i) {
40  out << " " << *i;
41  }
42  out << " >" << endl;
43  out << leader << " sigma = \"" << sigma << "\"" << endl;
44  out << leader << "}" << endl;
45  }
46 };
47 
48 inline ostream& operator<<(ostream &out, const PercyResult &r) { r.dump(out); return out; }
49 inline ostream& operator<<(ostream &out, const vector<PercyResult> &r) {
50  out << "<" << endl;
51  for (vector<PercyResult>::const_iterator i=r.begin();
52  i != r.end(); ++i) {
53  i->dump(out,1);
54  }
55  out << ">" << endl;
56  return out;
57 }
58 
59 
61  dbsize_t block_number;
62  vector<PercyResult> results;
63 
64  void dump(ostream &out, unsigned int depth = 0) const {
65  string leader(2*depth, ' ');
66  out << leader << "PercyBlockResults {" << endl;
67  out << leader << " block_number = " << block_number << endl;
68  out << leader << " results = <" << endl;
69  for (vector<PercyResult>::const_iterator i=results.begin();
70  i != results.end(); ++i) {
71  i->dump(out, depth+2);
72  }
73  out << leader << " >" << endl;
74  out << leader << "}" << endl;
75  }
76 };
77 
78 inline ostream& operator<<(ostream &out, const PercyBlockResults &r) { r.dump(out); return out; }
79 inline ostream& operator<<(ostream &out, const vector<PercyBlockResults> &r) {
80  out << "<" << endl;
81  for (vector<PercyBlockResults>::const_iterator i=r.begin();
82  i != r.end(); ++i) {
83  i->dump(out,1);
84  }
85  out << ">" << endl;
86  return out;
87 }
88 
89 #endif
std::ostream & operator<<(std::ostream &os, PercyMode mode)
Prints a PercyMode string to a stream.
Definition: percyresult.h:30
This header contains typedefs for seamless switching between 32- and 64-bit builds of Percy++...
Definition: percyresult.h:60