示例#1
0
void
SexpParser::ListToString(stringstream& ss, const ParameterList& lst)
{
    string space;

    ss.setf(ios_base::fixed,ios_base::floatfield);
    ss.precision(2);

    for (
         ParameterList::TVector::const_iterator i = lst.begin();
         i != lst.end();
         ++i
         )
    {
        if (i->type() == typeid(string))
        {
            ss << space;
            ss << boost::any_cast<string>(*i);
        }
        else if (i->type() == typeid(float))
        {
            ss << space;
            ss << boost::any_cast<float>(*i);
        }
        else if (i->type() == typeid(int))
        {
            ss << space;
            ss <<boost::any_cast<int>(*i);
        }
        else if (i->type() == typeid(ParameterList))
        {
            const any* v = &(*i);
            const ParameterList* lst = any_cast<ParameterList>(v);
            ss << space;
            ss << '(';
            ListToString(ss,*lst);
            ss << ')';
        }
        else
        {
            ss << space;
            ss << "(error data format unknown)";
        }

        space = " ";
    }
}