Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <nlohmann/json.hpp>
- #include <string>
- namespace fallow
- {
- namespace video
- {
- class WindowLayout
- {
- public:
- std::pair<int, int> getPosition() const { return windowPos; }
- std::pair<int, int> getSize() const { return windowSize; }
- std::string getTitle() const { return windowTitle; }
- std::uint32_t getFlags() const { return windowFlags; }
- /**
- * @brief Set the Position object
- *
- * @param [in] newPos New window position x and y coordinates. Support only integer values
- */
- void setPosition(const std::pair<int, int>& newPos) { windowPos = newPos; }
- /**
- * @brief Set the Size object
- *
- * @param [in] newSize New window size.
- */
- void setSize(const std::pair<int, int>& newSize) { windowSize = newSize; }
- /**
- * @brief Set the Title object
- *
- * @param [in] newTitle The new window title.
- */
- void setTitle(const std::string& newTitle) { windowTitle = newTitle; }
- /**
- * @brief Set the Flags object for Window
- *
- * @param [in] newFlags This param should contain all flags what you want to set. Example : Fullscreen |
- * Resizable
- */
- void setFlags(std::uint32_t newFlags) { windowFlags = newFlags; }
- void buildLayout(std::pair<int, int> pos = {0, 0},
- std::pair<int, int> size = {1920, 1080},
- const std::string& title = "Engine",
- std::uint32_t flags = {0})
- {
- windowPos = pos;
- windowSize = size;
- windowTitle = std::move(title);
- windowFlags = flags;
- }
- void buildLayout(const std::pair<int, int>& pos,
- const std::pair<int, int>& size,
- const std::string& title,
- std::uint32_t flags)
- {
- windowPos = pos;
- windowSize = size;
- windowTitle = title;
- windowFlags = flags;
- }
- private:
- std::pair<int, int> windowPos; // first - xPosition | second - yPosition
- std::pair<int, int> windowSize; // first - width | second - height
- std::string windowTitle;
- std::uint32_t windowFlags;
- public:
- NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(WindowLayout,
- windowPos,
- windowSize,
- windowTitle,
- windowFlags);
- };
- } // namespace video
- } // namespace fallow
- int main(int, char**)
- {
- std::ofstream stream("C:\\Users\\Sakhil Kuliev\\source\\repos\\Serializator\\log.json");
- // std::ifstream istream("C:\\Users\\Sakhil Kuliev\\source\\repos\\Serializator\\log.json");
- fallow::video::WindowLayout window;
- window.buildLayout();
- nlohmann::json data;
- window.to_json(data, window);
- stream << std::setw(4) << data;
- // nlohmann::json data = nlohmann::json::parse(istream);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement