lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5294] Rearrange; improve layout


From: Greg Chicares
Subject: [lmi-commits] [5294] Rearrange; improve layout
Date: Sat, 08 Oct 2011 10:02:28 +0000

Revision: 5294
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5294
Author:   chicares
Date:     2011-10-08 10:02:27 +0000 (Sat, 08 Oct 2011)
Log Message:
-----------
Rearrange; improve layout

Modified Paths:
--------------
    lmi/trunk/ce_product_name.cpp
    lmi/trunk/ce_product_name.hpp
    lmi/trunk/mc_enum.hpp
    lmi/trunk/mc_enum.tpp
    lmi/trunk/tn_range.tpp

Modified: lmi/trunk/ce_product_name.cpp
===================================================================
--- lmi/trunk/ce_product_name.cpp       2011-10-02 09:58:24 UTC (rev 5293)
+++ lmi/trunk/ce_product_name.cpp       2011-10-08 10:02:27 UTC (rev 5294)
@@ -55,16 +55,6 @@
     return s == str();
 }
 
-std::size_t ce_product_name::cardinality() const
-{
-    return product_names().size();
-}
-
-std::size_t ce_product_name::ordinal() const
-{
-    return ordinal(value_);
-}
-
 std::size_t ce_product_name::ordinal(std::string const& s)
 {
     std::size_t v =
@@ -89,6 +79,21 @@
     return v;
 }
 
+std::size_t ce_product_name::cardinality() const
+{
+    return product_names().size();
+}
+
+/// No product is ever proscribed.
+
+void ce_product_name::enforce_proscription()
+{}
+
+std::size_t ce_product_name::ordinal() const
+{
+    return ordinal(value_);
+}
+
 std::string ce_product_name::str(int j) const
 {
     return product_names()[j];
@@ -124,8 +129,3 @@
     return os << str();
 }
 
-/// No product is ever proscribed.
-
-void ce_product_name::enforce_proscription()
-{}
-

Modified: lmi/trunk/ce_product_name.hpp
===================================================================
--- lmi/trunk/ce_product_name.hpp       2011-10-02 09:58:24 UTC (rev 5293)
+++ lmi/trunk/ce_product_name.hpp       2011-10-08 10:02:27 UTC (rev 5294)
@@ -83,6 +83,7 @@
 
     // mc_enum_base required implementation.
     virtual std::size_t cardinality() const;
+    virtual void enforce_proscription();
     virtual std::size_t ordinal() const;
     virtual std::string str(int) const;
 
@@ -97,9 +98,6 @@
     virtual std::istream& read (std::istream&);
     virtual std::ostream& write(std::ostream&) const;
 
-    // mc_enum_base required implementation.
-    virtual void enforce_proscription();
-
     std::string value_;
 };
 

Modified: lmi/trunk/mc_enum.hpp
===================================================================
--- lmi/trunk/mc_enum.hpp       2011-10-02 09:58:24 UTC (rev 5293)
+++ lmi/trunk/mc_enum.hpp       2011-10-08 10:02:27 UTC (rev 5294)
@@ -119,17 +119,17 @@
     bool operator==(std::string const&) const;
 
     static std::size_t ordinal(std::string const&);
+    static std::vector<std::string> const& all_strings();
 
     // mc_enum_base required implementation.
     virtual std::size_t cardinality() const;
+    virtual void enforce_proscription();
     virtual std::size_t ordinal() const;
     virtual std::string str(int) const;
 
     std::string str() const;
     T value() const;
 
-    static std::vector<std::string> const& all_strings();
-
   private:
     static std::size_t        n();
     static T    const*        e();
@@ -140,9 +140,6 @@
     virtual std::istream& read (std::istream&);
     virtual std::ostream& write(std::ostream&) const;
 
-    // mc_enum_base required implementation.
-    virtual void enforce_proscription();
-
     T value_;
 };
 

Modified: lmi/trunk/mc_enum.tpp
===================================================================
--- lmi/trunk/mc_enum.tpp       2011-10-02 09:58:24 UTC (rev 5293)
+++ lmi/trunk/mc_enum.tpp       2011-10-08 10:02:27 UTC (rev 5294)
@@ -31,18 +31,6 @@
 #include <algorithm> // std::find()
 #include <typeinfo>
 
-// TODO ?? Should there be a runtime check that all elements in
-// e() and in c() are unique? Can that be asserted at compile time?
-
-template<typename T>
-std::size_t        mc_enum<T>::n() {return mc_enum_key<T>::n_;}
-
-template<typename T>
-T    const*        mc_enum<T>::e() {return mc_enum_key<T>::e();}
-
-template<typename T>
-char const* const* mc_enum<T>::c() {return mc_enum_key<T>::c();}
-
 /// The header that defines class mc_enum is by design unaware of its
 /// associated metadata, so static assertions that depend on metadata
 /// are written here.
@@ -100,58 +88,29 @@
     return s == str();
 }
 
-namespace
-{
-/// A whilom version of a vetust class substituted underbars for
-/// spaces, for reasons that, well, seemed good at the time.
-
-std::string provide_for_backward_compatibility(std::string const& s)
-{
-    static std::string const underbar("_");
-    std::string r(s);
-    for(;;)
-        {
-        std::string::size_type xpos = r.find_first_of(underbar);
-        if(std::string::npos == xpos)
-            {
-            break;
-            }
-        else
-            {
-            r[xpos] = ' ';
-            }
-        }
-    return r;
-}
-} // Unnamed namespace.
-
 template<typename T>
-std::istream& mc_enum<T>::read(std::istream& is)
+std::size_t mc_enum<T>::ordinal(std::string const& s)
 {
-    std::locale old_locale = is.imbue(blank_is_not_whitespace_locale());
-    std::string s;
-    is >> s;
-    is.imbue(old_locale);
-
     std::size_t v = std::find(c(), c() + n(), s) - c();
-    if(n() == v)
+    if(v == n())
         {
-        v = std::find(c(), c() + n(), provide_for_backward_compatibility(s)) - 
c();
+        fatal_error()
+            << "Value '"
+            << s
+            << "' invalid for type '"
+            << lmi::TypeInfo(typeid(T))
+            << "'."
+            << LMI_FLUSH
+            ;
         }
-    if(n() == v)
-        {
-        ordinal(s); // Throws.
-        throw "Unreachable.";
-        }
-    value_ = e()[v];
-
-    return is;
+    return v;
 }
 
 template<typename T>
-std::ostream& mc_enum<T>::write(std::ostream& os) const
+std::vector<std::string> const& mc_enum<T>::all_strings()
 {
-    return os << str();
+    static std::vector<std::string> const v(c(), c() + n());
+    return v;
 }
 
 template<typename T>
@@ -200,39 +159,80 @@
 }
 
 template<typename T>
+std::string mc_enum<T>::str() const
+{
+    return c()[ordinal()];
+}
+
+template<typename T>
 T mc_enum<T>::value() const
 {
     return value_;
 }
 
+// TODO ?? Should there be a runtime check that all elements in
+// e() and in c() are unique? Can that be asserted at compile time?
+
 template<typename T>
-std::size_t mc_enum<T>::ordinal(std::string const& s)
+std::size_t        mc_enum<T>::n() {return mc_enum_key<T>::n_;}
+
+template<typename T>
+T    const*        mc_enum<T>::e() {return mc_enum_key<T>::e();}
+
+template<typename T>
+char const* const* mc_enum<T>::c() {return mc_enum_key<T>::c();}
+
+namespace
 {
-    std::size_t v = std::find(c(), c() + n(), s) - c();
-    if(v == n())
+/// A whilom version of a vetust class substituted underbars for
+/// spaces, for reasons that, well, seemed good at the time.
+
+std::string provide_for_backward_compatibility(std::string const& s)
+{
+    static std::string const underbar("_");
+    std::string r(s);
+    for(;;)
         {
-        fatal_error()
-            << "Value '"
-            << s
-            << "' invalid for type '"
-            << lmi::TypeInfo(typeid(T))
-            << "'."
-            << LMI_FLUSH
-            ;
+        std::string::size_type xpos = r.find_first_of(underbar);
+        if(std::string::npos == xpos)
+            {
+            break;
+            }
+        else
+            {
+            r[xpos] = ' ';
+            }
         }
-    return v;
+    return r;
 }
+} // Unnamed namespace.
 
 template<typename T>
-std::string mc_enum<T>::str() const
+std::istream& mc_enum<T>::read(std::istream& is)
 {
-    return c()[ordinal()];
+    std::locale old_locale = is.imbue(blank_is_not_whitespace_locale());
+    std::string s;
+    is >> s;
+    is.imbue(old_locale);
+
+    std::size_t v = std::find(c(), c() + n(), s) - c();
+    if(n() == v)
+        {
+        v = std::find(c(), c() + n(), provide_for_backward_compatibility(s)) - 
c();
+        }
+    if(n() == v)
+        {
+        ordinal(s); // Throws.
+        throw "Unreachable.";
+        }
+    value_ = e()[v];
+
+    return is;
 }
 
 template<typename T>
-std::vector<std::string> const& mc_enum<T>::all_strings()
+std::ostream& mc_enum<T>::write(std::ostream& os) const
 {
-    static std::vector<std::string> const v(c(), c() + n());
-    return v;
+    return os << str();
 }
 

Modified: lmi/trunk/tn_range.tpp
===================================================================
--- lmi/trunk/tn_range.tpp      2011-10-02 09:58:24 UTC (rev 5293)
+++ lmi/trunk/tn_range.tpp      2011-10-08 10:02:27 UTC (rev 5294)
@@ -118,11 +118,11 @@
             }
         else if(0 < t)
             {
-            return  1;
+            return 1;
             }
         else
             {
-            return  0;
+            return 0;
             }
     }
 
@@ -202,10 +202,10 @@
                 );
             long int z1 = std::numeric_limits<long int>::max();
             return
-                    -z0 < t
-                &&        t < z0
-                &&  -z1 < t
-                &&        t < z1
+                   -z0 < t
+                &&       t < z0
+                && -z1 < t
+                &&       t < z1
                 && t == static_cast<long int>(t);
             }
     };
@@ -230,10 +230,10 @@
         // Here, '0 -' avoids a compiler warning about negating an
         // unsigned value.
         if
-            (       std::numeric_limits<T>::max()      == t
-            ||  0 - std::numeric_limits<T>::max()      == t
-            ||      std::numeric_limits<T>::infinity() == t
-            ||  0 - std::numeric_limits<T>::infinity() == t
+            (      std::numeric_limits<T>::max()      == t
+            || 0 - std::numeric_limits<T>::max()      == t
+            ||     std::numeric_limits<T>::infinity() == t
+            || 0 - std::numeric_limits<T>::infinity() == t
             )
             {
             return t;
@@ -346,15 +346,15 @@
 }
 
 template<typename T>
-T trammel_base<T>::default_initializer() const
+T trammel_base<T>::minimum_minimorum() const
 {
-    return default_value();
+    return adjust_minimum(nominal_minimum());
 }
 
 template<typename T>
-T trammel_base<T>::minimum_minimorum() const
+T trammel_base<T>::default_initializer() const
 {
-    return adjust_minimum(nominal_minimum());
+    return default_value();
 }
 
 template<typename T>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]