projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
not completely tested new structure for VST/FST build
[ardour.git]
/
libs
/
pbd
/
id.cc
diff --git
a/libs/pbd/id.cc
b/libs/pbd/id.cc
index f483ff911c27b993bec4a05c249153f8038c4d50..353776de9f5c585acc89be5ef59cf2a420dcc25e 100644
(file)
--- a/
libs/pbd/id.cc
+++ b/
libs/pbd/id.cc
@@
-8,17
+8,24
@@
#include <inttypes.h>
#include <pbd/id.h>
#include <inttypes.h>
#include <pbd/id.h>
+#include <string>
using namespace std;
using namespace PBD;
using namespace std;
using namespace PBD;
-Glib::Mutex
ID::counter_lock
;
+Glib::Mutex
* ID::counter_lock = 0
;
uint64_t ID::_counter = 0;
uint64_t ID::_counter = 0;
+void
+ID::init ()
+{
+ counter_lock = new Glib::Mutex;
+}
+
ID::ID ()
{
ID::ID ()
{
- Glib::Mutex::Lock lm (counter_lock);
- id = _counter++;
+ Glib::Mutex::Lock lm (
*
counter_lock);
+
_
id = _counter++;
}
ID::ID (string str)
}
ID::ID (string str)
@@
-29,14
+36,20
@@
ID::ID (string str)
int
ID::string_assign (string str)
{
int
ID::string_assign (string str)
{
- return sscanf (str.c_str(), "%" PRIu64, &id) != 0;
+ return sscanf (str.c_str(), "%" PRIu64, &
_
id) != 0;
}
void
}
void
-ID::print (char* buf) const
+ID::print (char* buf, uint32_t bufsize) const
+{
+ snprintf (buf, bufsize, "%" PRIu64, _id);
+}
+
+string ID::to_s() const
{
{
- /* XXX sizeof buf is unknown. bad API design */
- snprintf (buf, 16, "%" PRIu64, id);
+ char buf[32]; // see print()
+ print(buf, sizeof (buf));
+ return string(buf);
}
ID&
}
ID&
@@
-47,10
+60,10
@@
ID::operator= (string str)
}
ostream&
}
ostream&
-operator<< (ostream& ostr, const ID& id)
+operator<< (ostream& ostr, const ID&
_
id)
{
char buf[32];
{
char buf[32];
-
id.print (buf
);
+
_id.print (buf, sizeof (buf)
);
ostr << buf;
return ostr;
}
ostr << buf;
return ostr;
}