- Unify interface of string_utils. I dropped most of the exception
handling, hoping it's unnecessary. Code should be slightly more maintainable now. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@943 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
696c513ed2
commit
231662825d
8 changed files with 55 additions and 185 deletions
|
@ -104,7 +104,7 @@ XMLSerializerFactory::create_resource(Parameters& parameters)
|
|||
if (id.length() > 6 && id.substr(0, 6) == Glib::ustring("reskey"))
|
||||
{
|
||||
key = id.substr(6);
|
||||
string_to_int(key, old_key);
|
||||
old_key = string_to<int>(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,14 +119,14 @@ XMLSerializerFactory::create_resource(Parameters& parameters)
|
|||
pos = parameters.find(Glib::ustring("arrival-time"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
arrival_time = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
// read "how-many" property
|
||||
pos = parameters.find(Glib::ustring("how-many"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, how_many);
|
||||
how_many = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,14 +160,14 @@ XMLSerializerFactory::create_process(Parameters& parameters)
|
|||
pos = parameters.find(Glib::ustring("arrival-time"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
arrival_time = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("priority"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, priority);
|
||||
priority = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
_last_process = &_hist->add_process(name, arrival_time, priority);
|
||||
|
@ -200,21 +200,21 @@ XMLSerializerFactory::create_thread(Parameters& parameters)
|
|||
pos = parameters.find(Glib::ustring("arrival-delta"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
arrival_time = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("priority"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, priority);
|
||||
priority = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("lasts-for"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, lasts_for);
|
||||
lasts_for = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
_last_thread = &_hist->add_thread(name, *_last_process, lasts_for, arrival_time, priority);
|
||||
|
@ -235,7 +235,7 @@ XMLSerializerFactory::create_request(Parameters& parameters)
|
|||
pos = parameters.find(Glib::ustring("arrival-time"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
arrival_time = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
_last_request = &_hist->add_request(*_last_thread, arrival_time);
|
||||
|
@ -259,7 +259,7 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
|
|||
pos = parameters.find(Glib::ustring("resource"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, old_key);
|
||||
old_key = string_to<int>(pos->second);
|
||||
|
||||
TempMap::iterator temp_pos;
|
||||
temp_pos = _temp_map.find((resource_key_t)old_key);
|
||||
|
@ -274,7 +274,7 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
|
|||
pos = parameters.find(Glib::ustring("lasts-for"));
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, lasts_for);
|
||||
lasts_for = string_to<int>(pos->second);
|
||||
}
|
||||
|
||||
return _hist->add_subrequest(*_last_request, new_key, (History::time_t)lasts_for);
|
||||
|
|
|
@ -129,7 +129,7 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
|
|||
{
|
||||
//XMLVisitor xvisit(resources_node);
|
||||
Glib::ustring key;
|
||||
int_to_string((int)(*iter).first, key);
|
||||
to_string<int>(static_cast<int>((*iter).first), key);
|
||||
//xvisit.from_resource(*((*iter).second), key);
|
||||
from_resource(resources_node, *((*iter).second), key);
|
||||
iter++;
|
||||
|
@ -164,7 +164,7 @@ void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Gli
|
|||
Glib::ustring strPreemptible("false"); // fixed??
|
||||
Glib::ustring strArrivalTime("0"); // fixed??
|
||||
Glib::ustring strPlaces;
|
||||
int_to_string((int)obj.get_places(), strPlaces);
|
||||
to_string<int>(static_cast<int>(obj.get_places()), strPlaces);
|
||||
|
||||
xmlNodePtr process_node = xmlNewChild(parent, NULL, (const xmlChar *) "resource", NULL);
|
||||
xmlNewProp(process_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
|
||||
|
@ -186,8 +186,8 @@ void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(Seria
|
|||
{
|
||||
Glib::ustring strPriority;
|
||||
Glib::ustring strArrivalTime;
|
||||
int_to_string(obj.get_base_priority(), strPriority);
|
||||
int_to_string(obj.get_arrival_time(), strArrivalTime);
|
||||
to_string<int>(obj.get_base_priority(), strPriority);
|
||||
to_string<int>(obj.get_arrival_time(), strArrivalTime);
|
||||
|
||||
xmlNodePtr process_node = xmlNewChild(parent, NULL, (const xmlChar *) "process", NULL);
|
||||
xmlNewProp(process_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
|
||||
|
@ -226,9 +226,9 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
|
|||
Glib::ustring strPriority;
|
||||
Glib::ustring strArrivalTime;
|
||||
Glib::ustring strLastsTime;
|
||||
int_to_string(obj.get_base_priority(), strPriority);
|
||||
int_to_string(obj.get_arrival_time(), strArrivalTime);
|
||||
int_to_string(obj.get_elapsed_time(), strLastsTime);
|
||||
to_string<int>(obj.get_base_priority(), strPriority);
|
||||
to_string<int>(obj.get_arrival_time(), strArrivalTime);
|
||||
to_string<int>(obj.get_elapsed_time(), strLastsTime);
|
||||
// get_elapsed_time() or get_total_cpu_time() ???
|
||||
xmlNodePtr thread_node = xmlNewChild(parent, NULL, (const xmlChar *) "thread", NULL);
|
||||
xmlNewProp(thread_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
|
||||
|
@ -265,7 +265,7 @@ void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(Seria
|
|||
{
|
||||
|
||||
Glib::ustring strArrivalTime;
|
||||
int_to_string(obj.get_instant(), strArrivalTime);
|
||||
to_string<int>(obj.get_instant(), strArrivalTime);
|
||||
|
||||
xmlNodePtr request_node = xmlNewChild(parent, NULL, (const xmlChar *) "request", NULL);
|
||||
xmlNewProp(request_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str());
|
||||
|
@ -299,8 +299,8 @@ void XMLVisitor::from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw
|
|||
|
||||
Glib::ustring strResource;
|
||||
Glib::ustring strLastsFor;
|
||||
int_to_string(obj.get_resource_key(), strResource);
|
||||
int_to_string(obj.get_length(), strLastsFor);
|
||||
to_string<int>(obj.get_resource_key(), strResource);
|
||||
to_string<int>(obj.get_length(), strLastsFor);
|
||||
|
||||
xmlNodePtr subrequest_node = xmlNewChild(parent, NULL, (const xmlChar *) "subrequest", NULL);
|
||||
xmlNewProp(subrequest_node, (const xmlChar *) "resource", (const xmlChar *) strResource.c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue