/*
- Copyright (C) 2000-2007 Paul Davis
+ Copyright (C) 2000-2007 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <inttypes.h>
#include "pbd/id.h"
+#include "pbd/string_convert.h"
+
#include <string>
using namespace std;
using namespace PBD;
-Glib::Mutex* ID::counter_lock = 0;
+Glib::Threads::Mutex* ID::counter_lock = 0;
uint64_t ID::_counter = 0;
void
ID::init ()
{
if (!counter_lock)
- counter_lock = new Glib::Mutex;
+ counter_lock = new Glib::Threads::Mutex;
}
ID::ID ()
void
ID::reset ()
{
- Glib::Mutex::Lock lm (*counter_lock);
+ Glib::Threads::Mutex::Lock lm (*counter_lock);
_id = _counter++;
-}
+}
-int
+bool
ID::string_assign (string str)
{
- return sscanf (str.c_str(), "%" PRIu64, &_id) != 0;
+ return string_to_uint64 (str, _id);
}
void
snprintf (buf, bufsize, "%" PRIu64, _id);
}
-string ID::to_s() const
+std::string
+ID::to_s () const
{
- char buf[32]; // see print()
- print(buf, sizeof (buf));
- return string(buf);
+ return to_string (_id);
}
bool
ID::operator== (const string& str) const
{
- return to_s() == str;
+ return to_string (_id) == str;
}
ID&
}
ostream&
-operator<< (ostream& ostr, const ID& _id)
+operator<< (ostream& ostr, const ID& id)
{
- char buf[32];
- _id.print (buf, sizeof (buf));
- ostr << buf;
+ ostr << id.to_s();
return ostr;
}