All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
analysesResult.cc
Go to the documentation of this file.
1 /* analysesResult.cc
2  */
4 #include "osl/misc/carray.h"
5 #include <boost/foreach.hpp>
6 
8 {
9  return l.repetition == r.repetition
10  && l.checkmate == r.checkmate
12  && l.threatmate == r.threatmate
19 }
20 
21 std::ostream& osl::annotate::operator<<(std::ostream& os, Trivalent t)
22 {
23  static const CArray<const char*,3> str = {{
24  "False", "Unknown", "True",
25  }};
26  return os << str[t+1];
27 }
28 #define out(os, shared, x) os << #x << " " << shared.x << " "
29 template <class T> void outt(std::ostream& os, const T& a, const char *str)
30 {
31  if (a != T())
32  os << str << " " << a << " ";
33 }
34 #define outif(os, shared, x) outt(os, shared.x, #x)
35 std::ostream& osl::annotate::operator<<(std::ostream& os, const AnalysesResult& shared)
36 {
37  if (! shared.repetition.empty()) {
38  os << "repetition ";
39  BOOST_FOREACH(int p, shared.repetition)
40  os << p << " ";
41  os << " ";
42  }
43  if (shared.checkmate != False)
44  out(os, shared, checkmate);
45  if (shared.threatmate != False)
46  out(os, shared, threatmate);
47  if (shared.escape_from_check != False)
48  out(os, shared, escape_from_check);
49  outif(os, shared, checkmate_move);
50  outif(os, shared, threatmate_move);
51  outif(os, shared, threatmate_probability);
52  outif(os, shared, threatmate_node_count);
53  outif(os, shared, checkmate_for_capture.safe_count);
54  outif(os, shared, checkmate_for_capture.checkmate_count);
55  outif(os, shared, checkmate_for_capture.see_plus_checkmate_count);
56  outif(os, shared, checkmate_for_escape.safe_count);
57  outif(os, shared, checkmate_for_escape.checkmate_count);
58  if (! shared.threatmate_if_more_pieces.hand_ptype.empty())
59  {
60  os << "hand ";
61  BOOST_FOREACH(Ptype ptype, shared.threatmate_if_more_pieces.hand_ptype)
62  os << ptype << " ";
63  os << " ";
64  }
65  if (! shared.threatmate_if_more_pieces.board_ptype.empty())
66  {
67  os << "board ";
68  BOOST_FOREACH(Piece piece, shared.threatmate_if_more_pieces.board_ptype)
69  os << piece << " ";
70  os << " ";
71  }
72  return os;
73 }
74 #undef out
75 
76 // ;;; Local Variables:
77 // ;;; mode:c++
78 // ;;; c-basic-offset:2
79 // ;;; End: