2023-04-01 09:31:05 +00:00
|
|
|
#include "esm3exteriorcellrefid.hpp"
|
2023-04-03 16:41:25 +00:00
|
|
|
#include "serializerefid.hpp"
|
2023-04-01 09:31:05 +00:00
|
|
|
|
2023-04-07 19:40:44 +00:00
|
|
|
#include <limits>
|
2023-04-01 09:31:05 +00:00
|
|
|
#include <ostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
std::string ESM3ExteriorCellRefId::toString() const
|
|
|
|
{
|
2023-04-19 22:24:49 +00:00
|
|
|
constexpr std::size_t separator = 1;
|
2023-04-03 16:41:25 +00:00
|
|
|
std::string result;
|
2023-04-19 08:19:09 +00:00
|
|
|
result.resize(separator + getDecIntegralCapacity(mX) + separator + getDecIntegralCapacity(mY), '\0');
|
|
|
|
result[0] = '#';
|
|
|
|
const std::size_t endX = serializeDecIntegral(mX, separator, result);
|
|
|
|
result[endX] = ' ';
|
2023-04-19 22:24:49 +00:00
|
|
|
const std::size_t endY = serializeDecIntegral(mY, endX + separator, result);
|
2023-04-07 19:40:44 +00:00
|
|
|
result.resize(endY);
|
2023-04-03 16:41:25 +00:00
|
|
|
return result;
|
2023-04-01 09:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ESM3ExteriorCellRefId::toDebugString() const
|
|
|
|
{
|
2023-04-19 22:24:49 +00:00
|
|
|
constexpr std::size_t separator = 1;
|
2023-04-03 16:41:25 +00:00
|
|
|
std::string result;
|
2023-04-07 19:40:44 +00:00
|
|
|
serializeRefIdPrefix(
|
2023-04-19 22:24:49 +00:00
|
|
|
getDecIntegralCapacity(mX) + separator + getDecIntegralCapacity(mY), esm3ExteriorCellRefIdPrefix, result);
|
2023-04-07 19:40:44 +00:00
|
|
|
const std::size_t endX = serializeDecIntegral(mX, esm3ExteriorCellRefIdPrefix.size(), result);
|
|
|
|
result[endX] = ':';
|
2023-04-19 22:24:49 +00:00
|
|
|
const std::size_t endY = serializeDecIntegral(mY, endX + separator, result);
|
2023-04-07 19:40:44 +00:00
|
|
|
result.resize(endY);
|
2023-04-03 16:41:25 +00:00
|
|
|
return result;
|
2023-04-01 09:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value)
|
|
|
|
{
|
2023-04-07 19:40:44 +00:00
|
|
|
return stream << value.toDebugString();
|
2023-04-01 09:31:05 +00:00
|
|
|
}
|
|
|
|
}
|