J
JustSomeGuy
I need to make a class called uid.
A UID is a unique identifier.
It looks like... 1.2.3.345.1.2.4.566
This uid get transmitted over a network as 8 bit binary data.
If the length of the UID is odd, an extra padding null \0 is added
to the end.
This is what I've written but I'm not sure if I've garanteed to have
the c_str() method return a buffer that is null padded.
class uid
{
private:
std::string id;
public:
uid(std::string _id)
{
id = _id;
unsigned int len = id.size();
if (len & 0x00000001)
id.push_back(0x00);
}
int getSize(void)
{
return id.size();
}
const void *getData(void)
{
return id.c_str();
}
};
A UID is a unique identifier.
It looks like... 1.2.3.345.1.2.4.566
This uid get transmitted over a network as 8 bit binary data.
If the length of the UID is odd, an extra padding null \0 is added
to the end.
This is what I've written but I'm not sure if I've garanteed to have
the c_str() method return a buffer that is null padded.
class uid
{
private:
std::string id;
public:
uid(std::string _id)
{
id = _id;
unsigned int len = id.size();
if (len & 0x00000001)
id.push_back(0x00);
}
int getSize(void)
{
return id.size();
}
const void *getData(void)
{
return id.c_str();
}
};