//-----------------------------------------------------------------------
 String StringConverter::toString(const ColourValue& val)
 {
     StringStream stream;
     if (msUseLocale)
         stream.imbue(msLocale);
     stream << val.r << " " << val.g << " " << val.b << " " << val.a;
     return stream.str();
 }
 //-----------------------------------------------------------------------
 String StringConverter::toString(const Quaternion& val)
 {
     StringStream stream;
     if (msUseLocale)
         stream.imbue(msLocale);
     stream  << val.w << " " << val.x << " " << val.y << " " << val.z;
     return stream.str();
 }
 //-----------------------------------------------------------------------
 String StringConverter::toString(const Vector4& val)
 {
     StringStream stream;
     if (msUseLocale)
         stream.imbue(msLocale);
     stream << val.x << " " << val.y << " " << val.z << " " << val.w;
     return stream.str();
 }
 //-----------------------------------------------------------------------
 String StringConverter::toString(int val, 
     unsigned short width, char fill, std::ios::fmtflags flags)
 {
     StringStream stream;
     if (msUseLocale)
         stream.imbue(msLocale);
     stream.width(width);
     stream.fill(fill);
     if (flags)
         stream.setf(flags);
     stream << val;
     return stream.str();
 }
 //-----------------------------------------------------------------------
 String StringConverter::toString(const Matrix3& val)
 {
     StringStream stream;
     stream.imbue(msLocale);
     stream << val[0][0] << " "
         << val[0][1] << " "             
         << val[0][2] << " "             
         << val[1][0] << " "             
         << val[1][1] << " "             
         << val[1][2] << " "             
         << val[2][0] << " "             
         << val[2][1] << " "             
         << val[2][2];
     return stream.str();
 }
Esempio n. 6
0
void test_ops (const TempParams<T, CharT, Traits, Dist> &params,
               int                                       line,
               const char                               *input,
               T                                         expect,
               bool                                      is_eos,
               int                                       state)
{
    typedef std::istream_iterator<T, CharT, Traits, Dist> Iterator;
    typedef std::basic_stringstream<CharT, Traits>        StringStream;

    fmtnam (params.names);

    StringStream strm;

    typedef std::istreambuf_iterator<CharT, Traits> StreambufIterator;
    typedef std::num_get<CharT, StreambufIterator>  NumGet;

    if (false == std::has_facet<NumGet>(strm.getloc ())) {
        const std::locale loc (std::locale::classic (), new NumGet);
        strm.imbue (loc);
    }

    if (input && *input)
        strm << input;

    const Iterator eos;

    const Iterator it (strm);

    rw_assert (is_eos ^ (it != eos), 0, line,
               "line %d: %{$ITER}::operator() != %{$ITER}()", __LINE__);

    if (0 == (strm.rdstate () & (strm.badbit | strm.failbit))) {
        // operator*() is defined only for non-eos iterators
        // avoid calling it on a bad or failed stream too

        const T val = *it;

        rw_assert (val == expect, 0, line,
                   "line %d: %{$ITER}::operator*() == %{@}, got %{@}",
                   __LINE__, params.names.tfmt, expect, params.names.tfmt, val);
    }

    rw_assert (strm.rdstate () == state, 0, line,
               "line %d: %{$ITER}::operator*(), rdstate() == %{Is}, got %{Is}",
               __LINE__, state, strm.rdstate ());
}
    //-----------------------------------------------------------------------
    String StringConverter::toString(const StringVector& val)
    {
        StringStream stream;
        if (msUseLocale)
            stream.imbue(msLocale);
        StringVector::const_iterator i, iend, ibegin;
        ibegin = val.begin();
        iend = val.end();
        for (i = ibegin; i != iend; ++i)
        {
            if (i != ibegin)
                stream << " ";

            stream << *i; 
        }
        return stream.str();
    }