From 35010b4938a3425ad56f97e1eae3834cb99d7326 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 1 Sep 2008 16:03:01 +0200 Subject: [PATCH 1/1] Preserve options order when printed Use a vector instead of a map so that options are printed according to their original order. Signed-off-by: Marco Costalba --- src/ucioption.cpp | 227 +++++++++++++++++++++++++--------------------- 1 file changed, 122 insertions(+), 105 deletions(-) diff --git a/src/ucioption.cpp b/src/ucioption.cpp index d700e6d1..37c0d40f 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -22,7 +22,6 @@ //// #include -#include #include #include #include @@ -53,23 +52,22 @@ namespace { typedef std::vector ComboValues; - struct OptionValue + struct Option { - std::string defaultValue, currentValue; + std::string name, defaultValue, currentValue; OptionType type; int minValue, maxValue; ComboValues comboValues; - // Helper to convert a bool or an int in a std::string + // Helper to convert a bool or an int to a std::string template std::string stringify(const T& v); - OptionValue(); // this is needed to use a std::map - OptionValue(const char* defaultValue, OptionType = STRING); - OptionValue(bool defaultValue); - OptionValue(int defaultValue, int minValue, int maxValue); + Option(const char* name, const char* defaultValue, OptionType = STRING); + Option(const char* name, bool defaultValue); + Option(const char* name, int defaultValue, int minValue, int maxValue); }; - typedef std::map Options; + typedef std::vector