Commit 0ae76334 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[STYLE] fixed those hpp files I wrote in incorrect style.

parent b753cf6d
......@@ -38,7 +38,7 @@
* Some utilities for string manipulation and output operations. Please note
* that the overloaded ostream output operators aren't in a separate namespace
* but the string manipulation functions. This is because of short use of e.g.
* the <tt><<</tt> operator instead of <tt>string_utils::operator(cout,
* the <tt><<</tt> operator instead of <tt>string_utils::operator( cout,
* myVector)</tt>.
*
* The reason for not using the Boost trimming functions is, that Boost
......@@ -52,7 +52,8 @@
* The reason for not using Boosts Tokenizer is, that this tokenizer, is much
* most simplest to use :).
*/
namespace string_utils {
namespace string_utils
{
/** We consider the following characters as whitespace:
* - <tt>\\r</tt> carriage return
* - <tt>\\n</tt> newline
......@@ -70,7 +71,7 @@ namespace string_utils {
* \return A copy of the trimmed string
*/
std::string rTrim(const std::string& source, const std::string& t = WHITESPACE );
std::string rTrim( const std::string& source, const std::string& t = WHITESPACE );
/**
* Trims any occurence of each character given in parameter t from the
......@@ -91,7 +92,7 @@ namespace string_utils {
* \param t String representing a set containg all trimmable characters
* \return A copy of the trimmed string
*/
std::string trim(const std::string& source, const std::string& t = WHITESPACE );
std::string trim( const std::string& source, const std::string& t = WHITESPACE );
/**
* Transforms all characters in the given string into upper case
......@@ -100,7 +101,7 @@ namespace string_utils {
* \param source String to transpose.
* \return A copy of the upper case only string
*/
std::string toUpper(const std::string& source);
std::string toUpper( const std::string& source );
/**
* Transforms all characters in the given string into lower case
......@@ -109,7 +110,7 @@ namespace string_utils {
* \param source String to transpose.
* \return A copy of the lower case only string
*/
std::string toLower(const std::string& source);
std::string toLower( const std::string& source );
/**
* Splits the given string into a vector of strings (so called tokens).
......@@ -136,12 +137,12 @@ namespace string_utils {
template< class T > std::ostream& operator<<( std::ostream& os, const std::vector< T >& v )
{
std::stringstream result;
result << "[" << std::scientific << std::setprecision(16);
std::copy( v.begin(), v.end(), std::ostream_iterator< T >(result, ", ") );
result << "[" << std::scientific << std::setprecision( 16 );
std::copy( v.begin(), v.end(), std::ostream_iterator< T >( result, ", " ) );
os << rTrim( result.str(), ", " ) << "]";
return os;
}
/**
* Writes every list to an output stream such as cout, if its elements have
* an output operator defined.
......@@ -154,11 +155,10 @@ namespace string_utils {
{
std::stringstream result;
result << "<" << std::scientific;
std::copy( l.begin(), l.end(), std::ostream_iterator< T >(result, ", ") );
std::copy( l.begin(), l.end(), std::ostream_iterator< T >( result, ", " ) );
os << rTrim( result.str(), ", " ) << ">";
return os;
}
} // end of namespace
} // end of namespace
#endif // WSTRINGUTILS_HPP
......@@ -27,6 +27,7 @@
#include <stdint.h>
#include <algorithm>
#include <cassert>
/**
......@@ -39,12 +40,13 @@ namespace wiotools
*/
inline bool isBigEndian()
{
union {
union
{
uint32_t i;
char c[4];
} some = {0x01020304}; // assigning an 32 bit unsigned integer
} some = {0x01020305}; // NOLINT assigning an 32 bit unsigned integer
return some.c[0] == 1;
return some.c[0] == 1;
}
......@@ -56,10 +58,13 @@ namespace wiotools
size_t numBytes = sizeof( T );
T result = value;
if( numBytes == 1 )
{
return result;
}
assert( numBytes % 2 == 0 && numBytes > 0 );
char *s = reinterpret_cast< char* >( &result );
for( size_t i = 0; i < numBytes / 2; ++i ) {
for( size_t i = 0; i < numBytes / 2; ++i )
{
std::swap( s[i], s[ ( numBytes - 1 ) - i ] );
}
return result;
......@@ -71,11 +76,11 @@ namespace wiotools
*/
template< class T > void switchByteOrderOfArray( T *array, const size_t arraySize )
{
for( size_t i = 0; i < arraySize; ++i ) {
for( size_t i = 0; i < arraySize; ++i )
{
array[i] = switchByteOrder< T >( array[i] );
}
}
}
} // end of namespace
#endif // WIOTOOLS_HPP
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment