50#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_XY_H
51#define LASS_GUARDIAN_OF_INCLUSION_PRIM_XY_H
65 static constexpr size_t dimension = 2;
69 constexpr XY(): value_(0) {}
90 throw util::Exception(
"Invalid parameter axis. Try 'x', 'X', 'y' or 'Y'.", LASS_PRETTY_FUNCTION);
97 explicit constexpr XY(
int value): value_(value) {}
103 if (
axis.length() != 1)
105 LASS_THROW(
"Invalid parameter axis '" <<
axis <<
"'. It must be a single character.");
110 constexpr XY(
const XY& other) =
default;
111 constexpr XY& operator=(
const XY& other) =
default;
117 LASS_ASSERT(value_ >= 0 && value_ <
static_cast<int>(dimension));
118 constexpr char axes[] = {
'x',
'y' };
122 constexpr operator int()
const {
return value_; }
123 constexpr operator size_t()
const {
return static_cast<size_t>(value_); }
125 constexpr XY& operator++()
130 constexpr XY& operator--()
136 constexpr XY operator++(
int)
138 const XY result(*
this);
142 constexpr XY operator--(
int)
144 const XY result(*
this);
149 constexpr XY& operator+=(
int offset)
154 constexpr XY& operator-=(
int offset)
160 constexpr XY operator+(
int offset)
const
162 return XY(value_ + offset);
164 constexpr XY operator-(
int offset)
const
166 return XY(value_ - offset);
169 constexpr bool operator==(
XY other)
const
171 return value_ == other.value_;
173 constexpr bool operator==(
int other)
const
175 return static_cast<int>(value_) == other;
177 constexpr bool operator==(
size_t other)
const
179 return static_cast<size_t>(value_) == other;
181 constexpr bool operator==(
char other)
const
183 return *
this ==
XY(other);
185 bool operator==(
const std::string& other)
const
187 return *
this ==
XY(other);
190 constexpr bool operator!=(
XY other)
const
192 return value_ != other.value_;
194 constexpr bool operator!=(
int other)
const
196 return static_cast<int>(value_) != other;
198 constexpr bool operator!=(
size_t other)
const
200 return static_cast<size_t>(value_) != other;
202 constexpr bool operator!=(
char other)
const
204 return *
this !=
XY(other);
206 bool operator!=(
const std::string& other)
const
208 return *
this !=
XY(other);
213 typedef num::Modulo<dimension, int> TValue;
220inline constexpr bool operator==(
int a,
const XY& b)
227inline constexpr bool operator==(
size_t a,
const XY& b)
234inline constexpr bool operator==(
char a,
const XY& b)
241inline bool operator==(
const std::string& a,
const XY& b)
248inline constexpr bool operator!=(
int a,
const XY& b)
255inline constexpr bool operator!=(
size_t a,
const XY& b)
262inline constexpr bool operator!=(
char a,
const XY& b)
269inline bool operator!=(
const std::string& a,
const XY& b)
276template <
typename Char,
typename Traits>
277std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& stream,
const XY& xy)
289#define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_XY
290#ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
cyclic iterator over xy indices
XY(const std::string &axis)
initializes iterator to an axis by character: "x" or "y".
constexpr XY(char axis)
initializes iterator to an axis by character: 'x' or 'y'.
constexpr char axis() const
return axis by character: 'x' or 'y'.
constexpr XY(int value)
initializes iterator to an axis by number.
constexpr XY()
intializes iterator to x axis.
type of all exceptions in lass
set of geometrical primitives
Library for Assembled Shared Sources.