Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
wdeconinck committed Mar 19, 2021
1 parent c61a23f commit bdba64b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
42 changes: 16 additions & 26 deletions src/atlas/io/detail/Base64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,20 @@ namespace {

static std::array<unsigned char, 256> b64_decode_table{
/* ASCII table */
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
};
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64};

static std::array<unsigned char, 256> b64_encode_table{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
};
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};

} // namespace

Expand All @@ -63,7 +53,7 @@ std::string Base64::encode( const void* data, size_t len ) {

std::string str;
str.resize( out_len );
out = reinterpret_cast<unsigned char*>(const_cast<char*>(str.data()));
out = reinterpret_cast<unsigned char*>( const_cast<char*>( str.data() ) );

end = src + len;
in = src;
Expand Down Expand Up @@ -96,9 +86,9 @@ std::string Base64::encode( const void* data, size_t len ) {
std::string Base64::decode( const void* data, size_t len ) {
const auto& table = b64_decode_table;

const unsigned char* p = reinterpret_cast<const unsigned char*>(data);
int pad = len > 0 && ( len % 4 || p[len - 1] == '=' );
const size_t L = ( ( len + 3 ) / 4 - pad ) * 4;
const unsigned char* p = reinterpret_cast<const unsigned char*>( data );
int pad = len > 0 && ( len % 4 || p[len - 1] == '=' );
const size_t L = ( ( len + 3 ) / 4 - pad ) * 4;
std::string str( L / 4 * 3 + pad, '\0' );

for ( size_t i = 0, j = 0; i < L; i += 4 ) {
Expand Down
5 changes: 2 additions & 3 deletions src/atlas/io/types/scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include <cstdint>
#include <string>
#include <bitset>

#include "eckit/utils/ByteSwap.h"

Expand Down Expand Up @@ -69,13 +68,13 @@ void encode_scalar_metadata( const T& value, atlas::io::Metadata& out ) {
inline void encode_scalar_metadata( const unsigned long& value, atlas::io::Metadata& out ) {
out.set( "type", "scalar" );
out.set( "datatype", array::DataType::str<size_t>() );
out.set( "value", size_t(value) );
out.set( "value", size_t( value ) );
}

inline void encode_scalar_metadata( const unsigned long long& value, atlas::io::Metadata& out ) {
out.set( "type", "scalar" );
out.set( "datatype", array::DataType::str<size_t>() );
out.set( "value", size_t(value) );
out.set( "value", size_t( value ) );
}

template <typename T>
Expand Down

0 comments on commit bdba64b

Please sign in to comment.