Commit 1bad3b18 authored by Hansruedi Patzen's avatar Hansruedi Patzen
Browse files

connectfour: merge cleanup

parent ca0c4d35
......@@ -321,9 +321,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SFML/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ConnectFourGui/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;C:\Program Files\MinGW\include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/w10_solution_03_ConnectFour/include}&quot;"/>
</option>
......@@ -357,9 +355,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SFML/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ConnectFourGui/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;C:\Program Files\MinGW\include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/w10_solution_03_ConnectFour/include}&quot;"/>
</option>
......@@ -421,9 +417,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SFML/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ConnectFourGui/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;C:\Program Files\MinGW\include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/w10_solution_03_ConnectFour/include}&quot;"/>
</option>
......
#ifndef GAMECOMMAND_HPP_
#define GAMECOMMAND_HPP_
#include "Board.h"
#include "asio/buffer.hpp"
#include <array>
#include <charconv>
#include <cmath>
#include <limits>
#include <iterator>
struct GameCommand {
constexpr static int dataSize { static_cast<int>(std::log10(std::numeric_limits<Column::value_type>::max())) + 2 };
using dataType = std::array<char, dataSize>;
GameCommand() = default;
explicit GameCommand(Column column) :
data { } {
std::to_chars(std::begin(data), std::end(data), column.value);
}
Column decode() const {
int value { };
std::from_chars(std::begin(data), std::end(data), value);
return Column { value };
}
auto asBuffer() {
return asio::buffer(data.begin(), dataSize);
}
private:
dataType data { };
};
#endif /* GAMECOMMAND_HPP_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment