diff --git a/src/database-options.hpp b/src/database-options.hpp index ed12e44c..0f609004 100644 --- a/src/database-options.hpp +++ b/src/database-options.hpp @@ -4,12 +4,12 @@ #include "decimal.hpp" LOST_CLI_OPTION("min-mag" , decimal , minMag , 100 , STR_TO_DECIMAL(optarg) , kNoDefaultArgument) -LOST_CLI_OPTION("max-stars" , int , maxStars , 10000 , atoi(optarg) , kNoDefaultArgument) +LOST_CLI_OPTION("max-stars" , int , maxStars , 10000 , atoi(optarg) , kNoDefaultArgument) LOST_CLI_OPTION("min-separation" , decimal , minSeparation , 0.08 , STR_TO_DECIMAL(optarg) , kNoDefaultArgument) -LOST_CLI_OPTION("kvector" , bool , kvector , false , atobool(optarg), true) +LOST_CLI_OPTION("kvector" , bool , kvector , false , atobool(optarg), true) LOST_CLI_OPTION("kvector-min-distance" , decimal , kvectorMinDistance , 0.5 , STR_TO_DECIMAL(optarg) , kNoDefaultArgument) LOST_CLI_OPTION("kvector-max-distance" , decimal , kvectorMaxDistance , 15 , STR_TO_DECIMAL(optarg) , kNoDefaultArgument) -LOST_CLI_OPTION("kvector-distance-bins" , long , kvectorNumDistanceBins, 10000 , atol(optarg) , kNoDefaultArgument) -LOST_CLI_OPTION("swap-integer-endianness", bool , swapIntegerEndianness , false , atobool(optarg), true) -LOST_CLI_OPTION("swap-float-endianness" , bool , swapFloatEndianness , false , atobool(optarg), true) -LOST_CLI_OPTION("output" , std::string, outputPath , "-" , optarg , kNoDefaultArgument) +LOST_CLI_OPTION("kvector-distance-bins" , long , kvectorNumDistanceBins , 10000 , atol(optarg) , kNoDefaultArgument) +LOST_CLI_OPTION("swap-integer-endianness", bool , swapIntegerEndianness , false , atobool(optarg), true) +LOST_CLI_OPTION("swap-decimal-endianness", bool , swapDecimalEndianness , false , atobool(optarg), true) +LOST_CLI_OPTION("output" , std::string, outputPath , "-" , optarg , kNoDefaultArgument) diff --git a/src/io.cpp b/src/io.cpp index 017687c6..7eba293b 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -267,7 +267,7 @@ typedef StarIdAlgorithm *(*StarIdAlgorithmFactory)(); typedef AttitudeEstimationAlgorithm *(*AttitudeEstimationAlgorithmFactory)(); SerializeContext serFromDbValues(const DatabaseOptions &values) { - return SerializeContext(values.swapIntegerEndianness, values.swapFloatEndianness); + return SerializeContext(values.swapIntegerEndianness, values.swapDecimalEndianness); } MultiDatabaseDescriptor GenerateDatabases(const Catalog &catalog, const DatabaseOptions &values) { diff --git a/src/serialize-helpers.hpp b/src/serialize-helpers.hpp index 13a0a3fb..2e57fb87 100644 --- a/src/serialize-helpers.hpp +++ b/src/serialize-helpers.hpp @@ -1,7 +1,7 @@ /** * Helpers to serialize and deserialize arbitrary data types to disk * - * The serialization and deserialization helpers here assume that (a) integers and floating point + * The serialization and deserialization helpers here assume that (a) integers and decimal point * numbers are stored in the same format on the source and target systems except for endianness, and * (b) the target system requires no greater than n-byte alignment for n-byte values (eg, an int32_t * only needs 4-byte alignment, not 8-byte), and (c) the database itself will be aligned at a @@ -23,16 +23,18 @@ #include #include +#include "decimal.hpp" + namespace lost { class SerializeContext { public: - SerializeContext(bool swapIntegerEndianness, bool swapFloatEndianness) - : swapIntegerEndianness(swapIntegerEndianness), swapFloatEndianness(swapFloatEndianness) { } + SerializeContext(bool swapIntegerEndianness, bool swapDecimalEndianness) + : swapIntegerEndianness(swapIntegerEndianness), swapDecimalEndianness(swapDecimalEndianness) { } SerializeContext() : SerializeContext(false, false) { } bool swapIntegerEndianness; - bool swapFloatEndianness; + bool swapDecimalEndianness; std::vector buffer; }; @@ -66,8 +68,8 @@ void SwapEndianness(unsigned char *buffer) { } /// Swap the endianness of a value if necessary. Uses -/// LOST_DATABASE_{SOURCE,TARGET}_INTEGER_ENDIANNESS to determine to switch all values but float and -/// double, which use LOST_DATABASE_{SOURCE,TARGET}_FLOAT_ENDIANNESS. +/// LOST_DATABASE_{SOURCE,TARGET}_INTEGER_ENDIANNESS to determine to switch all values but decimal +/// which uses LOST_DATABASE_{SOURCE,TARGET}_DECIMAL_ENDIANNESS. template void SwapEndiannessIfNecessary(unsigned char *buffer, SerializeContext *ser) { if (ser->swapIntegerEndianness) { @@ -78,16 +80,9 @@ void SwapEndiannessIfNecessary(unsigned char *buffer, SerializeContext *ser) { // template specializations template <> -inline void SwapEndiannessIfNecessary(unsigned char *buffer, SerializeContext *ser) { - if (ser->swapFloatEndianness) { - SwapEndianness(buffer); - } -} - -template <> -inline void SwapEndiannessIfNecessary(unsigned char *buffer, SerializeContext *ser) { - if (ser->swapFloatEndianness) { - SwapEndianness(buffer); +inline void SwapEndiannessIfNecessary(unsigned char *buffer, SerializeContext *ser) { + if (ser->swapDecimalEndianness) { + SwapEndianness(buffer); } }