Skip to content

Commit

Permalink
Vis Studio Fixes. Yaml/Bson
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Astari committed Jun 12, 2024
1 parent 53e7675 commit bfffc13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/Serialize/BsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class BsonParser: public ParserInterface

virtual void ignoreDataValue() override;

virtual void getValue(short int& value) override {value = getIntValue<MaxTemplate<4, sizeof(short int)>::value, short int>();}
virtual void getValue(short int& value) override {value = static_cast<int>(getIntValue<MaxTemplate<4, sizeof(short int)>::value, short int>());}
virtual void getValue(int& value) override {value = getIntValue<sizeof(int), int>();}
virtual void getValue(long int& value) override {value = getIntValue<sizeof(long int), long int>();}
virtual void getValue(long long int& value) override {value = getIntValue<sizeof(long long int), long long int>();}
Expand Down Expand Up @@ -194,17 +194,17 @@ inline IEEE_754::_2008::Binary<size * 8> BsonParser::readFloat()
template<std::size_t Size, typename Int>
inline Int BsonParser::getIntValue()
{
if (nextType == '\x10') {ThorsMessage(5, "BsonParser", "getIntValue", "Int-32"); return readInt<4, std::int32_t>();}
if (nextType == '\x12') {ThorsMessage(5, "BsonParser", "getIntValue", "Int-64"); return readInt<8, std::int64_t>();}
if (nextType == '\x10') {ThorsMessage(5, "BsonParser", "getIntValue", "Int-32"); return static_cast<Int>(readInt<4, std::int32_t>());}
if (nextType == '\x12') {ThorsMessage(5, "BsonParser", "getIntValue", "Int-64"); return static_cast<Int>(readInt<8, std::int64_t>());}
badType("Int(32 or 64)", nextType);
}

template<std::size_t Size, typename Float>
inline Float BsonParser::getFloatValue()
{
if (nextType == '\x10') {ThorsMessage(5, "BsonParser", "getFloatValue", "Double-32");return readInt<4, std::int32_t>();}
if (nextType == '\x12') {ThorsMessage(5, "BsonParser", "getFloatValue", "Double-64");return readInt<8, std::int64_t>();}
if (nextType == '\x01') {ThorsMessage(5, "BsonParser", "getFloatValue", "Double-128");return readFloat<8>();}
if (nextType == '\x10') {ThorsMessage(5, "BsonParser", "getFloatValue", "Double-32");return static_cast<Float>(readInt<4, std::int32_t>());}
if (nextType == '\x12') {ThorsMessage(5, "BsonParser", "getFloatValue", "Double-64");return static_cast<Float>(readInt<8, std::int64_t>());}
if (nextType == '\x01') {ThorsMessage(5, "BsonParser", "getFloatValue", "Double-128");return static_cast<Float>(readFloat<8>());}
#if 0
if (nextType == '\x13') {return readFloat<16>();}
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/Serialize/BsonPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void BsonPrinter::writeKey(char value, std::size_t size)
// So when we write a single value we wrap it just like an array.
//
// <4 byte Doc Size> <1 byte Type info> <2 byte Index "0"> <value> <1 byte doc term>
std::int32_t totalSize = 4 + 1 + 2 + size + 1;
std::int32_t totalSize = static_cast<std::int32_t>(4 + 1 + 2 + size + 1);
writeSize<4, std::int32_t>(totalSize);
output.write(&value, 1);
output.write("0", 2);
Expand Down Expand Up @@ -121,7 +121,7 @@ THORS_SERIALIZER_HEADER_ONLY_INCLUDE
void BsonPrinter::openMap(std::size_t size)
{
writeKey('\x03', -1);
writeSize<4, std::int32_t>(size);
writeSize<4, std::int32_t>(static_cast<std::int32_t>(size));
currentContainer.emplace_back(BsonContainer::Map);
}

Expand All @@ -142,7 +142,7 @@ THORS_SERIALIZER_HEADER_ONLY_INCLUDE
void BsonPrinter::openArray(std::size_t size)
{
writeKey('\x04', -1);
writeSize<4, std::int32_t>(size);
writeSize<4, std::int32_t>(static_cast<std::int32_t>(size));
currentContainer.emplace_back(BsonContainer::Array);
arrayIndex.emplace_back(0);
}
Expand Down Expand Up @@ -173,7 +173,7 @@ THORS_SERIALIZER_HEADER_ONLY_INCLUDE
void BsonPrinter::writeString(std::string const& value)
{
writeKey('\x02', 4 + value.size() + 1);
writeSize<4, std::int32_t>(value.size() + 1);
writeSize<4, std::int32_t>(static_cast<std::int32_t>(value.size() + 1));
output << EscapeString(value);
output.write("", 1);
}
Expand All @@ -188,7 +188,7 @@ THORS_SERIALIZER_HEADER_ONLY_INCLUDE
void BsonPrinter::writeBinary(std::string const& value)
{
writeKey('\x05', 4 + 1 + value.size()); // binary
writeSize<4, std::int32_t>(value.size());
writeSize<4, std::int32_t>(static_cast<std::int32_t>(value.size()));
output.write("\x80", 1);
output.write(value.c_str(), value.size());
}
2 changes: 1 addition & 1 deletion src/Serialize/YamlPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void YamlPrinter::emit(T const& data)
NULL,
NULL,
reinterpret_cast<yaml_char_t*>(const_cast<char*>(buffer.str().c_str())),
buffer.str().size(),
static_cast<int>(buffer.str().size()),
1,
0,
YAML_ANY_SCALAR_STYLE);
Expand Down

0 comments on commit bfffc13

Please sign in to comment.