Boost logo

Boost-Commit :

From: boost_at_[hidden]
Date: 2008-06-01 04:31:29


Author: matthiasschabel
Date: 2008-06-01 04:31:29 EDT (Sun, 01 Jun 2008)
New Revision: 46006
URL: http://svn.boost.org/trac/boost/changeset/46006

Log:
something funky going on here...need to fix
Text files modified:
   sandbox/units/libs/units/example/runtime_unit.cpp | 75 ++++++++++++++++++++++++++++++---------
   1 files changed, 57 insertions(+), 18 deletions(-)

Modified: sandbox/units/libs/units/example/runtime_unit.cpp
==============================================================================
--- sandbox/units/libs/units/example/runtime_unit.cpp (original)
+++ sandbox/units/libs/units/example/runtime_unit.cpp 2008-06-01 04:31:29 EDT (Sun, 01 Jun 2008)
@@ -27,50 +27,89 @@
 
 }
 
-quantity<si::length> calculate(const quantity<si::length>& t) {
+quantity<si::length> calculate(const quantity<si::length>& t)
+{
     return(boost::units::hypot(t, 2.0 * si::meters));
 }
 
-int main() {
+// enter "return meter", then 3.4 centimeter
+// -> gives 2.00029 meter as output?
+
+int main()
+{
     known_units["meter"] = 1.0 * si::meters;
     known_units["centimeter"] = .01 * si::meters;;
     known_units["foot"] =
         conversion_factor(foot_base_unit::unit_type(), si::meter) * si::meter;
+
     std::string output_type("meter");
     std::string input;
- while((std::cout << ">") && (std::cin >> input)) {
- if(!input.empty() && input[0] == '#') std::getline(std::cin, input);
- else if(input == "exit") break;
- else if(input == "help") {
+
+ while((std::cout << ">") && (std::cin >> input))
+ {
+ if(!input.empty() && input[0] == '#')
+ {
+ std::getline(std::cin, input);
+ }
+ else if(input == "exit")
+ {
+ break;
+ }
+ else if(input == "help")
+ {
             std::cout << "type \"exit\" to exit\n"
                 "type \"return 'unit'\" to set the return units\n"
                 "type \"'number' 'unit'\" to do a simple calculation"
                 << std::endl;
- } else if(input == "return") {
- if(std::cin >> input) {
- if(known_units.find(input) != known_units.end()) {
+ }
+ else if(input == "return")
+ {
+ if(std::cin >> input)
+ {
+ if(known_units.find(input) != known_units.end())
+ {
                     output_type = input;
                     std::cout << "Done." << std::endl;
- } else {
+ }
+ else
+ {
                     std::cout << "Unknown unit \"" << input << "\""
                          << std::endl;
                 }
- } else break;
- } else {
- try {
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ try
+ {
                 double value = boost::lexical_cast<double>(input);
- if(std::cin >> input) {
- if(known_units.find(input) != known_units.end()) {
+
+ if(std::cin >> input)
+ {
+ if(known_units.find(input) != known_units.end())
+ {
                         std::cout << static_cast<double>(
                             calculate(value * known_units[input]) /
                             known_units[output_type])
                             << ' ' << output_type << std::endl;
- } else {
+ }
+ else
+ {
                         std::cout << "Unknown unit \"" << input << "\""
                             << std::endl;
                     }
- } else break;
- } catch(...) {
+ }
+ else
+ {
+ break;
+ }
+ }
+ catch(...)
+ {
                 std::cout << "Input error" << std::endl;
             }
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk