dml: Fix build errors from Travis

This commit is contained in:
Joshua Scott 2018-03-30 19:29:12 +01:00
parent 977ea2310e
commit 2e17370337
9 changed files with 49 additions and 20 deletions

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,8 +9,10 @@ namespace dml
template <> template <>
void DblField::write_to(std::ostream &ostream) const void DblField::write_to(std::ostream &ostream) const
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
ValueBytes<DBL> data = { m_value }; endianness_check.value = 0x0102;
ValueBytes<DBL> data;
data.value = m_value;
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)
std::reverse(&data.buff[0], &data.buff[7]); std::reverse(&data.buff[0], &data.buff[7]);
ostream.write(data.buff, sizeof(DBL)); ostream.write(data.buff, sizeof(DBL));
@ -18,7 +21,8 @@ namespace dml
template <> template <>
void DblField::read_from(std::istream &istream) void DblField::read_from(std::istream &istream)
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<DBL> data; ValueBytes<DBL> data;
istream.read(data.buff, sizeof(DBL)); istream.read(data.buff, sizeof(DBL));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,8 +9,10 @@ namespace dml
template <> template <>
void FltField::write_to(std::ostream &ostream) const void FltField::write_to(std::ostream &ostream) const
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
ValueBytes<FLT> data = { m_value }; endianness_check.value = 0x0102;
ValueBytes<FLT> data;
data.value = m_value;
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)
std::reverse(&data.buff[0], &data.buff[3]); std::reverse(&data.buff[0], &data.buff[3]);
ostream.write(data.buff, sizeof(FLT)); ostream.write(data.buff, sizeof(FLT));
@ -18,7 +21,8 @@ namespace dml
template <> template <>
void FltField::read_from(std::istream &istream) void FltField::read_from(std::istream &istream)
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<FLT> data; ValueBytes<FLT> data;
istream.read(data.buff, sizeof(FLT)); istream.read(data.buff, sizeof(FLT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void GidField::write_to(std::ostream &ostream) const void GidField::write_to(std::ostream &ostream) const
{ {
ValueBytes<GID> data = { m_value }; ValueBytes<GID> data;
data.value = m_value;
if (data.buff[0] == ((m_value & 0xFF00000000000000) >> 56)) if (data.buff[0] == ((m_value & 0xFF00000000000000) >> 56))
std::reverse(&data.buff[0], &data.buff[7]); std::reverse(&data.buff[0], &data.buff[7]);
ostream.write(data.buff, sizeof(GID)); ostream.write(data.buff, sizeof(GID));
@ -17,7 +19,8 @@ namespace dml
template <> template <>
void GidField::read_from(std::istream &istream) void GidField::read_from(std::istream &istream)
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<GID> data; ValueBytes<GID> data;
istream.read(data.buff, sizeof(GID)); istream.read(data.buff, sizeof(GID));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void IntField::write_to(std::ostream &ostream) const void IntField::write_to(std::ostream &ostream) const
{ {
ValueBytes<INT> data = { m_value }; ValueBytes<INT> data;
data.value = m_value;
if (data.buff[0] == ((m_value & 0xFF000000) >> 24)) if (data.buff[0] == ((m_value & 0xFF000000) >> 24))
std::reverse(&data.buff[0], &data.buff[3]); std::reverse(&data.buff[0], &data.buff[3]);
ostream.write(data.buff, sizeof(INT)); ostream.write(data.buff, sizeof(INT));
@ -17,7 +19,8 @@ namespace dml
template <> template <>
void IntField::read_from(std::istream &istream) void IntField::read_from(std::istream &istream)
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<INT> data; ValueBytes<INT> data;
istream.read(data.buff, sizeof(INT)); istream.read(data.buff, sizeof(INT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void ShrtField::write_to(std::ostream &ostream) const void ShrtField::write_to(std::ostream &ostream) const
{ {
ValueBytes<SHRT> data = { m_value }; ValueBytes<SHRT> data;
data.value = m_value;
if (data.buff[0] == ((m_value & 0xFF00) >> 8)) if (data.buff[0] == ((m_value & 0xFF00) >> 8))
std::reverse(&data.buff[0], &data.buff[1]); std::reverse(&data.buff[0], &data.buff[1]);
ostream.write(data.buff, sizeof(SHRT)); ostream.write(data.buff, sizeof(SHRT));
@ -17,7 +19,8 @@ namespace dml
template <> template <>
void ShrtField::read_from(std::istream &istream) void ShrtField::read_from(std::istream &istream)
{ {
const ValueBytes<SHRT> endianness_check = { 0x0102 }; ValueBytes<SHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<SHRT> data; ValueBytes<SHRT> data;
istream.read(data.buff, sizeof(SHRT)); istream.read(data.buff, sizeof(SHRT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void StrField::write_to(std::ostream &ostream) const void StrField::write_to(std::ostream &ostream) const
{ {
ValueBytes<USHRT> data = { m_value.length() }; ValueBytes<USHRT> data;
data.value = m_value.length();
if (data.buff[0] == ((m_value.length() & 0xFF00) >> 8)) if (data.buff[0] == ((m_value.length() & 0xFF00) >> 8))
std::reverse(&data.buff[0], &data.buff[1]); std::reverse(&data.buff[0], &data.buff[1]);
ostream.write(data.buff, sizeof(USHRT)); ostream.write(data.buff, sizeof(USHRT));
@ -19,7 +21,8 @@ namespace dml
void StrField::read_from(std::istream &istream) void StrField::read_from(std::istream &istream)
{ {
// Get the length // Get the length
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<USHRT> length_data; ValueBytes<USHRT> length_data;
istream.read(length_data.buff, sizeof(USHRT)); istream.read(length_data.buff, sizeof(USHRT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void UIntField::write_to(std::ostream &ostream) const void UIntField::write_to(std::ostream &ostream) const
{ {
ValueBytes<UINT> data = { m_value }; ValueBytes<UINT> data;
data.value = m_value;
if (data.buff[0] == ((m_value & 0xFF000000) >> 24)) if (data.buff[0] == ((m_value & 0xFF000000) >> 24))
std::reverse(&data.buff[0], &data.buff[3]); std::reverse(&data.buff[0], &data.buff[3]);
ostream.write(data.buff, sizeof(UINT)); ostream.write(data.buff, sizeof(UINT));
@ -17,7 +19,8 @@ namespace dml
template <> template <>
void UIntField::read_from(std::istream &istream) void UIntField::read_from(std::istream &istream)
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<UINT> data; ValueBytes<UINT> data;
istream.read(data.buff, sizeof(UINT)); istream.read(data.buff, sizeof(UINT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void UShrtField::write_to(std::ostream &ostream) const void UShrtField::write_to(std::ostream &ostream) const
{ {
ValueBytes<USHRT> data = { m_value }; ValueBytes<USHRT> data;
data.value = m_value;
if (data.buff[0] == ((m_value & 0xFF00) >> 8)) if (data.buff[0] == ((m_value & 0xFF00) >> 8))
std::reverse(&data.buff[0], &data.buff[1]); std::reverse(&data.buff[0], &data.buff[1]);
ostream.write(data.buff, sizeof(USHRT)); ostream.write(data.buff, sizeof(USHRT));
@ -17,7 +19,8 @@ namespace dml
template <> template <>
void UShrtField::read_from(std::istream &istream) void UShrtField::read_from(std::istream &istream)
{ {
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<USHRT> data; ValueBytes<USHRT> data;
istream.read(data.buff, sizeof(USHRT)); istream.read(data.buff, sizeof(USHRT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)

View File

@ -1,5 +1,6 @@
#include "ki/dml/Field.h" #include "ki/dml/Field.h"
#include "ki/util/ValueBytes.h" #include "ki/util/ValueBytes.h"
#include <algorithm>
namespace ki namespace ki
{ {
@ -8,7 +9,8 @@ namespace dml
template <> template <>
void WStrField::write_to(std::ostream &ostream) const void WStrField::write_to(std::ostream &ostream) const
{ {
ValueBytes<USHRT> data = { m_value.length() }; ValueBytes<USHRT> data;
data.value = m_value.length();
if (data.buff[0] == ((m_value.length() & 0xFF00) >> 8)) if (data.buff[0] == ((m_value.length() & 0xFF00) >> 8))
std::reverse(&data.buff[0], &data.buff[1]); std::reverse(&data.buff[0], &data.buff[1]);
ostream.write(data.buff, sizeof(USHRT)); ostream.write(data.buff, sizeof(USHRT));
@ -19,7 +21,8 @@ namespace dml
void WStrField::read_from(std::istream &istream) void WStrField::read_from(std::istream &istream)
{ {
// Get the length // Get the length
const ValueBytes<USHRT> endianness_check = { 0x0102 }; ValueBytes<USHRT> endianness_check;
endianness_check.value = 0x0102;
ValueBytes<USHRT> length_data; ValueBytes<USHRT> length_data;
istream.read(length_data.buff, sizeof(USHRT)); istream.read(length_data.buff, sizeof(USHRT));
if (endianness_check.buff[0] == 0x01) if (endianness_check.buff[0] == 0x01)