Belofte
version 2.1.8
A promising chess program using the UCI or Winboard interface
case.cpp
Go to the documentation of this file.
1
/*---------------------------------------------------------------------+
2
* File: case.cpp
3
* Project: part of belofte - A Promising Chess Program
4
* Author: yves
5
* SPDX-License-Identifier: GPL-2.0-only
6
+----------------------------------------------------------------------*/
7
8
#include "
belofte.h
"
9
10
//-----------------------------------------------------------------------
11
// bCase class
12
13
bCase::bCase
()
14
{
15
}
16
17
bCase::bCase
(
case_t
c)
18
{
19
m_case = c;
20
}
21
22
bCase::bCase
(
column_t
const
c,
rank_t
const
r)
23
{
24
if
(c != -1)
25
m_case =
static_cast<
case_t
>
(
bCase::coordToCase
(c, r));
26
else
27
m_case = 0xFF;
28
}
29
30
bCase::bCase
(std::string
const
& bc)
31
{
32
if
(bc.size() > 1) {
33
m_case =
bCase::coordToCase
(bc[0] -
'a'
, bc[1] -
'1'
);
34
}
35
}
36
37
bCase::~bCase
()
38
{
39
}
40
41
bCase
&
bCase::operator=
(std::string
const
& bc)
42
{
43
if
(bc.size() > 1) {
44
m_case =
bCase::coordToCase
(bc[0] -
'a'
, bc[1] -
'1'
);
45
}
46
return
*
this
;
47
}
48
49
bool
bCase::operator==
(
bCase
const
rhs)
const
{
50
return
m_case == rhs.m_case;
51
}
52
53
case_t
bCase::getCaseT
()
const
54
{
55
return
m_case;
56
}
57
58
bCase::operator std::string()
const
59
{
60
if
(m_case == 0xFF)
return
"-"
;
61
return
std::string(1, column0() +
'a'
) + std::string(1, rank0() +
'1'
);
62
}
63
64
std::ostream&
operator<<
(std::ostream& os,
bCase
const
& bc)
65
{
66
os << std::string(bc);
67
return
os;
68
}
69
70
// eof
belofte.h
This is the main include file, needs to be included before any other include.
rank_t
int8_t rank_t
Definition
belofte.h:104
column_t
int8_t column_t
Definition
belofte.h:105
case_t
uint8_t case_t
Definition
belofte.h:106
operator<<
std::ostream & operator<<(std::ostream &os, bCase const &bc)
Definition
case.cpp:64
bCase
position on board, defined as 255 if invalid used primarily to compose a move or a source or destinat...
Definition
case.h:17
bCase::operator=
bCase & operator=(bCase const &)=delete
bCase::operator==
bool operator==(bCase const rhs) const
Definition
case.cpp:49
bCase::getCaseT
case_t getCaseT() const
Definition
case.cpp:53
bCase::bCase
bCase()
Definition
case.cpp:13
bCase::coordToCase
static constexpr case_t coordToCase(column_t const c, rank_t const r)
Definition
case.h:42
bCase::~bCase
~bCase()
Definition
case.cpp:37
src
case.cpp
Generated on 10/10/2024 by
1.9.8