[svn] commit: r1408 - in /trunk/src/lib/cc: data.cc data.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Mar 15 08:35:46 UTC 2010
Author: jinmei
Date: Mon Mar 15 08:35:45 2010
New Revision: 1408
Log:
namespace related cleanups
Modified:
trunk/src/lib/cc/data.cc
trunk/src/lib/cc/data.h
Modified: trunk/src/lib/cc/data.cc
==============================================================================
--- trunk/src/lib/cc/data.cc (original)
+++ trunk/src/lib/cc/data.cc Mon Mar 15 08:35:45 2010
@@ -43,7 +43,11 @@
const unsigned char ITEM_LENGTH_8 = 0x20;
const unsigned char ITEM_LENGTH_MASK = 0x30;
-static inline void
+namespace isc {
+namespace data {
+
+namespace {
+inline void
throwParseError(const std::string& error, const std::string& file, int line = 0, int pos = 0)
{
if (line != 0 || pos != 0) {
@@ -54,6 +58,7 @@
throw ParseError(error);
}
}
+}
std::ostream& operator <<(std::ostream &out, const isc::data::ElementPtr& e) {
return out << e->str();
@@ -124,8 +129,8 @@
//
// helper functions for createFromString factory
//
-
-static bool
+namespace {
+bool
char_in(const char c, const char *chars) {
for (size_t i = 0; i < strlen(chars); ++i) {
if (chars[i] == c) {
@@ -135,7 +140,7 @@
return false;
}
-static void
+void
skip_chars(std::istream &in, const char *chars, int& line, int& pos) {
char c = in.peek();
while (char_in(c, chars) && c != EOF) {
@@ -155,7 +160,7 @@
// unless that character is specified in the optional may_skip
//
// the character found is left on the stream
-static void
+void
skip_to(std::istream &in, const std::string& file, int& line,
int& pos, const char* chars, const char* may_skip="")
{
@@ -188,7 +193,7 @@
throwParseError(std::string("EOF read, one of \"") + chars + "\" expected", file, line, pos);
}
-static std::string
+std::string
str_from_stringstream(std::istream &in, const std::string& file, int& line, int& pos) throw (ParseError)
{
char c = 0;
@@ -213,7 +218,7 @@
return ss.str();
}
-static std::string
+std::string
word_from_stringstream(std::istream &in, int& line, int& pos) {
std::stringstream ss;
while (isalpha(in.peek())) {
@@ -223,7 +228,7 @@
return ss.str();
}
-static inline int
+inline int
count_chars_i(int i) {
int result = 1;
while (i > 10) {
@@ -233,7 +238,7 @@
return result;
}
-static inline int
+inline int
count_chars_d(double d) {
int result = 1;
while (d < 1.0) {
@@ -243,7 +248,7 @@
return result;
}
-static ElementPtr
+ElementPtr
from_stringstream_int_or_double(std::istream &in, int &line, int &pos) {
int i;
in >> i;
@@ -259,7 +264,7 @@
}
}
-static ElementPtr
+ElementPtr
from_stringstream_bool(std::istream &in, const std::string& file, int& line, int& pos)
{
const std::string word = word_from_stringstream(in, line, pos);
@@ -274,13 +279,13 @@
}
}
-static ElementPtr
+ElementPtr
from_stringstream_string(std::istream& in, const std::string& file, int& line, int& pos)
{
return Element::create(str_from_stringstream(in, file, line, pos));
}
-static ElementPtr
+ElementPtr
from_stringstream_list(std::istream &in, const std::string& file, int& line, int& pos)
{
char c = 0;
@@ -300,7 +305,7 @@
return Element::create(v);
}
-static ElementPtr
+ElementPtr
from_stringstream_map(std::istream &in, const std::string& file, int& line, int& pos)
{
char c = 0;
@@ -328,6 +333,7 @@
}
}
return Element::create(m);
+}
}
ElementPtr
@@ -511,10 +517,10 @@
//
// Decode from wire format.
//
-
+namespace {
ElementPtr decode_element(std::stringstream& in, int& in_length);
-static unsigned char
+unsigned char
get_byte(std::stringstream& in) {
const int c = in.get();
if (c == EOF) {
@@ -687,6 +693,7 @@
return (element);
}
+}
ElementPtr
Element::fromWire(const std::string& s) {
@@ -805,11 +812,13 @@
}
}
+namespace {
void
encode_tag(std::stringstream& ss, const std::string &s) {
const unsigned char val = s.length() & 0x000000ff;
ss << val << s;
+}
}
void
@@ -939,12 +948,12 @@
}
bool
-isc::data::isNull(ElementPtr p) {
+isNull(ElementPtr p) {
return !p;
}
void
-isc::data::removeIdentical(ElementPtr a, const ElementPtr b) {
+removeIdentical(ElementPtr a, const ElementPtr b) {
if (!b) {
return;
}
@@ -964,7 +973,7 @@
}
void
-isc::data::merge(ElementPtr element, const ElementPtr other) {
+merge(ElementPtr element, const ElementPtr other) {
if (element->getType() != Element::map ||
other->getType() != Element::map) {
isc_throw(TypeError, "merge arguments not MapElements");
@@ -981,3 +990,5 @@
}
}
+}
+}
Modified: trunk/src/lib/cc/data.h
==============================================================================
--- trunk/src/lib/cc/data.h (original)
+++ trunk/src/lib/cc/data.h Mon Mar 15 08:35:45 2010
@@ -492,8 +492,6 @@
/// Raises a TypeError if either ElementPtr is not a MapElement
void merge(ElementPtr element, const ElementPtr other);
-} }
-
///
/// \brief Insert the Element as a string into stream.
///
@@ -512,6 +510,7 @@
std::ostream& operator <<(std::ostream &out, const isc::data::ElementPtr& e);
bool operator==(const isc::data::ElementPtr a, const isc::data::ElementPtr b);
+} }
#endif // _ISC_DATA_H
More information about the bind10-changes
mailing list