CASM
1.1.0
A Clusters Approach to Statistical Mechanics
FormatFlag.hh
Go to the documentation of this file.
1
#ifndef FORMATFLAG_HH
2
#define FORMATFLAG_HH
3
4
#include <iostream>
5
6
namespace
CASM
{
7
8
class
FormatFlag
{
9
public
:
10
enum
Value
{
11
cart
= 0,
12
va_off
= 0,
13
header_on
= 0,
14
frac
= (1u << 0),
15
va_on
= (1u << 1),
16
header_off
= (1u << 2)
17
// add up to (1u << 7)
18
};
19
20
FormatFlag
(
int
_value) :
m_value
(_value) {}
21
22
FormatFlag
(std::ostream &_stream) :
m_value
(_stream.iword(
iword_index
())) {}
23
24
int
value
()
const
{
return
m_value
; }
25
26
std::ostream &
set
(std::ostream &_stream)
const
{
27
_stream.iword(
iword_index
()) =
value
();
28
return
_stream;
29
}
30
31
bool
print_header
()
const
{
return
!bool(
m_value
&
header_off
); }
32
33
FormatFlag
&
print_header
(
bool
_set) {
34
if
(_set)
35
m_value
&= ~
header_off
;
36
else
37
m_value
|=
header_off
;
38
return
*
this
;
39
}
40
41
bool
print_va
()
const
{
return
bool(
m_value
&
va_on
); }
42
43
FormatFlag
operator|
(
int
RHS) {
44
FormatFlag
tflag(*
this
);
45
return
tflag |= RHS;
46
}
47
48
FormatFlag
operator^
(
int
RHS) {
49
FormatFlag
tflag(*
this
);
50
return
tflag ^= RHS;
51
}
52
53
FormatFlag
operator&
(
int
RHS) {
54
FormatFlag
tflag(*
this
);
55
return
tflag &= RHS;
56
}
57
58
FormatFlag
&
operator|=
(
int
RHS) {
59
m_value
|= RHS;
60
return
*
this
;
61
}
62
63
FormatFlag
&
operator^=
(
int
RHS) {
64
m_value
^= RHS;
65
return
*
this
;
66
}
67
68
FormatFlag
&
operator&=
(
int
RHS) {
69
m_value
&= RHS;
70
return
*
this
;
71
}
72
73
private
:
74
static
int
iword_index
();
75
int
m_value
;
76
};
77
78
std::ostream &
operator<<
(std::ostream &_stream,
const
FormatFlag
&flag);
79
80
}
// namespace CASM
81
#endif
CASM::FormatFlag
Definition:
FormatFlag.hh:8
CASM::FormatFlag::operator&
FormatFlag operator&(int RHS)
Definition:
FormatFlag.hh:53
CASM::FormatFlag::operator|=
FormatFlag & operator|=(int RHS)
Definition:
FormatFlag.hh:58
CASM::FormatFlag::FormatFlag
FormatFlag(int _value)
Definition:
FormatFlag.hh:20
CASM::FormatFlag::Value
Value
Definition:
FormatFlag.hh:10
CASM::FormatFlag::va_on
@ va_on
Definition:
FormatFlag.hh:15
CASM::FormatFlag::header_off
@ header_off
Definition:
FormatFlag.hh:16
CASM::FormatFlag::va_off
@ va_off
Definition:
FormatFlag.hh:12
CASM::FormatFlag::cart
@ cart
Definition:
FormatFlag.hh:11
CASM::FormatFlag::frac
@ frac
Definition:
FormatFlag.hh:14
CASM::FormatFlag::header_on
@ header_on
Definition:
FormatFlag.hh:13
CASM::FormatFlag::operator|
FormatFlag operator|(int RHS)
Definition:
FormatFlag.hh:43
CASM::FormatFlag::value
int value() const
Definition:
FormatFlag.hh:24
CASM::FormatFlag::print_header
bool print_header() const
Definition:
FormatFlag.hh:31
CASM::FormatFlag::print_header
FormatFlag & print_header(bool _set)
Definition:
FormatFlag.hh:33
CASM::FormatFlag::operator^
FormatFlag operator^(int RHS)
Definition:
FormatFlag.hh:48
CASM::FormatFlag::FormatFlag
FormatFlag(std::ostream &_stream)
Definition:
FormatFlag.hh:22
CASM::FormatFlag::operator^=
FormatFlag & operator^=(int RHS)
Definition:
FormatFlag.hh:63
CASM::FormatFlag::m_value
int m_value
Definition:
FormatFlag.hh:75
CASM::FormatFlag::set
std::ostream & set(std::ostream &_stream) const
Definition:
FormatFlag.hh:26
CASM::FormatFlag::print_va
bool print_va() const
Definition:
FormatFlag.hh:41
CASM::FormatFlag::operator&=
FormatFlag & operator&=(int RHS)
Definition:
FormatFlag.hh:68
CASM::FormatFlag::iword_index
static int iword_index()
Definition:
FormatFlag.cc:4
CASM
Main CASM namespace.
Definition:
APICommand.hh:8
CASM::operator<<
std::ostream & operator<<(std::ostream &_stream, const FormattedPrintable &_formatted)
Definition:
DataFormatter.hh:747
include
casm
casm_io
FormatFlag.hh
Generated on Tue Mar 23 2021 14:16:36 for CASM by
1.9.1