physical::format::detail Namespace Reference


Functions

template<class UnitSystem>
std::ostream & automatic_quantity (std::ostream &os, DynamicPhysical< UnitSystem > q)
template<class UnitSystem>
std::ostream & single_dimension (std::ostream &os, enum UnitSystem::baseunit bu, const std::string &symbol, bool &first, DynamicPhysical< UnitSystem > q)
template<class UnitSystem>
std::ostream & automatic_dimension (std::ostream &os, DynamicPhysical< UnitSystem > q)
template<class UnitSystem>
std::string automatic_dimension_string (DynamicPhysical< UnitSystem > q)
template<class UnitSystem>
std::ostream & format_to_spec (std::ostream &os, DynamicPhysical< UnitSystem > quantity, FormatSpec< UnitSystem > spec)


Function Documentation

template<class UnitSystem>
std::ostream& physical::format::detail::automatic_dimension ( std::ostream &  os,
DynamicPhysical< UnitSystem >  q 
)

Definition at line 42 of file format_impl.hpp.

References physical::unit_si_float::ampere, physical::unit_si_float::candela, physical::DynamicPhysical< UnitSystem >::exponents, physical::unit_si_float::kelvin, physical::unit_si_float::kilogram, physical::unit_si_float::meter, physical::unitsymbol_si_float::mol, physical::unit_si_float::second, and single_dimension().

Referenced by automatic_dimension_string(), automatic_quantity(), and format_to_spec().

00042                                                                                                        {
00043                                 assert(q.exponents.exponents.size() == UnitSystem::number_baseunits);
00044                                 bool first=true;
00045                                 os << "[";
00046                                 single_dimension(os, UnitSystem::meter,         "m",    first, q);
00047                                 single_dimension(os, UnitSystem::kilogram,      "kg",   first, q);
00048                                 single_dimension(os, UnitSystem::second,        "s",    first, q);
00049                                 single_dimension(os, UnitSystem::ampere,        "A",    first, q);
00050                                 single_dimension(os, UnitSystem::kelvin,        "K",    first, q);
00051                                 single_dimension(os, UnitSystem::mol,           "mol",  first, q);
00052                                 single_dimension(os, UnitSystem::candela,       "cd",   first, q);
00053                                 if (first) os << "1";
00054                                 os << "]";
00055                                 return os;
00056                         };

template<class UnitSystem>
std::string physical::format::detail::automatic_dimension_string ( DynamicPhysical< UnitSystem >  q  ) 

Definition at line 65 of file format_impl.hpp.

References automatic_dimension().

00065                                                                                             {
00066                                 std::ostringstream os;
00067                                 automatic_dimension(os, q);
00068                                 return os.str();
00069                         };

template<class UnitSystem>
std::ostream & physical::format::detail::automatic_quantity ( std::ostream &  os,
DynamicPhysical< UnitSystem >  q 
)

Definition at line 59 of file format_impl.hpp.

References automatic_dimension(), and physical::DynamicPhysical< UnitSystem >::numerical_value.

Referenced by physical::operator<<().

00059                                                                                                       {
00060                                 os << q.numerical_value;
00061                                 return automatic_dimension(os, q);
00062                         };

template<class UnitSystem>
std::ostream & physical::format::detail::format_to_spec ( std::ostream &  os,
DynamicPhysical< UnitSystem >  quantity,
FormatSpec< UnitSystem >  spec 
)

Definition at line 72 of file format_impl.hpp.

References automatic_dimension(), physical::DynamicPhysical< UnitSystem >::numerical_value, physical::format::FormatSpec< UnitSystem >::precision, physical::unitsymbol_si_float::quantity, physical::format::FormatSpec< UnitSystem >::unit, and physical::format::FormatSpec< UnitSystem >::unitname.

Referenced by physical::format::operator<<().

00072                                                                                                                                      {
00073                                 
00074                                 if (spec.unit.exponents != quantity.exponents) {
00075                                         // Use automatically generated unit string.
00076                                         // Or better throw IncompatibleUnitException?
00077                                         os << quantity.numerical_value << "[";
00078                                         detail::automatic_dimension(os, quantity);
00079                                         os << "]";
00080 
00081                                 } else {
00082                                         // the (hopefully) usual case
00083 
00084                                         const DynamicPhysical<UnitSystem> &a = quantity;        
00085                                         const FormatSpec<UnitSystem>::unit_type &u = spec.unit;
00086                                         const DynamicPhysical<UnitSystem> x = a/u;      
00087                                         
00088                                         os.precision(spec.precision);
00089                                         os << x.numerical_value << "[" << spec.unitname <<"]";
00090                                 };
00091                                 return os;
00092                         }

template<class UnitSystem>
std::ostream& physical::format::detail::single_dimension ( std::ostream &  os,
enum UnitSystem::baseunit  bu,
const std::string &  symbol,
bool &  first,
DynamicPhysical< UnitSystem >  q 
)

Definition at line 29 of file format_impl.hpp.

References physical::DynamicPhysical< UnitSystem >::exponents.

Referenced by automatic_dimension().

00030                                                                                                                                  {
00031                                 int e = q.exponents.exponents[bu];
00032                                 if(e) {
00033                                         if (!first) os << "*";
00034                                         os << symbol;
00035                                         if (e!=1) os << '^' << e;
00036                                         first=false;
00037                                 };
00038                                 return os;
00039                         };


Generated on Mon Apr 2 22:25:08 2007 for physical_svn by  doxygen 1.5.1-p1
hosted on SourceForge.net Logo