22 copy(data.begin(), data.end(),
data_.begin());
68 snprintf(temp,
sizeof(temp),
"subcluster:%u:%u", asn,
id);
75 snprintf(temp,
sizeof(temp),
"subcluster:%u:%u", asn,
id);
82 boost::system::error_code *errorp) {
87 size_t pos = str.find(
':');
88 if (pos == string::npos) {
90 *errorp = make_error_code(boost::system::errc::invalid_argument);
95 string first(str.substr(0, pos));
96 if (first !=
"subcluster") {
98 *errorp = make_error_code(boost::system::errc::invalid_argument);
103 string rest(str.substr(pos+1));
105 pos = rest.find(
':');
106 if (pos == string::npos) {
107 if (errorp != NULL) {
108 *errorp = make_error_code(boost::system::errc::invalid_argument);
113 boost::system::error_code ec;
114 string second(rest.substr(0, pos));
118 uint64_t asn = strtoll(second.c_str(), &endptr, 10);
119 if (asn == 0 || asn > 0xFFFFFFFF || *endptr !=
'\0') {
120 if (errorp != NULL) {
121 *errorp = make_error_code(boost::system::errc::invalid_argument);
126 string third(rest.substr(pos+1));
127 uint64_t
id = strtoll(third.c_str(), &endptr, 10);
128 if (*endptr !=
'\0') {
129 if (errorp != NULL) {
130 *errorp = make_error_code(boost::system::errc::invalid_argument);
136 if ((asn >
AS2_MAX &&
id > 0xFFFF) ||
id == 0 ||
id > 0xFFFFFFFF) {
137 if (errorp != NULL) {
138 *errorp = make_error_code(boost::system::errc::invalid_argument);
boost::array< uint8_t, kSize > bytes_type
std::string ToString() const
static SubCluster FromString(const std::string &str, boost::system::error_code *error=NULL)
static SubCluster null_sub_cluster
static void put_value(uint8_t *data, int size, uint64_t value)
static uint64_t get_value(const uint8_t *data, int size)