#include <ostream>
#include <stdio.h>
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS
-#endif
-#include <inttypes.h>
-
#include "pbd/id.h"
+#include "pbd/string_convert.h"
+
#include <string>
using namespace std;
{
Glib::Threads::Mutex::Lock lm (*counter_lock);
_id = _counter++;
-}
-
-int
-ID::string_assign (string str)
-{
- return sscanf (str.c_str(), "%" PRIu64, &_id) != 0;
}
-void
-ID::print (char* buf, uint32_t bufsize) const
+bool
+ID::string_assign (string str)
{
- snprintf (buf, bufsize, "%" PRIu64, _id);
+ return string_to_uint64 (str, _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;
}