-/*
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
-*
-* This file is part of CasparCG (www.casparcg.com).
-*
-* CasparCG is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* CasparCG is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
-*
-* Author: Niklas P Andersson, niklas.p.andersson@svt.se
-*/
-
-#pragma once
-
-#include <common/except.h>
-
-#include <string>
-#include <cstdint>
-
-namespace caspar { namespace psd {
-
-template<typename T>
-struct point
-{
- point() : x(0), y(0) {}
- point(T x1, T y1) : x(x1), y(y1) {}
- T x;
- T y;
-
- void clear() { x = 0; y = 0; }
-};
-
-template<typename T>
-struct color
-{
- T red = 0;
- T green = 0;
- T blue = 0;
- T alpha = 0;
-
- std::uint32_t to_uint32()
- {
- return (alpha << 24) + (red << 16) + (green << 8) + blue;
- }
-};
-
-template<typename T>
-struct size
-{
- size() : width(0), height(0) {}
- size(T w, T h) : width(w), height(h) {}
- T width;
- T height;
-
- void clear() { width = 0; height = 0; }
-};
-
-template<typename T>
-struct rect
-{
- point<T> location;
- psd::size<T> size;
-
- bool empty() const { return size.width == 0 || size.height == 0; }
- void clear() { location.clear(); size.clear(); }
-};
-
-struct psd_file_format_exception : virtual caspar_exception {};
-
-enum class channel_type
-{
- total_user_mask = -3,
- user_mask = -2,
- transparency = -1,
- color_red = 0,
- color_green = 1,
- color_blue = 2
-};
-
-enum class layer_type
-{
- content = 0,
- group,
- timeline_group,
- group_delimiter
-};
-layer_type int_to_layer_type(std::uint32_t x, std::uint32_t y);
-std::wstring layer_type_to_string(layer_type b);
-
-enum class blend_mode
-{
- InvalidBlendMode = -1,
- Normal = 'norm',
- Darken = 'dark',
- Lighten = 'lite',
- Hue = 'hue ',
- Saturation = 'sat ',
- Color = 'colr',
- Luminosity = 'lum ',
- Multiply = 'mul ',
- Screen = 'scrn',
- Dissolve = 'diss',
- Overlay = 'over',
- HardLight = 'hLit',
- SoftLight = 'sLit',
- Difference = 'diff',
- Exclusion = 'smud',
- ColorDodge = 'div ',
- ColorBurn = 'idiv'
-};
-
-blend_mode int_to_blend_mode(std::uint32_t x);
-std::wstring blend_mode_to_string(blend_mode b);
-
-enum class color_mode
-{
- InvalidColorMode = -1,
- Bitmap = 0,
- Grayscale = 1,
- Indexed = 2,
- RGB = 3,
- CMYK = 4,
- Multichannel = 7,
- Duotone = 8,
- Lab = 9
-};
-
-color_mode int_to_color_mode(std::uint16_t x);
-std::wstring color_mode_to_string(color_mode c);
-
+/*\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+* Author: Niklas P Andersson, niklas.p.andersson@svt.se\r
+*/\r
+\r
+#pragma once\r
+\r
+#include <common/except.h>\r
+#include <common/enum_class.h>\r
+\r
+#include <string>\r
+#include <cstdint>\r
+\r
+namespace caspar { namespace psd {\r
+ \r
+template<typename T>\r
+struct point\r
+{\r
+ point() : x(0), y(0) {}\r
+ point(T x1, T y1) : x(x1), y(y1) {}\r
+ T x;\r
+ T y;\r
+\r
+ void clear() { x = 0; y = 0; }\r
+};\r
+\r
+template<typename T>\r
+struct color\r
+{\r
+ T red = 0;\r
+ T green = 0;\r
+ T blue = 0;\r
+ T alpha = 0;\r
+\r
+ std::uint32_t to_uint32()\r
+ {\r
+ return (alpha << 24) + (red << 16) + (green << 8) + blue;\r
+ }\r
+};\r
+\r
+template<typename T>\r
+struct size\r
+{\r
+ size() : width(0), height(0) {}\r
+ size(T w, T h) : width(w), height(h) {}\r
+ T width;\r
+ T height;\r
+\r
+ void clear() { width = 0; height = 0; }\r
+};\r
+\r
+template<typename T>\r
+struct rect\r
+{\r
+ point<T> location;\r
+ psd::size<T> size;\r
+\r
+ bool empty() const { return size.width == 0 || size.height == 0; }\r
+ void clear() { location.clear(); size.clear(); }\r
+};\r
+\r
+struct psd_file_format_exception : virtual caspar_exception {};\r
+\r
+enum class channel_type\r
+{\r
+ total_user_mask = -3,\r
+ user_mask = -2,\r
+ transparency = -1,\r
+ color_red = 0,\r
+ color_green = 1,\r
+ color_blue = 2\r
+};\r
+\r
+enum class layer_type\r
+{\r
+ content = 0,\r
+ group,\r
+ timeline_group,\r
+ group_delimiter\r
+};\r
+layer_type int_to_layer_type(std::uint32_t x, std::uint32_t y);\r
+std::wstring layer_type_to_string(layer_type b);\r
+\r
+enum class blend_mode\r
+{\r
+ InvalidBlendMode = -1,\r
+ Normal = 'norm',\r
+ Darken = 'dark',\r
+ Lighten = 'lite',\r
+ Hue = 'hue ',\r
+ Saturation = 'sat ',\r
+ Color = 'colr',\r
+ Luminosity = 'lum ',\r
+ Multiply = 'mul ',\r
+ Screen = 'scrn',\r
+ Dissolve = 'diss',\r
+ Overlay = 'over',\r
+ HardLight = 'hLit',\r
+ SoftLight = 'sLit',\r
+ Difference = 'diff',\r
+ Exclusion = 'smud',\r
+ ColorDodge = 'div ',\r
+ ColorBurn = 'idiv'\r
+};\r
+\r
+blend_mode int_to_blend_mode(std::uint32_t x);\r
+std::wstring blend_mode_to_string(blend_mode b);\r
+\r
+enum class color_mode\r
+{\r
+ InvalidColorMode = -1,\r
+ Bitmap = 0,\r
+ Grayscale = 1,\r
+ Indexed = 2,\r
+ RGB = 3,\r
+ CMYK = 4,\r
+ Multichannel = 7,\r
+ Duotone = 8,\r
+ Lab = 9\r
+};\r
+\r
+color_mode int_to_color_mode(std::uint16_t x);\r
+std::wstring color_mode_to_string(color_mode c);\r
+\r
\r
enum class layer_tag : int {\r
none = 0,\r
rasterized = 16,\r
all = 31\r
};\r
-inline layer_tag operator | (layer_tag lhs, layer_tag rhs)\r
-{\r
- return (layer_tag)(static_cast<int>(lhs) | static_cast<int>(rhs));\r
-}\r
-inline layer_tag operator & (layer_tag lhs, layer_tag rhs)\r
-{\r
- return (layer_tag)(static_cast<int>(lhs) & static_cast<int>(rhs));\r
-}\r
-inline layer_tag operator ^ (layer_tag lhs, layer_tag rhs)\r
-{\r
- return (layer_tag)(static_cast<int>(lhs) ^ static_cast<int>(rhs));\r
-}\r
+ENUM_ENABLE_BITWISE(layer_tag);\r
+\r
inline layer_tag operator ~ (layer_tag rhs)\r
{\r
return (layer_tag)(static_cast<int>(layer_tag::all) ^ static_cast<int>(rhs));\r
}\r
\r
-layer_tag string_to_layer_tags(const std::wstring& str);
-
-} //namespace psd
-} //namespace caspar
-
+layer_tag string_to_layer_tags(const std::wstring& str);\r
+\r
+} //namespace psd\r
+} //namespace caspar\r
+\r