Commit 81eb4c24 authored by JINMEI Tatuya's avatar JINMEI Tatuya

style fixes:

 - added surrandong parentheses for return values based on agreed guideline
 - removed redundant semicolons after a block
 - fixed curly brace position

diff is large, but the change is very trivial.  so I'm skipping explicit review.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@2745 e5f2f494-b856-4b98-b285-d166d9295462
parent cbd29a59
...@@ -563,7 +563,7 @@ IOService::stop() { ...@@ -563,7 +563,7 @@ IOService::stop() {
asio::io_service& asio::io_service&
IOService::get_io_service() { IOService::get_io_service() {
return impl_->io_service_; return (impl_->io_service_);
} }
void void
......
...@@ -521,11 +521,11 @@ AuthSrv::updateConfig(isc::data::ElementPtr new_config) { ...@@ -521,11 +521,11 @@ AuthSrv::updateConfig(isc::data::ElementPtr new_config) {
ElementPtr answer = isc::config::createAnswer(); ElementPtr answer = isc::config::createAnswer();
answer = impl_->setDbFile(new_config); answer = impl_->setDbFile(new_config);
return answer; return (answer);
} catch (const isc::Exception& error) { } catch (const isc::Exception& error) {
if (impl_->verbose_mode_) { if (impl_->verbose_mode_) {
cerr << "[b10-auth] error: " << error.what() << endl; cerr << "[b10-auth] error: " << error.what() << endl;
} }
return isc::config::createAnswer(1, error.what()); return (isc::config::createAnswer(1, error.what()));
} }
} }
...@@ -68,7 +68,7 @@ asio_link::IOService* io_service; ...@@ -68,7 +68,7 @@ asio_link::IOService* io_service;
ElementPtr ElementPtr
my_config_handler(ElementPtr new_config) { my_config_handler(ElementPtr new_config) {
return auth_server->updateConfig(new_config); return (auth_server->updateConfig(new_config));
} }
ElementPtr ElementPtr
...@@ -83,7 +83,7 @@ my_command_handler(const string& command, const ElementPtr args) { ...@@ -83,7 +83,7 @@ my_command_handler(const string& command, const ElementPtr args) {
io_service->stop(); io_service->stop();
} }
return answer; return (answer);
} }
void void
......
...@@ -35,24 +35,21 @@ namespace isc { ...@@ -35,24 +35,21 @@ namespace isc {
namespace data { namespace data {
std::string std::string
Element::str() Element::str() {
{
std::stringstream ss; std::stringstream ss;
toJSON(ss); toJSON(ss);
return ss.str(); return (ss.str());
} }
std::string std::string
Element::toWire() Element::toWire() {
{
std::stringstream ss; std::stringstream ss;
toJSON(ss); toJSON(ss);
return ss.str(); return (ss.str());
} }
void void
Element::toWire(std::ostream& ss) Element::toWire(std::ostream& ss) {
{
toJSON(ss); toJSON(ss);
} }
...@@ -65,63 +62,62 @@ Element::toWire(std::ostream& ss) ...@@ -65,63 +62,62 @@ Element::toWire(std::ostream& ss)
// //
bool bool
Element::getValue(long int& t UNUSED_PARAM) { Element::getValue(long int& t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::getValue(double& t UNUSED_PARAM) { Element::getValue(double& t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::getValue(bool& t UNUSED_PARAM) { Element::getValue(bool& t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::getValue(std::string& t UNUSED_PARAM) { Element::getValue(std::string& t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::getValue(std::vector<ElementPtr>& t UNUSED_PARAM) { Element::getValue(std::vector<ElementPtr>& t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::getValue(std::map<std::string, ElementPtr>& t UNUSED_PARAM) { Element::getValue(std::map<std::string, ElementPtr>& t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::setValue(const long int v UNUSED_PARAM) { Element::setValue(const long int v UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::setValue(const double v UNUSED_PARAM) { Element::setValue(const double v UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::setValue(const bool t UNUSED_PARAM) { Element::setValue(const bool t UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::setValue(const std::string& v UNUSED_PARAM) { Element::setValue(const std::string& v UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::setValue(const std::vector<ElementPtr>& v UNUSED_PARAM) { Element::setValue(const std::vector<ElementPtr>& v UNUSED_PARAM) {
return false; return (false);
} }
bool bool
Element::setValue(const std::map<std::string, ElementPtr>& v UNUSED_PARAM) Element::setValue(const std::map<std::string, ElementPtr>& v UNUSED_PARAM) {
{ return (false);
return false;
} }
ElementPtr ElementPtr
...@@ -180,7 +176,7 @@ bool ...@@ -180,7 +176,7 @@ bool
Element::find(const std::string& identifier UNUSED_PARAM, Element::find(const std::string& identifier UNUSED_PARAM,
ElementPtr& t UNUSED_PARAM) ElementPtr& t UNUSED_PARAM)
{ {
return false; return (false);
} }
namespace { namespace {
...@@ -194,11 +190,11 @@ throwJSONError(const std::string& error, const std::string& file, int line, int ...@@ -194,11 +190,11 @@ throwJSONError(const std::string& error, const std::string& file, int line, int
} }
std::ostream& operator <<(std::ostream &out, const isc::data::ElementPtr& e) { std::ostream& operator <<(std::ostream &out, const isc::data::ElementPtr& e) {
return out << e->str(); return (out << e->str());
} }
bool operator==(const isc::data::ElementPtr a, const isc::data::ElementPtr b) { bool operator==(const isc::data::ElementPtr a, const isc::data::ElementPtr b) {
return a->equals(b); return (a->equals(b));
}; };
// //
...@@ -206,37 +202,37 @@ bool operator==(const isc::data::ElementPtr a, const isc::data::ElementPtr b) { ...@@ -206,37 +202,37 @@ bool operator==(const isc::data::ElementPtr a, const isc::data::ElementPtr b) {
// //
ElementPtr ElementPtr
Element::create() { Element::create() {
return ElementPtr(new NullElement()); return (ElementPtr(new NullElement()));
} }
ElementPtr ElementPtr
Element::create(const long int i) { Element::create(const long int i) {
return ElementPtr(new IntElement(i)); return (ElementPtr(new IntElement(i)));
} }
ElementPtr ElementPtr
Element::create(const double d) { Element::create(const double d) {
return ElementPtr(new DoubleElement(d)); return (ElementPtr(new DoubleElement(d)));
} }
ElementPtr ElementPtr
Element::create(const std::string& s) { Element::create(const std::string& s) {
return ElementPtr(new StringElement(s)); return (ElementPtr(new StringElement(s)));
} }
ElementPtr ElementPtr
Element::create(const bool b) { Element::create(const bool b) {
return ElementPtr(new BoolElement(b)); return (ElementPtr(new BoolElement(b)));
} }
ElementPtr ElementPtr
Element::createList() { Element::createList() {
return ElementPtr(new ListElement()); return (ElementPtr(new ListElement()));
} }
ElementPtr ElementPtr
Element::createMap() { Element::createMap() {
return ElementPtr(new MapElement()); return (ElementPtr(new MapElement()));
} }
...@@ -248,10 +244,10 @@ bool ...@@ -248,10 +244,10 @@ bool
char_in(const char c, const char *chars) { char_in(const char c, const char *chars) {
for (size_t i = 0; i < strlen(chars); ++i) { for (size_t i = 0; i < strlen(chars); ++i) {
if (chars[i] == c) { if (chars[i] == c) {
return true; return (true);
} }
} }
return false; return (false);
} }
void void
...@@ -332,7 +328,7 @@ str_from_stringstream(std::istream &in, const std::string& file, const int line, ...@@ -332,7 +328,7 @@ str_from_stringstream(std::istream &in, const std::string& file, const int line,
c = in.get(); c = in.get();
++pos; ++pos;
} }
return ss.str(); return (ss.str());
} }
std::string std::string
...@@ -342,7 +338,7 @@ word_from_stringstream(std::istream &in, int& pos) { ...@@ -342,7 +338,7 @@ word_from_stringstream(std::istream &in, int& pos) {
ss << (char) in.get(); ss << (char) in.get();
} }
pos += ss.str().size(); pos += ss.str().size();
return ss.str(); return (ss.str());
} }
static std::string static std::string
...@@ -353,7 +349,7 @@ number_from_stringstream(std::istream &in, int& pos) { ...@@ -353,7 +349,7 @@ number_from_stringstream(std::istream &in, int& pos) {
ss << (char) in.get(); ss << (char) in.get();
} }
pos += ss.str().size(); pos += ss.str().size();
return ss.str(); return (ss.str());
} }
// Should we change from IntElement and DoubleElement to NumberElement // Should we change from IntElement and DoubleElement to NumberElement
...@@ -386,9 +382,9 @@ from_stringstream_number(std::istream &in, int &pos) { ...@@ -386,9 +382,9 @@ from_stringstream_number(std::istream &in, int &pos) {
} }
if (is_double) { if (is_double) {
return Element::create(d); return (Element::create(d));
} else { } else {
return Element::create(i); return (Element::create(i));
} }
} }
...@@ -398,13 +394,13 @@ from_stringstream_bool(std::istream &in, const std::string& file, ...@@ -398,13 +394,13 @@ from_stringstream_bool(std::istream &in, const std::string& file,
{ {
const std::string word = word_from_stringstream(in, pos); const std::string word = word_from_stringstream(in, pos);
if (boost::iequals(word, "True")) { if (boost::iequals(word, "True")) {
return Element::create(true); return (Element::create(true));
} else if (boost::iequals(word, "False")) { } else if (boost::iequals(word, "False")) {
return Element::create(false); return (Element::create(false));
} else { } else {
throwJSONError(std::string("Bad boolean value: ") + word, file, line, pos); throwJSONError(std::string("Bad boolean value: ") + word, file, line, pos);
// above is a throw shortcurt, return empty is never reached // above is a throw shortcurt, return empty is never reached
return ElementPtr(); return (ElementPtr());
} }
} }
...@@ -414,17 +410,17 @@ from_stringstream_null(std::istream &in, const std::string& file, ...@@ -414,17 +410,17 @@ from_stringstream_null(std::istream &in, const std::string& file,
{ {
const std::string word = word_from_stringstream(in, pos); const std::string word = word_from_stringstream(in, pos);
if (boost::iequals(word, "null")) { if (boost::iequals(word, "null")) {
return Element::create(); return (Element::create());
} else { } else {
throwJSONError(std::string("Bad null value: ") + word, file, line, pos); throwJSONError(std::string("Bad null value: ") + word, file, line, pos);
return ElementPtr(); return (ElementPtr());
} }
} }
ElementPtr ElementPtr
from_stringstream_string(std::istream& in, const std::string& file, int& line, int& pos) from_stringstream_string(std::istream& in, const std::string& file, int& line, int& pos)
{ {
return Element::create(str_from_stringstream(in, file, line, pos)); return (Element::create(str_from_stringstream(in, file, line, pos)));
} }
ElementPtr ElementPtr
...@@ -444,7 +440,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line, int ...@@ -444,7 +440,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line, int
c = in.get(); c = in.get();
pos++; pos++;
} }
return list; return (list);
} }
ElementPtr ElementPtr
...@@ -474,53 +470,53 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line, ...@@ -474,53 +470,53 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
pos++; pos++;
} }
} }
return map; return (map);
} }
} }
std::string std::string
Element::typeToName(Element::types type) Element::typeToName(Element::types type)
{ {
switch(type) { switch (type) {
case Element::integer: case Element::integer:
return std::string("integer"); return (std::string("integer"));
case Element::real: case Element::real:
return std::string("real"); return (std::string("real"));
case Element::boolean: case Element::boolean:
return std::string("boolean"); return (std::string("boolean"));
case Element::string: case Element::string:
return std::string("string"); return (std::string("string"));
case Element::list: case Element::list:
return std::string("list"); return (std::string("list"));
case Element::map: case Element::map:
return std::string("map"); return (std::string("map"));
case Element::null: case Element::null:
return std::string("null"); return (std::string("null"));
case Element::any: case Element::any:
return std::string("any"); return (std::string("any"));
default: default:
return std::string("unknown"); return (std::string("unknown"));
} }
} }
Element::types Element::types
Element::nameToType(const std::string& type_name) { Element::nameToType(const std::string& type_name) {
if (type_name == "integer") { if (type_name == "integer") {
return Element::integer; return (Element::integer);
} else if (type_name == "real") { } else if (type_name == "real") {
return Element::real; return (Element::real);
} else if (type_name == "boolean") { } else if (type_name == "boolean") {
return Element::boolean; return (Element::boolean);
} else if (type_name == "string") { } else if (type_name == "string") {
return Element::string; return (Element::string);
} else if (type_name == "list") { } else if (type_name == "list") {
return Element::list; return (Element::list);
} else if (type_name == "map") { } else if (type_name == "map") {
return Element::map; return (Element::map);
} else if (type_name == "null") { } else if (type_name == "null") {
return Element::null; return (Element::null);
} else if (type_name == "any") { } else if (type_name == "any") {
return Element::any; return (Element::any);
} else { } else {
isc_throw(TypeError, type_name + " is not a valid type name"); isc_throw(TypeError, type_name + " is not a valid type name");
} }
...@@ -529,14 +525,14 @@ Element::nameToType(const std::string& type_name) { ...@@ -529,14 +525,14 @@ Element::nameToType(const std::string& type_name) {
ElementPtr ElementPtr
Element::fromJSON(std::istream& in) throw(JSONError) { Element::fromJSON(std::istream& in) throw(JSONError) {
int line = 1, pos = 1; int line = 1, pos = 1;
return fromJSON(in, "<istream>", line, pos); return (fromJSON(in, "<istream>", line, pos));
} }
ElementPtr ElementPtr
Element::fromJSON(std::istream& in, const std::string& file_name) throw(JSONError) Element::fromJSON(std::istream& in, const std::string& file_name) throw(JSONError)
{ {
int line = 1, pos = 1; int line = 1, pos = 1;
return fromJSON(in, file_name, line, pos); return (fromJSON(in, file_name, line, pos));
} }
ElementPtr ElementPtr
...@@ -602,7 +598,7 @@ Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos ...@@ -602,7 +598,7 @@ Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos
} }
} }
if (el_read) { if (el_read) {
return element; return (element);
} else { } else {
isc_throw(JSONError, "nothing read"); isc_throw(JSONError, "nothing read");
} }
...@@ -612,7 +608,7 @@ ElementPtr ...@@ -612,7 +608,7 @@ ElementPtr
Element::fromJSON(const std::string &in) { Element::fromJSON(const std::string &in) {
std::stringstream ss; std::stringstream ss;
ss << in; ss << in;
return fromJSON(ss, "<string>"); return (fromJSON(ss, "<string>"));
} }
// to JSON format // to JSON format
...@@ -698,18 +694,18 @@ ElementPtr ...@@ -698,18 +694,18 @@ ElementPtr
MapElement::find(const std::string& id) { MapElement::find(const std::string& id) {
const size_t sep = id.find('/'); const size_t sep = id.find('/');
if (sep == std::string::npos) { if (sep == std::string::npos) {
return get(id); return (get(id));
} else { } else {
ElementPtr ce = get(id.substr(0, sep)); ElementPtr ce = get(id.substr(0, sep));
if (ce) { if (ce) {
// ignore trailing slash // ignore trailing slash