#include "Utils.h"
#include "common.h"

#include <tango/tango.h>

#include <cstdio>

/// Parse a string to return an integer
/// Current implementation does not complain about trailing garbage.
template <>
int ParseString<int>(const char *c_str)
{
    int val;
    const int ret = sscanf(c_str, "%d", &val);

    if(ret != 1 || ret == EOF)
    {
        std::stringstream sstr;
        sstr << "Could not parse the string \"" << c_str << "\" to number";

        Tango::Except::throw_exception(DB_ParseStringError, sstr.str(), "DataBase::ParseString");
    }

    return val;
}
