18#include <boost/lexical_cast.hpp>
35decimalToNumber(
const char* s,
const char* s_end) {
40 const std::string num_str(s, s + 3);
42 const int i = boost::lexical_cast<int>(num_str);
48 }
catch (
const boost::bad_lexical_cast&) {
50 "Invalid form for escaped digits: " << num_str);
62 const char* s = str_region.
beg;
63 const char*
const s_end = str_region.
beg + str_region.
len;
65 for (
size_t n = str_region.
len; n != 0; --n, ++s) {
67 if (escape && std::isdigit(c) != 0) {
68 c = decimalToNumber(s, s_end);
75 }
else if (!escape && c ==
'\\') {
87 (result.size() - 1) <<
"(+1) characters");
89 result[0] = result.size() - 1;
96 const char* s = str_region.
beg;
97 const char*
const s_end = str_region.
beg + str_region.
len;
99 for (
size_t n = str_region.
len; n != 0; --n, ++s) {
101 if (escape && std::isdigit(c) != 0) {
102 c = decimalToNumber(s, s_end);
109 }
else if (!escape && c ==
'\\') {
125 for (
auto const& it : char_string) {
130 const uint8_t
ch = it;
131 if ((
ch < 0x20) || (
ch >= 0x7f)) {
134 s.push_back(
'0' + ((
ch / 100) % 10));
135 s.push_back(
'0' + ((
ch / 10) % 10));
136 s.push_back(
'0' + (
ch % 10));
139 if ((
ch ==
'"') || (
ch ==
';') || (
ch ==
'\\')) {
151 for (
auto const& it : char_string) {
152 const uint8_t
ch = it;
153 if ((
ch < 0x20) || (
ch >= 0x7f)) {
156 s.push_back(
'0' + ((
ch / 100) % 10));
157 s.push_back(
'0' + ((
ch / 10) % 10));
158 s.push_back(
'0' + (
ch % 10));
161 if ((
ch ==
'"') || (
ch ==
';') || (
ch ==
'\\')) {
172 if (self.size() == 0 && other.size() == 0) {
175 if (self.size() == 0) {
178 if (other.size() == 0) {
181 const size_t self_len = self[0];
182 const size_t other_len = other[0];
183 const size_t cmp_len = std::min(self_len, other_len);
187 if (self_len < other_len) {
189 }
else if (self_len > other_len) {
195 const int cmp = std::memcmp(&self[1], &other[1], cmp_len);
198 }
else if (cmp > 0) {
200 }
else if (self_len < other_len) {
202 }
else if (self_len > other_len) {
211 if (self.size() == 0 && other.size() == 0) {
214 if (self.size() == 0) {
217 if (other.size() == 0) {
220 const size_t self_len = self.size();
221 const size_t other_len = other.size();
222 const size_t cmp_len = std::min(self_len, other_len);
223 const int cmp = std::memcmp(&self[0], &other[0], cmp_len);
226 }
else if (cmp > 0) {
228 }
else if (self_len < other_len) {
230 }
else if (self_len > other_len) {
242 "insufficient data to read character-string length");
245 if (rdata_len <
static_cast<size_t>(len) + 1) {
247 "character string length is too large: " <<
248 static_cast<int>(len));
252 "not enough data in buffer to read character-string of len"
253 <<
static_cast<int>(len));
256 target.resize(len + 1);
258 buffer.
readData(&target[0] + 1, len);
A standard DNS module exception that is thrown if RDATA parser fails to recognize a given textual rep...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define isc_throw_assert(expr)
Replacement for assert() that throws if the expression is false.
std::string charStringToString(const CharString &char_string)
Convert a CharString into a textual DNS character-string.
int compareCharStrings(const detail::CharString &self, const detail::CharString &other)
Compare two CharString objects.
int compareCharStringDatas(const detail::CharStringData &self, const detail::CharStringData &other)
Compare two CharStringData objects.
void stringToCharString(const MasterToken::StringRegion &str_region, CharString &result)
Convert a DNS character-string into corresponding binary data.
std::vector< uint8_t > CharStringData
Type for DNS character string without the length prefix.
void stringToCharStringData(const MasterToken::StringRegion &str_region, CharStringData &result)
Convert a DNS character-string into corresponding binary data.
size_t bufferToCharString(isc::util::InputBuffer &buffer, size_t rdata_len, CharString &target)
Convert a buffer containing a character-string to CharString.
std::string charStringDataToString(const CharStringData &char_string)
Convert a CharStringData into a textual DNS character-string.
std::vector< uint8_t > CharString
Type for DNS character string.
const unsigned int MAX_CHARSTRING_LEN
The maximum allowable length of character-string containing in RDATA as defined in RFC1035,...
Defines the logger used by the top-level component of kea-lfc.
A simple representation of a range of a string.
size_t len
The length of the string in bytes.
const char * beg
The start address of the string.