File: Holding.h

package info (click to toggle)
deal 3.1.9-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,552 kB
  • sloc: ansic: 5,224; cpp: 4,186; tcl: 3,125; makefile: 200; sh: 10
file content (37 lines) | stat: -rw-r--r-- 731 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef __DDS_HOLDING_H__
#define __DDS_HOLDING_H__
#include "ddsInterface.h"

/*
 * This is just a utility class so you can say:
 *      cout << Holding(h) << endl;
 * when h is of type holding_t.
 */
struct Holding {
  holding_t _h;
  inline Holding(holding_t h) : _h(h) { }
  inline operator holding_t() const {
    return _h;
  }

};


inline ostream& operator <<(ostream &out,const Holding &holding) {
  static const char *cards="AKQJT98765432";
  int index=0;
  holding_t h = holding._h;

  if (h&8191) {
    for (holding_t card=1<<12; card; card >>= 1, index++) {
      if (h & card) {
        out << cards[index];
      }
    }
  } else {
      out << "void";
  }
  out << " (" << holding._h << ")";
  return out;
}
#endif