Skip to content

Commit

Permalink
make pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
voivoid committed Apr 10, 2017
1 parent 2e1fe8a commit 4f5755f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

int main(int argc, char** argv)
{
if(argc != 2)
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " <filename>\n";
return -1;
Expand All @@ -16,13 +16,13 @@ int main(int argc, char** argv)
boost::filesystem::path filePath = argv[1];
assert(!filePath.empty());

if(!boost::filesystem::exists(filePath))
if (!boost::filesystem::exists(filePath))
{
std::cerr << "File " << filePath << " doesn't exist\n";
return -1;
}

if(!boost::filesystem::is_regular_file(filePath))
if (!boost::filesystem::is_regular_file(filePath))
{
std::cerr << "File " << filePath << " is not a regular file\n";
return -1;
Expand All @@ -35,9 +35,7 @@ int main(int argc, char** argv)

Bson::Bytes content;
content.reserve(fileSize);
content.insert(content.begin(),
std::istream_iterator<Bson::Byte>(fstream),
std::istream_iterator<Bson::Byte>());
content.insert(content.begin(), std::istream_iterator<Bson::Byte>(fstream), std::istream_iterator<Bson::Byte>());
assert(content.size() == fileSize);

std::cout << "Content size: " << content.size() << "\n";
Expand Down
14 changes: 7 additions & 7 deletions src/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ T read(Istream& stream)
return value;
}

template <typename T>
typename std::enable_if_t<std::is_pod<T>::value> write(const T value, Ostream& stream)
{
static_assert(std::is_pod<T>::value);
stream.write(reinterpret_cast<const Byte*>(&value), sizeof(value));
}

template <>
String read(Istream& stream)
{
Expand Down Expand Up @@ -175,6 +168,13 @@ Document read(Istream& stream)
return document;
}

template <typename T>
typename std::enable_if_t<std::is_pod<T>::value> write(const T value, Ostream& stream)
{
static_assert(std::is_pod<T>::value);
stream.write(reinterpret_cast<const Byte*>(&value), sizeof(value));
}

void write(const String& string, Ostream& stream)
{
write(static_cast<Int32>(string.length() + 1), stream);
Expand Down

0 comments on commit 4f5755f

Please sign in to comment.