/** * \file output_helpers.h * \brief manipulation of text, and Interconversion between text and numbers * Copyright 2007-2010 IMP Inventors. All rights reserved. */ #ifndef IMPALGEBRA_INTERNAL_OUTPUT_HELPERS_H #define IMPALGEBRA_INTERNAL_OUTPUT_HELPERS_H #include "../algebra_config.h" #include "IMP/base_types.h" #include #include IMPALGEBRA_BEGIN_INTERNAL_NAMESPACE //! Best precision for a Float number. /* * This function returns the best precision to be used in a "printf" format if * this number is to fit in a given width. It returns -1 if the exponential * format is advised. */ IMPALGEBRAEXPORT int best_precision(double F, Int width); //! Formated Float to string conversion. /** * If precision==0 the precision is automatically computed in such a way that * the number fits the width (exponential format might be chosen). If * precision==-1 then the exponential format is forced. If width==0 then the * minimum width is used. */ IMPALGEBRAEXPORT std::string float_to_string(double F, Int width = 8, Int prec = 0); template struct IMPALGEBRAEXPORT stdVectorIO { const std::vector &v_; stdVectorIO(const std::vector& v): v_(v) {} }; //! output for a std::vector template std::ostream& operator<<(std::ostream& ostrm, const stdVectorIO& v) { unsigned long s = v.v_.size(); for(unsigned long i = 0; i