diff options
Diffstat (limited to 'cpp')
430 files changed, 21148 insertions, 21148 deletions
diff --git a/cpp/demo/Freeze/bench/Client.cpp b/cpp/demo/Freeze/bench/Client.cpp index 143db226bcf..98975463f4f 100644 --- a/cpp/demo/Freeze/bench/Client.cpp +++ b/cpp/demo/Freeze/bench/Client.cpp @@ -42,7 +42,7 @@ public: double stop() { - if (!_stopped) + if(!_stopped) { _stopped = true; _stop = IceUtil::Time::now(); @@ -114,7 +114,7 @@ public: { int n = _current; ++_current; - if (_current > _max) + if(_current > _max) { _current = _min; } @@ -175,7 +175,7 @@ TestApp::IntIntMapTest(const Freeze::DBEnvironmentPtr& dbEnv) // int i; _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { m.insert(make_pair(i, i)); } @@ -189,7 +189,7 @@ TestApp::IntIntMapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Read each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { IntIntMap::const_iterator p = m.find(i); test(p != m.end()); @@ -205,7 +205,7 @@ TestApp::IntIntMapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Remove each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { m.erase(i); } @@ -222,7 +222,7 @@ void TestApp::generatedRead(IntIntMap& m, int reads , const GeneratorPtr& gen) { _watch.start(); - for (int i = 0; i < reads; ++i) + for(int i = 0; i < reads; ++i) { int key = gen->next(); IntIntMap::const_iterator p = m.find(key); @@ -249,7 +249,7 @@ TestApp::IntIntMapReadTest(const Freeze::DBEnvironmentPtr& dbEnv) // int i; _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { m.insert(make_pair(i, i)); } @@ -280,7 +280,7 @@ TestApp::IntIntMapReadTest(const Freeze::DBEnvironmentPtr& dbEnv) * want to examine the cache stats for the database. * _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { m.erase(i); } @@ -308,7 +308,7 @@ TestApp::Struct1Struct2MapTest(const Freeze::DBEnvironmentPtr& dbEnv) Struct2 s2; int i; _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; ostringstream os; @@ -326,7 +326,7 @@ TestApp::Struct1Struct2MapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Read each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; Struct1Struct2Map::const_iterator p = m.find(s1); @@ -345,7 +345,7 @@ TestApp::Struct1Struct2MapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Remove each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; m.erase(s1); @@ -372,7 +372,7 @@ TestApp::Struct1Class1MapTest(const Freeze::DBEnvironmentPtr& dbEnv) Class1Ptr c1 = new Class1(); int i; _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; ostringstream os; @@ -390,7 +390,7 @@ TestApp::Struct1Class1MapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Read each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; Struct1Class1Map::const_iterator p = m.find(s1); @@ -409,7 +409,7 @@ TestApp::Struct1Class1MapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Remove each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; m.erase(s1); @@ -440,11 +440,11 @@ TestApp::Struct1ObjectMapTest(const Freeze::DBEnvironmentPtr& dbEnv) c2->obj = c1; int i; _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; Ice::ObjectPtr o; - if ((i % 2) == 0) + if((i % 2) == 0) { o = c2; } @@ -467,14 +467,14 @@ TestApp::Struct1ObjectMapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Read each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; Struct1ObjectMap::const_iterator p = m.find(s1); test(p != m.end()); Ice::ObjectPtr o = p->second; Class1Ptr nc1; - if ((i % 2) == 0) + if((i % 2) == 0) { Class2Ptr nc2 = Class2Ptr::dynamicCast(o); test(nc2); @@ -500,7 +500,7 @@ TestApp::Struct1ObjectMapTest(const Freeze::DBEnvironmentPtr& dbEnv) // Remove each record. // _watch.start(); - for (i = 0; i < _repetitions; ++i) + for(i = 0; i < _repetitions; ++i) { s1.l = i; m.erase(s1); @@ -521,11 +521,11 @@ public: Ice::ObjectPtr create(const string& type) { - if (type == "::Class1") + if(type == "::Class1") { return new Class1(); } - else if (type == "::Class2") + else if(type == "::Class2") { return new Class2(); } diff --git a/cpp/demo/Freeze/library/BookFactory.h b/cpp/demo/Freeze/library/BookFactory.h index 58a95f2d8e5..677fc77e3bc 100644 --- a/cpp/demo/Freeze/library/BookFactory.h +++ b/cpp/demo/Freeze/library/BookFactory.h @@ -1,33 +1,33 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef BOOK_FACTORY_H -#define BOOK_FACTORY_H - -#include <LibraryI.h> - -class BookFactory : virtual public Ice::ObjectFactory -{ -public: - - BookFactory(const LibraryIPtr&); - - // - // Operations from ObjectFactory - // - virtual Ice::ObjectPtr create(const std::string&); - virtual void destroy(); - -private: - - LibraryIPtr _library; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef BOOK_FACTORY_H
+#define BOOK_FACTORY_H
+
+#include <LibraryI.h>
+
+class BookFactory : virtual public Ice::ObjectFactory
+{
+public:
+
+ BookFactory(const LibraryIPtr&);
+
+ //
+ // Operations from ObjectFactory
+ //
+ virtual Ice::ObjectPtr create(const std::string&);
+ virtual void destroy();
+
+private:
+
+ LibraryIPtr _library;
+};
+
+#endif
diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index 6271b1b73f5..0e1e37b20a4 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -57,7 +57,7 @@ BookI::getRenterName(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); - if (_rentalCustomerName.empty()) + if(_rentalCustomerName.empty()) { throw BookNotRentedException(); } @@ -69,7 +69,7 @@ BookI::rentBook(const ::std::string& name, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); - if (!_rentalCustomerName.empty()) + if(!_rentalCustomerName.empty()) { throw BookRentedException(); } @@ -81,7 +81,7 @@ BookI::returnBook(const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); - if (_rentalCustomerName.empty()) + if(_rentalCustomerName.empty()) { throw BookNotRentedException(); } @@ -174,7 +174,7 @@ LibraryI::createBook(const ::BookDescription& description, const Ice::Current&) Ice::StringSeq isbnSeq; StringIsbnSeqDict::iterator p = _authors.find(description.authors); - if (p != _authors.end()) + if(p != _authors.end()) { isbnSeq = p->second; } @@ -222,7 +222,7 @@ LibraryI::findByAuthors(const string& authors, const Ice::Current&) BookPrxSeq books; - if (p != _authors.end()) + if(p != _authors.end()) { books.reserve(p->second.size()); transform(p->second.begin(), p->second.end(), back_inserter(books), IsbnToBook(_adapter)); @@ -262,7 +262,7 @@ LibraryI::remove(const BookDescription& description) // If the title isn't found then raise a record not found // exception. // - if (p == _authors.end()) + if(p == _authors.end()) { throw Freeze::DBNotFoundException(__FILE__, __LINE__); } @@ -274,7 +274,7 @@ LibraryI::remove(const BookDescription& description) isbnSeq.erase(remove_if(isbnSeq.begin(), isbnSeq.end(), bind2nd(equal_to<string>(), description.isbn)), isbnSeq.end()); - if (isbnSeq.empty()) + if(isbnSeq.empty()) { // // If there are no further associated isbn numbers then remove diff --git a/cpp/demo/Freeze/library/LibraryI.h b/cpp/demo/Freeze/library/LibraryI.h index 88c18a97a15..3fb81d5f11d 100644 --- a/cpp/demo/Freeze/library/LibraryI.h +++ b/cpp/demo/Freeze/library/LibraryI.h @@ -1,66 +1,66 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef LIBRARY_I_H -#define LIBRARY_I_H - -#include <IceUtil/RWRecMutex.h> - -#include <Library.h> -#include <LibraryTypes.h> - -class LibraryI : public Library, public IceUtil::RWRecMutex -{ -public: - - LibraryI(const Ice::ObjectAdapterPtr&, const Freeze::DBPtr&, const Freeze::EvictorPtr&); - virtual ~LibraryI(); - - virtual ::BookPrx createBook(const ::BookDescription&, const Ice::Current&); - virtual ::BookPrx findByIsbn(const ::std::string&, const Ice::Current&); - virtual ::BookPrxSeq findByAuthors(const ::std::string&, const Ice::Current&); - virtual void setEvictorSize(::Ice::Int, const Ice::Current&); - virtual void shutdown(const Ice::Current&); - - void remove(const BookDescription&); - -private: - - Ice::ObjectAdapterPtr _adapter; - Freeze::EvictorPtr _evictor; - - // - // This is a dictionary of authors to a sequence of isbn numbers - // for efficient lookup of books by authors. - // - StringIsbnSeqDict _authors; -}; - -typedef IceUtil::Handle<LibraryI> LibraryIPtr; - -class BookI : public Book, public IceUtil::RWRecMutex -{ -public: - - BookI(const LibraryIPtr&); - virtual ~BookI(); - - virtual ::BookDescription getBookDescription(const Ice::Current&); - virtual void destroy(const Ice::Current&); - virtual void rentBook(const ::std::string&, const Ice::Current&); - virtual ::std::string getRenterName(const Ice::Current&); - virtual void returnBook(const Ice::Current&); - -private: - - LibraryIPtr _library; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef LIBRARY_I_H
+#define LIBRARY_I_H
+
+#include <IceUtil/RWRecMutex.h>
+
+#include <Library.h>
+#include <LibraryTypes.h>
+
+class LibraryI : public Library, public IceUtil::RWRecMutex
+{
+public:
+
+ LibraryI(const Ice::ObjectAdapterPtr&, const Freeze::DBPtr&, const Freeze::EvictorPtr&);
+ virtual ~LibraryI();
+
+ virtual ::BookPrx createBook(const ::BookDescription&, const Ice::Current&);
+ virtual ::BookPrx findByIsbn(const ::std::string&, const Ice::Current&);
+ virtual ::BookPrxSeq findByAuthors(const ::std::string&, const Ice::Current&);
+ virtual void setEvictorSize(::Ice::Int, const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+ void remove(const BookDescription&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+ Freeze::EvictorPtr _evictor;
+
+ //
+ // This is a dictionary of authors to a sequence of isbn numbers
+ // for efficient lookup of books by authors.
+ //
+ StringIsbnSeqDict _authors;
+};
+
+typedef IceUtil::Handle<LibraryI> LibraryIPtr;
+
+class BookI : public Book, public IceUtil::RWRecMutex
+{
+public:
+
+ BookI(const LibraryIPtr&);
+ virtual ~BookI();
+
+ virtual ::BookDescription getBookDescription(const Ice::Current&);
+ virtual void destroy(const Ice::Current&);
+ virtual void rentBook(const ::std::string&, const Ice::Current&);
+ virtual ::std::string getRenterName(const Ice::Current&);
+ virtual void returnBook(const Ice::Current&);
+
+private:
+
+ LibraryIPtr _library;
+};
+
+#endif
diff --git a/cpp/demo/Freeze/library/Parser.cpp b/cpp/demo/Freeze/library/Parser.cpp index 070c78e0666..4e378330f97 100644 --- a/cpp/demo/Freeze/library/Parser.cpp +++ b/cpp/demo/Freeze/library/Parser.cpp @@ -50,7 +50,7 @@ Parser::createParser(const CommunicatorPtr& communicator, const LibraryPrx& libr void Parser::addBook(const list<string>& _args) { - if (_args.size() != 3) + if(_args.size() != 3) { error("`add' requires at exactly three arguments (type `help' for more info)"); return; @@ -89,7 +89,7 @@ Parser::addBook(const list<string>& _args) void Parser::findIsbn(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`isbn' requires exactly one argument (type `help' for more info)"); return; @@ -101,7 +101,7 @@ Parser::findIsbn(const list<string>& args) _current = _foundBooks.begin(); BookPrx book = _library->findByIsbn(args.front()); - if (!book) + if(!book) { cout << "no book with that ISBN number exists." << endl; } @@ -127,7 +127,7 @@ Parser::findIsbn(const list<string>& args) void Parser::findAuthors(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`authors' requires exactly one argument (type `help' for more info)"); return; @@ -155,7 +155,7 @@ Parser::findAuthors(const list<string>& args) void Parser::nextFoundBook() { - if (_current != _foundBooks.end()) + if(_current != _foundBooks.end()) { ++_current; } @@ -167,7 +167,7 @@ Parser::printCurrent() { try { - if (_current != _foundBooks.end()) + if(_current != _foundBooks.end()) { BookDescription desc = (*_current)->getBookDescription(); string renter; @@ -183,7 +183,7 @@ Parser::printCurrent() cout << "isbn: " << desc.isbn << endl; cout << "title: " << desc.title << endl; cout << "authors: " << desc.authors << endl; - if (!renter.empty()) + if(!renter.empty()) { cout << "rented: " << renter << endl; } @@ -204,7 +204,7 @@ Parser::printCurrent() void Parser::rentCurrent(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`rent' requires exactly one argument (type `help' for more info)"); return; @@ -212,7 +212,7 @@ Parser::rentCurrent(const list<string>& args) try { - if (_current != _foundBooks.end()) + if(_current != _foundBooks.end()) { (*_current)->rentBook(args.front()); cout << "the book is now rented by `" << args.front() << "'" << endl; @@ -243,7 +243,7 @@ Parser::returnCurrent() { try { - if (_current != _foundBooks.end()) + if(_current != _foundBooks.end()) { (*_current)->returnBook(); cout << "the book has been returned." << endl; @@ -274,7 +274,7 @@ Parser::removeCurrent() { try { - if (_current != _foundBooks.end()) + if(_current != _foundBooks.end()) { (*_current)->destroy(); cout << "removed current book" << endl; @@ -299,7 +299,7 @@ Parser::removeCurrent() void Parser::setEvictorSize(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`size' requires exactly one argument (type `help' for more info)"); return; @@ -339,9 +339,9 @@ Parser::shutdown() void Parser::getInput(char* buf, int& result, int maxSize) { - if (!_commands.empty()) + if(!_commands.empty()) { - if (_commands == ";") + if(_commands == ";") { result = 0; } @@ -355,30 +355,30 @@ Parser::getInput(char* buf, int& result, int maxSize) #endif strncpy(buf, _commands.c_str(), result); _commands.erase(0, result); - if (_commands.empty()) + if(_commands.empty()) { _commands = ";"; } } } - else if (isatty(fileno(yyin))) + else if(isatty(fileno(yyin))) { #ifdef HAVE_READLINE char* line = readline(parser->getPrompt()); - if (!line) + if(!line) { result = 0; } else { - if (*line) + if(*line) { add_history(line); } result = strlen(line) + 1; - if (result > maxSize) + if(result > maxSize) { free(line); error("input line too long"); @@ -397,12 +397,12 @@ Parser::getInput(char* buf, int& result, int maxSize) cout << parser->getPrompt() << flush; string line; - while (true) + while(true) { char c = static_cast<char>(getc(yyin)); - if (c == EOF) + if(c == EOF) { - if (line.size()) + if(line.size()) { line += '\n'; } @@ -411,14 +411,14 @@ Parser::getInput(char* buf, int& result, int maxSize) line += c; - if (c == '\n') + if(c == '\n') { break; } } result = line.length(); - if (result > maxSize) + if(result > maxSize) { error("input line too long"); buf[0] = EOF; @@ -433,7 +433,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } else { - if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; @@ -459,7 +459,7 @@ Parser::getPrompt() { assert(_commands.empty() && isatty(fileno(yyin))); - if (_continue) + if(_continue) { _continue = false; return "(cont) "; @@ -473,7 +473,7 @@ Parser::getPrompt() void Parser::error(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } @@ -493,7 +493,7 @@ Parser::error(const string& s) void Parser::warning(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } @@ -532,7 +532,7 @@ Parser::parse(FILE* file, bool debug) _current = _foundBooks.end(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } @@ -564,7 +564,7 @@ Parser::parse(const string& commands, bool debug) _current = _foundBooks.end(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } diff --git a/cpp/demo/Freeze/library/Parser.h b/cpp/demo/Freeze/library/Parser.h index fa074055cd1..ed19c1bee69 100644 --- a/cpp/demo/Freeze/library/Parser.h +++ b/cpp/demo/Freeze/library/Parser.h @@ -1,106 +1,106 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef PARSER_H -#define PARSER_H - -#include <IceUtil/Handle.h> -#include <Ice/Ice.h> -#include <Library.h> -#include <list> - -#ifdef _WIN32 -# include <io.h> -# define isatty _isatty -# define fileno _fileno -// '_isatty' : inconsistent dll linkage. dllexport assumed. -# pragma warning( disable : 4273 ) -#endif - -// -// Stuff for flex and bison -// - -#define YYSTYPE std::list<std::string> -#define YY_DECL int yylex(YYSTYPE* yylvalp) -YY_DECL; -int yyparse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) yyerror(a) - -class Parser; -typedef ::IceUtil::Handle<Parser> ParserPtr; - -class Parser : public ::IceUtil::SimpleShared -{ -public: - - static ParserPtr createParser(const Ice::CommunicatorPtr&, const LibraryPrx&); - - void usage(); - - void addBook(const std::list<std::string>&); - void findIsbn(const std::list<std::string>&); - void findAuthors(const std::list<std::string>&); - void nextFoundBook(); - void printCurrent(); - void rentCurrent(const std::list<std::string>&); - void returnCurrent(); - void removeCurrent(); - void setEvictorSize(const std::list<std::string>&); - void shutdown(); - - void getInput(char*, int&, int); - void nextLine(); - void continueLine(); - char* getPrompt(); - - void error(const char*); - void error(const std::string&); - - void warning(const char*); - void warning(const std::string&); - - int parse(FILE*, bool); - int parse(const std::string&, bool); - -private: - - Parser(const Ice::CommunicatorPtr&, const LibraryPrx&); - - BookPrxSeq _foundBooks; - BookPrxSeq::iterator _current; - - std::string _commands; - Ice::CommunicatorPtr _communicator; - LibraryPrx _library; - bool _continue; - int _errors; - int _currentLine; - std::string _currentFile; -}; - -extern Parser* parser; // The current parser for bison/flex - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <IceUtil/Handle.h>
+#include <Ice/Ice.h>
+#include <Library.h>
+#include <list>
+
+#ifdef _WIN32
+# include <io.h>
+# define isatty _isatty
+# define fileno _fileno
+// '_isatty' : inconsistent dll linkage. dllexport assumed.
+# pragma warning( disable : 4273 )
+#endif
+
+//
+// Stuff for flex and bison
+//
+
+#define YYSTYPE std::list<std::string>
+#define YY_DECL int yylex(YYSTYPE* yylvalp)
+YY_DECL;
+int yyparse();
+
+//
+// I must set the initial stack depth to the maximum stack depth to
+// disable bison stack resizing. The bison stack resizing routines use
+// simple malloc/alloc/memcpy calls, which do not work for the
+// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
+// assignment operator, etc.
+//
+#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum.
+#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
+
+//
+// Newer bison versions allow to disable stack resizing by defining
+// yyoverflow.
+//
+#define yyoverflow(a, b, c, d, e, f) yyerror(a)
+
+class Parser;
+typedef ::IceUtil::Handle<Parser> ParserPtr;
+
+class Parser : public ::IceUtil::SimpleShared
+{
+public:
+
+ static ParserPtr createParser(const Ice::CommunicatorPtr&, const LibraryPrx&);
+
+ void usage();
+
+ void addBook(const std::list<std::string>&);
+ void findIsbn(const std::list<std::string>&);
+ void findAuthors(const std::list<std::string>&);
+ void nextFoundBook();
+ void printCurrent();
+ void rentCurrent(const std::list<std::string>&);
+ void returnCurrent();
+ void removeCurrent();
+ void setEvictorSize(const std::list<std::string>&);
+ void shutdown();
+
+ void getInput(char*, int&, int);
+ void nextLine();
+ void continueLine();
+ char* getPrompt();
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void warning(const char*);
+ void warning(const std::string&);
+
+ int parse(FILE*, bool);
+ int parse(const std::string&, bool);
+
+private:
+
+ Parser(const Ice::CommunicatorPtr&, const LibraryPrx&);
+
+ BookPrxSeq _foundBooks;
+ BookPrxSeq::iterator _current;
+
+ std::string _commands;
+ Ice::CommunicatorPtr _communicator;
+ LibraryPrx _library;
+ bool _continue;
+ int _errors;
+ int _currentLine;
+ std::string _currentFile;
+};
+
+extern Parser* parser; // The current parser for bison/flex
+
+#endif
diff --git a/cpp/demo/Freeze/library/RunParser.cpp b/cpp/demo/Freeze/library/RunParser.cpp index 816753bb4a2..848872382ce 100644 --- a/cpp/demo/Freeze/library/RunParser.cpp +++ b/cpp/demo/Freeze/library/RunParser.cpp @@ -33,21 +33,21 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) bool debug = false; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-e") == 0) + else if(strcmp(argv[idx], "-e") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -57,22 +57,22 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) commands += argv[idx + 1]; commands += ';'; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -84,7 +84,7 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } } - if (argc >= 2 && !commands.empty()) + if(argc >= 2 && !commands.empty()) { cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl; usage(argv[0]); @@ -94,7 +94,7 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); const char* refProperty = "Library.Library"; string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -102,7 +102,7 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::ObjectPrx base = communicator->stringToProxy(ref); LibraryPrx phoneBook = LibraryPrx::checkedCast(base); - if (!phoneBook) + if(!phoneBook) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -111,12 +111,12 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) ParserPtr parser = Parser::createParser(communicator, phoneBook); int status = EXIT_SUCCESS; - if (argc < 2) // No files given + if(argc < 2) // No files given { - if (!commands.empty()) // Commands were given + if(!commands.empty()) // Commands were given { int parseStatus = parser->parse(commands, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -124,7 +124,7 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) else // No commands, let's use standard input { int parseStatus = parser->parse(stdin, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -132,10 +132,10 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } else // Process files given on the command line { - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { FILE* file = fopen(argv[idx], "r"); - if (file == NULL) + if(file == NULL) { cerr << argv[0] << ": can't open file `" << argv[idx] << "': " << strerror(errno) << endl; return EXIT_FAILURE; @@ -145,7 +145,7 @@ runParser(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) fclose(file); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } diff --git a/cpp/demo/Freeze/library/dummyinclude/unistd.h b/cpp/demo/Freeze/library/dummyinclude/unistd.h index 92d53d10b9b..a5868056a35 100644 --- a/cpp/demo/Freeze/library/dummyinclude/unistd.h +++ b/cpp/demo/Freeze/library/dummyinclude/unistd.h @@ -1,4 +1,4 @@ -// -// Files generated by flex need unistd.h, which is not available on -// Windows. Thus this dummy file. -// +//
+// Files generated by flex need unistd.h, which is not available on
+// Windows. Thus this dummy file.
+//
diff --git a/cpp/demo/Freeze/phonebook/ContactFactory.h b/cpp/demo/Freeze/phonebook/ContactFactory.h index e1def9780b1..0cb42282a07 100644 --- a/cpp/demo/Freeze/phonebook/ContactFactory.h +++ b/cpp/demo/Freeze/phonebook/ContactFactory.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef CONTACT_FACTORY_H -#define CONTACT_FACTORY_H - -#include <PhoneBookI.h> - -class ContactFactory : virtual public Ice::ObjectFactory, virtual public Freeze::ServantInitializer -{ -public: - - ContactFactory(const PhoneBookIPtr&, const Freeze::EvictorPtr&); - - // - // Operations from ObjectFactory - // - virtual Ice::ObjectPtr create(const std::string&); - virtual void destroy(); - - // - // Operations from ServantInitializer - // - virtual void initialize(const Ice::ObjectAdapterPtr&, const Ice::Identity&, const Ice::ObjectPtr&); - -private: - - PhoneBookIPtr _phoneBook; - Freeze::EvictorPtr _evictor; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef CONTACT_FACTORY_H
+#define CONTACT_FACTORY_H
+
+#include <PhoneBookI.h>
+
+class ContactFactory : virtual public Ice::ObjectFactory, virtual public Freeze::ServantInitializer
+{
+public:
+
+ ContactFactory(const PhoneBookIPtr&, const Freeze::EvictorPtr&);
+
+ //
+ // Operations from ObjectFactory
+ //
+ virtual Ice::ObjectPtr create(const std::string&);
+ virtual void destroy();
+
+ //
+ // Operations from ServantInitializer
+ //
+ virtual void initialize(const Ice::ObjectAdapterPtr&, const Ice::Identity&, const Ice::ObjectPtr&);
+
+private:
+
+ PhoneBookIPtr _phoneBook;
+ Freeze::EvictorPtr _evictor;
+};
+
+#endif
diff --git a/cpp/demo/Freeze/phonebook/Parser.cpp b/cpp/demo/Freeze/phonebook/Parser.cpp index a8f21a0410a..33239338af8 100644 --- a/cpp/demo/Freeze/phonebook/Parser.cpp +++ b/cpp/demo/Freeze/phonebook/Parser.cpp @@ -51,7 +51,7 @@ Parser::createParser(const CommunicatorPtr& communicator, const PhoneBookPrx& ph void Parser::addContacts(const list<string>& args) { - if (args.empty()) + if(args.empty()) { error("`add' requires at least one argument (type `help' for more info)"); return; @@ -81,7 +81,7 @@ Parser::addContacts(const list<string>& args) void Parser::findContacts(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`find' requires exactly one argument (type `help' for more info)"); return; @@ -109,7 +109,7 @@ Parser::findContacts(const list<string>& args) void Parser::nextFoundContact() { - if (_current != _foundContacts.end()) + if(_current != _foundContacts.end()) { ++_current; } @@ -121,7 +121,7 @@ Parser::printCurrent() { try { - if (_current != _foundContacts.end()) + if(_current != _foundContacts.end()) { cout << "current contact is:" << endl; cout << "name: " << (*_current)->getName() << endl; @@ -148,7 +148,7 @@ Parser::printCurrent() void Parser::setCurrentName(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`name' requires exactly one argument (type `help' for more info)"); return; @@ -156,7 +156,7 @@ Parser::setCurrentName(const list<string>& args) try { - if (_current != _foundContacts.end()) + if(_current != _foundContacts.end()) { (*_current)->setName(args.front()); cout << "changed name to `" << args.front() << "'" << endl; @@ -181,7 +181,7 @@ Parser::setCurrentName(const list<string>& args) void Parser::setCurrentAddress(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`address' requires exactly one argument (type `help' for more info)"); return; @@ -189,7 +189,7 @@ Parser::setCurrentAddress(const list<string>& args) try { - if (_current != _foundContacts.end()) + if(_current != _foundContacts.end()) { (*_current)->setAddress(args.front()); cout << "changed address to `" << args.front() << "'" << endl; @@ -214,7 +214,7 @@ Parser::setCurrentAddress(const list<string>& args) void Parser::setCurrentPhone(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`phone' requires exactly one argument (type `help' for more info)"); return; @@ -222,7 +222,7 @@ Parser::setCurrentPhone(const list<string>& args) try { - if (_current != _foundContacts.end()) + if(_current != _foundContacts.end()) { (*_current)->setPhone(args.front()); cout << "changed phone number to `" << args.front() << "'" << endl; @@ -249,7 +249,7 @@ Parser::removeCurrent() { try { - if (_current != _foundContacts.end()) + if(_current != _foundContacts.end()) { (*_current)->destroy(); cout << "removed current contact" << endl; @@ -274,7 +274,7 @@ Parser::removeCurrent() void Parser::setEvictorSize(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`size' requires exactly one argument (type `help' for more info)"); return; @@ -314,9 +314,9 @@ Parser::shutdown() void Parser::getInput(char* buf, int& result, int maxSize) { - if (!_commands.empty()) + if(!_commands.empty()) { - if (_commands == ";") + if(_commands == ";") { result = 0; } @@ -330,30 +330,30 @@ Parser::getInput(char* buf, int& result, int maxSize) #endif strncpy(buf, _commands.c_str(), result); _commands.erase(0, result); - if (_commands.empty()) + if(_commands.empty()) { _commands = ";"; } } } - else if (isatty(fileno(yyin))) + else if(isatty(fileno(yyin))) { #ifdef HAVE_READLINE char* line = readline(parser->getPrompt()); - if (!line) + if(!line) { result = 0; } else { - if (*line) + if(*line) { add_history(line); } result = strlen(line) + 1; - if (result > maxSize) + if(result > maxSize) { free(line); error("input line too long"); @@ -372,12 +372,12 @@ Parser::getInput(char* buf, int& result, int maxSize) cout << parser->getPrompt() << flush; string line; - while (true) + while(true) { char c = static_cast<char>(getc(yyin)); - if (c == EOF) + if(c == EOF) { - if (line.size()) + if(line.size()) { line += '\n'; } @@ -386,14 +386,14 @@ Parser::getInput(char* buf, int& result, int maxSize) line += c; - if (c == '\n') + if(c == '\n') { break; } } result = line.length(); - if (result > maxSize) + if(result > maxSize) { error("input line too long"); buf[0] = EOF; @@ -408,7 +408,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } else { - if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; @@ -434,7 +434,7 @@ Parser::getPrompt() { assert(_commands.empty() && isatty(fileno(yyin))); - if (_continue) + if(_continue) { _continue = false; return "(cont) "; @@ -448,7 +448,7 @@ Parser::getPrompt() void Parser::error(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } @@ -468,7 +468,7 @@ Parser::error(const string& s) void Parser::warning(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } @@ -507,7 +507,7 @@ Parser::parse(FILE* file, bool debug) _current = _foundContacts.end(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } @@ -539,7 +539,7 @@ Parser::parse(const string& commands, bool debug) _current = _foundContacts.end(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } diff --git a/cpp/demo/Freeze/phonebook/Parser.h b/cpp/demo/Freeze/phonebook/Parser.h index 56fbc5b7456..9e53fb9d450 100644 --- a/cpp/demo/Freeze/phonebook/Parser.h +++ b/cpp/demo/Freeze/phonebook/Parser.h @@ -1,106 +1,106 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef PARSER_H -#define PARSER_H - -#include <IceUtil/Handle.h> -#include <Ice/Ice.h> -#include <PhoneBook.h> -#include <list> - -#ifdef _WIN32 -# include <io.h> -# define isatty _isatty -# define fileno _fileno -// '_isatty' : inconsistent dll linkage. dllexport assumed. -# pragma warning( disable : 4273 ) -#endif - -// -// Stuff for flex and bison -// - -#define YYSTYPE std::list<std::string> -#define YY_DECL int yylex(YYSTYPE* yylvalp) -YY_DECL; -int yyparse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) yyerror(a) - -class Parser; -typedef ::IceUtil::Handle<Parser> ParserPtr; - -class Parser : public ::IceUtil::SimpleShared -{ -public: - - static ParserPtr createParser(const Ice::CommunicatorPtr&, const PhoneBookPrx&); - - void usage(); - - void addContacts(const std::list<std::string>&); - void findContacts(const std::list<std::string>&); - void nextFoundContact(); - void printCurrent(); - void setCurrentName(const std::list<std::string>&); - void setCurrentAddress(const std::list<std::string>&); - void setCurrentPhone(const std::list<std::string>&); - void removeCurrent(); - void setEvictorSize(const std::list<std::string>&); - void shutdown(); - - void getInput(char*, int&, int); - void nextLine(); - void continueLine(); - char* getPrompt(); - - void error(const char*); - void error(const std::string&); - - void warning(const char*); - void warning(const std::string&); - - int parse(FILE*, bool); - int parse(const std::string&, bool); - -private: - - Parser(const Ice::CommunicatorPtr&, const PhoneBookPrx&); - - Contacts _foundContacts; - Contacts::iterator _current; - - std::string _commands; - Ice::CommunicatorPtr _communicator; - PhoneBookPrx _phoneBook; - bool _continue; - int _errors; - int _currentLine; - std::string _currentFile; -}; - -extern Parser* parser; // The current parser for bison/flex - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <IceUtil/Handle.h>
+#include <Ice/Ice.h>
+#include <PhoneBook.h>
+#include <list>
+
+#ifdef _WIN32
+# include <io.h>
+# define isatty _isatty
+# define fileno _fileno
+// '_isatty' : inconsistent dll linkage. dllexport assumed.
+# pragma warning( disable : 4273 )
+#endif
+
+//
+// Stuff for flex and bison
+//
+
+#define YYSTYPE std::list<std::string>
+#define YY_DECL int yylex(YYSTYPE* yylvalp)
+YY_DECL;
+int yyparse();
+
+//
+// I must set the initial stack depth to the maximum stack depth to
+// disable bison stack resizing. The bison stack resizing routines use
+// simple malloc/alloc/memcpy calls, which do not work for the
+// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
+// assignment operator, etc.
+//
+#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum.
+#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
+
+//
+// Newer bison versions allow to disable stack resizing by defining
+// yyoverflow.
+//
+#define yyoverflow(a, b, c, d, e, f) yyerror(a)
+
+class Parser;
+typedef ::IceUtil::Handle<Parser> ParserPtr;
+
+class Parser : public ::IceUtil::SimpleShared
+{
+public:
+
+ static ParserPtr createParser(const Ice::CommunicatorPtr&, const PhoneBookPrx&);
+
+ void usage();
+
+ void addContacts(const std::list<std::string>&);
+ void findContacts(const std::list<std::string>&);
+ void nextFoundContact();
+ void printCurrent();
+ void setCurrentName(const std::list<std::string>&);
+ void setCurrentAddress(const std::list<std::string>&);
+ void setCurrentPhone(const std::list<std::string>&);
+ void removeCurrent();
+ void setEvictorSize(const std::list<std::string>&);
+ void shutdown();
+
+ void getInput(char*, int&, int);
+ void nextLine();
+ void continueLine();
+ char* getPrompt();
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void warning(const char*);
+ void warning(const std::string&);
+
+ int parse(FILE*, bool);
+ int parse(const std::string&, bool);
+
+private:
+
+ Parser(const Ice::CommunicatorPtr&, const PhoneBookPrx&);
+
+ Contacts _foundContacts;
+ Contacts::iterator _current;
+
+ std::string _commands;
+ Ice::CommunicatorPtr _communicator;
+ PhoneBookPrx _phoneBook;
+ bool _continue;
+ int _errors;
+ int _currentLine;
+ std::string _currentFile;
+};
+
+extern Parser* parser; // The current parser for bison/flex
+
+#endif
diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp index 1e472fa0c99..b6ff1bf645d 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp @@ -162,7 +162,7 @@ PhoneBookI::createContact(const Ice::Current&) { NameIdentitiesDict::iterator p = _nameIdentitiesDict.find("N"); Identities identities; - if (p != _nameIdentitiesDict.end()) + if(p != _nameIdentitiesDict.end()) { identities = p->second; } @@ -198,7 +198,7 @@ PhoneBookI::findContacts(const string& name, const Ice::Current&) // NameIdentitiesDict::iterator p = _nameIdentitiesDict.find("N" + name); Identities identities; - if (p != _nameIdentitiesDict.end()) + if(p != _nameIdentitiesDict.end()) { identities = p->second; } @@ -266,7 +266,7 @@ PhoneBookI::move(const Identity& ident, const string& oldName, const string& new removeI(ident, oldName); NameIdentitiesDict::iterator p = _nameIdentitiesDict.find("N" + newName); Identities identities; - if (p != _nameIdentitiesDict.end()) + if(p != _nameIdentitiesDict.end()) { identities = p->second; } @@ -307,7 +307,7 @@ PhoneBookI::getNewIdentity() Ice::Long n; Identities ids; NameIdentitiesDict::iterator p = _nameIdentitiesDict.find("ID"); - if (p == _nameIdentitiesDict.end()) + if(p == _nameIdentitiesDict.end()) { n = 0; } @@ -365,7 +365,7 @@ PhoneBookI::removeI(const Identity& ident, const string& name) // If the name isn't found then raise a record not found // exception. // - if (p == _nameIdentitiesDict.end()) + if(p == _nameIdentitiesDict.end()) { throw Freeze::DBNotFoundException(__FILE__, __LINE__); } @@ -374,7 +374,7 @@ PhoneBookI::removeI(const Identity& ident, const string& name) identities.erase(remove_if(identities.begin(), identities.end(), bind2nd(equal_to<Ice::Identity>(), ident)), identities.end()); - if (identities.empty()) + if(identities.empty()) { _nameIdentitiesDict.erase(p); } diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.h b/cpp/demo/Freeze/phonebook/PhoneBookI.h index bb341a7b94a..fa387c15a8d 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.h +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.h @@ -1,77 +1,77 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef PHONE_BOOK_I_H -#define PHONE_BOOK_I_H - -#include <IceUtil/IceUtil.h> -#include <Ice/Ice.h> -#include <Freeze/Freeze.h> -#include <PhoneBook.h> -#include <NameIdentitiesDict.h> - -class PhoneBookI; -typedef IceUtil::Handle<PhoneBookI> PhoneBookIPtr; - -class ContactI; -typedef IceUtil::Handle<ContactI> ContactIPtr; - -class ContactI : public Contact, public IceUtil::RWRecMutex -{ -public: - - ContactI(const PhoneBookIPtr&, const Freeze::EvictorPtr&); - - void setIdentity(const Ice::Identity&); - - virtual std::string getName(const Ice::Current&); - virtual void setName(const std::string&, const Ice::Current&); - - virtual std::string getAddress(const Ice::Current&); - virtual void setAddress(const std::string&, const Ice::Current&); - - virtual std::string getPhone(const Ice::Current&); - virtual void setPhone(const std::string&, const Ice::Current&); - - virtual void destroy(const Ice::Current&); - -private: - - PhoneBookIPtr _phoneBook; - Freeze::EvictorPtr _evictor; - Ice::Identity _identity; -}; - -class PhoneBookI : public PhoneBook, public IceUtil::RWRecMutex -{ -public: - - PhoneBookI(const Ice::ObjectAdapterPtr&, const Freeze::DBPtr&, const Freeze::EvictorPtr&); - - virtual ContactPrx createContact(const Ice::Current&); - virtual Contacts findContacts(const std::string&, const Ice::Current&); - virtual void setEvictorSize(Ice::Int, const Ice::Current&); - virtual void shutdown(const Ice::Current&); - - void remove(const Ice::Identity&, const std::string&); - void move(const Ice::Identity&, const std::string&, const std::string&); - Ice::Identity getNewIdentity(); - -private: - - void removeI(const Ice::Identity&, const std::string&); - - Ice::ObjectAdapterPtr _adapter; - Freeze::DBPtr _db; - Freeze::EvictorPtr _evictor; - NameIdentitiesDict _nameIdentitiesDict; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef PHONE_BOOK_I_H
+#define PHONE_BOOK_I_H
+
+#include <IceUtil/IceUtil.h>
+#include <Ice/Ice.h>
+#include <Freeze/Freeze.h>
+#include <PhoneBook.h>
+#include <NameIdentitiesDict.h>
+
+class PhoneBookI;
+typedef IceUtil::Handle<PhoneBookI> PhoneBookIPtr;
+
+class ContactI;
+typedef IceUtil::Handle<ContactI> ContactIPtr;
+
+class ContactI : public Contact, public IceUtil::RWRecMutex
+{
+public:
+
+ ContactI(const PhoneBookIPtr&, const Freeze::EvictorPtr&);
+
+ void setIdentity(const Ice::Identity&);
+
+ virtual std::string getName(const Ice::Current&);
+ virtual void setName(const std::string&, const Ice::Current&);
+
+ virtual std::string getAddress(const Ice::Current&);
+ virtual void setAddress(const std::string&, const Ice::Current&);
+
+ virtual std::string getPhone(const Ice::Current&);
+ virtual void setPhone(const std::string&, const Ice::Current&);
+
+ virtual void destroy(const Ice::Current&);
+
+private:
+
+ PhoneBookIPtr _phoneBook;
+ Freeze::EvictorPtr _evictor;
+ Ice::Identity _identity;
+};
+
+class PhoneBookI : public PhoneBook, public IceUtil::RWRecMutex
+{
+public:
+
+ PhoneBookI(const Ice::ObjectAdapterPtr&, const Freeze::DBPtr&, const Freeze::EvictorPtr&);
+
+ virtual ContactPrx createContact(const Ice::Current&);
+ virtual Contacts findContacts(const std::string&, const Ice::Current&);
+ virtual void setEvictorSize(Ice::Int, const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+ void remove(const Ice::Identity&, const std::string&);
+ void move(const Ice::Identity&, const std::string&, const std::string&);
+ Ice::Identity getNewIdentity();
+
+private:
+
+ void removeI(const Ice::Identity&, const std::string&);
+
+ Ice::ObjectAdapterPtr _adapter;
+ Freeze::DBPtr _db;
+ Freeze::EvictorPtr _evictor;
+ NameIdentitiesDict _nameIdentitiesDict;
+};
+
+#endif
diff --git a/cpp/demo/Freeze/phonebook/RunParser.cpp b/cpp/demo/Freeze/phonebook/RunParser.cpp index bb69f419317..fc8a1ada60d 100644 --- a/cpp/demo/Freeze/phonebook/RunParser.cpp +++ b/cpp/demo/Freeze/phonebook/RunParser.cpp @@ -34,21 +34,21 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) bool debug = false; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-e") == 0) + else if(strcmp(argv[idx], "-e") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -58,22 +58,22 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) commands += argv[idx + 1]; commands += ';'; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -85,7 +85,7 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) } } - if (argc >= 2 && !commands.empty()) + if(argc >= 2 && !commands.empty()) { cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl; usage(argv[0]); @@ -95,7 +95,7 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) PropertiesPtr properties = communicator->getProperties(); const char* refProperty = "PhoneBook.PhoneBook"; string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -103,7 +103,7 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) ObjectPrx base = communicator->stringToProxy(ref); PhoneBookPrx phoneBook = PhoneBookPrx::checkedCast(base); - if (!phoneBook) + if(!phoneBook) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -112,12 +112,12 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) ParserPtr parser = Parser::createParser(communicator, phoneBook); int status = EXIT_SUCCESS; - if (argc < 2) // No files given + if(argc < 2) // No files given { - if (!commands.empty()) // Commands were given + if(!commands.empty()) // Commands were given { int parseStatus = parser->parse(commands, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -125,7 +125,7 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) else // No commands, let's use standard input { int parseStatus = parser->parse(stdin, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -133,10 +133,10 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) } else // Process files given on the command line { - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { FILE* file = fopen(argv[idx], "r"); - if (file == NULL) + if(file == NULL) { cerr << argv[0] << ": can't open file `" << argv[idx] << "': " << strerror(errno) << endl; return EXIT_FAILURE; @@ -146,7 +146,7 @@ runParser(int argc, char* argv[], const CommunicatorPtr& communicator) fclose(file); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } diff --git a/cpp/demo/Freeze/phonebook/dummyinclude/unistd.h b/cpp/demo/Freeze/phonebook/dummyinclude/unistd.h index 92d53d10b9b..a5868056a35 100644 --- a/cpp/demo/Freeze/phonebook/dummyinclude/unistd.h +++ b/cpp/demo/Freeze/phonebook/dummyinclude/unistd.h @@ -1,4 +1,4 @@ -// -// Files generated by flex need unistd.h, which is not available on -// Windows. Thus this dummy file. -// +//
+// Files generated by flex need unistd.h, which is not available on
+// Windows. Thus this dummy file.
+//
diff --git a/cpp/demo/Glacier/session/Client.cpp b/cpp/demo/Glacier/session/Client.cpp index 163ef3033a1..e45edb20196 100644 --- a/cpp/demo/Glacier/session/Client.cpp +++ b/cpp/demo/Glacier/session/Client.cpp @@ -46,7 +46,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) assert (!glacierStarterEndpoints.empty()); Ice::ObjectPrx starterBase = communicator->stringToProxy("Glacier/starter:" + glacierStarterEndpoints); Glacier::StarterPrx starter = Glacier::StarterPrx::checkedCast(starterBase); - if (!starter) + if(!starter) { cerr << argv[0] << ": endpoints `" << glacierStarterEndpoints << "' do not refer to a glacier router starter" << endl; @@ -61,7 +61,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) string id; string pw; - while (true) + while(true) { cout << "user id: " << flush; cin >> id; @@ -114,7 +114,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) HelloSessionPrx base = HelloSessionPrx::checkedCast(session); HelloSessionPrx twoway = HelloSessionPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); - if (!twoway) + if(!twoway) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -136,34 +136,34 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { cout << "==> "; cin >> c; - if (c == 't') + if(c == 't') { twoway->hello(); } - else if (c == 'o') + else if(c == 'o') { oneway->hello(); } - else if (c == 'O') + else if(c == 'O') { batchOneway->hello(); } - else if (c == 'd') + else if(c == 'd') { datagram->hello(); } - else if (c == 'D') + else if(c == 'D') { batchDatagram->hello(); } - else if (c == 'f') + else if(c == 'f') { batchOneway->ice_flush(); batchDatagram->ice_flush(); } - else if (c == 'T') + else if(c == 'T') { - if (timeout == -1) + if(timeout == -1) { timeout = 2000; } @@ -176,7 +176,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) oneway = HelloSessionPrx::uncheckedCast(oneway->ice_timeout(timeout)); batchOneway = HelloSessionPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); - if (timeout == -1) + if(timeout == -1) { cout << "timeout is now switched off" << endl; } @@ -185,7 +185,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cout << "timeout is now set to 2000ms" << endl; } } - else if (c == 'S') + else if(c == 'S') { secure = !secure; @@ -195,7 +195,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) datagram = HelloSessionPrx::uncheckedCast(datagram->ice_secure(secure)); batchDatagram = HelloSessionPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - if (secure) + if(secure) { cout << "secure mode is now on" << endl; } @@ -204,11 +204,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cout << "secure mode is now off" << endl; } } - else if (c == 'x') + else if(c == 'x') { // Nothing to do } - else if (c == '?') + else if(c == '?') { menu(); } @@ -223,7 +223,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cerr << ex << endl; } } - while (cin.good() && c != 'x'); + while(cin.good() && c != 'x'); // // Shutdown the router. @@ -252,7 +252,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Glacier/session/HelloSessionI.h b/cpp/demo/Glacier/session/HelloSessionI.h index 0638969f6ab..a270e50a472 100644 --- a/cpp/demo/Glacier/session/HelloSessionI.h +++ b/cpp/demo/Glacier/session/HelloSessionI.h @@ -1,48 +1,48 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef HELLO_SESSION_I_H -#define HELLO_SESSION_I_H - -#include <Glacier/SessionManager.h> -#include <HelloSession.h> - -class HelloSessionManagerI : public Glacier::SessionManager -{ -public: - - HelloSessionManagerI(const Ice::ObjectAdapterPtr&); - - virtual Glacier::SessionPrx create(const ::std::string&, const Ice::Current&); - - void remove(const Ice::Identity&); - -private: - - Ice::ObjectAdapterPtr _adapter; -}; -typedef IceUtil::Handle<HelloSessionManagerI> HelloSessionManagerIPtr; - -class HelloSessionI : public HelloSession -{ -public: - - HelloSessionI(const ::std::string&, const HelloSessionManagerIPtr&); - - virtual void destroy(const Ice::Current&); - virtual void hello(const Ice::Current&); - -private: - - ::std::string _userId; - HelloSessionManagerIPtr _manager; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef HELLO_SESSION_I_H
+#define HELLO_SESSION_I_H
+
+#include <Glacier/SessionManager.h>
+#include <HelloSession.h>
+
+class HelloSessionManagerI : public Glacier::SessionManager
+{
+public:
+
+ HelloSessionManagerI(const Ice::ObjectAdapterPtr&);
+
+ virtual Glacier::SessionPrx create(const ::std::string&, const Ice::Current&);
+
+ void remove(const Ice::Identity&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+};
+typedef IceUtil::Handle<HelloSessionManagerI> HelloSessionManagerIPtr;
+
+class HelloSessionI : public HelloSession
+{
+public:
+
+ HelloSessionI(const ::std::string&, const HelloSessionManagerIPtr&);
+
+ virtual void destroy(const Ice::Current&);
+ virtual void hello(const Ice::Current&);
+
+private:
+
+ ::std::string _userId;
+ HelloSessionManagerIPtr _manager;
+};
+
+#endif
diff --git a/cpp/demo/Glacier/session/Server.cpp b/cpp/demo/Glacier/session/Server.cpp index fdff2f5c96f..5660e5a809d 100644 --- a/cpp/demo/Glacier/session/Server.cpp +++ b/cpp/demo/Glacier/session/Server.cpp @@ -75,7 +75,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/callback/CallbackI.h b/cpp/demo/Ice/callback/CallbackI.h index 72a1dfbe7e2..30359a00f92 100644 --- a/cpp/demo/Ice/callback/CallbackI.h +++ b/cpp/demo/Ice/callback/CallbackI.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef CALLBACK_I_H -#define CALLBACK_I_H - -#include <Callback.h> - -class CallbackReceiverI : public CallbackReceiver -{ -public: - - virtual void callback(const Ice::Current&); -}; - -class CallbackI : public Callback -{ -public: - - CallbackI(const Ice::CommunicatorPtr&); - - virtual void initiateCallback(const CallbackReceiverPrx&, const Ice::Current&); - virtual void shutdown(const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef CALLBACK_I_H
+#define CALLBACK_I_H
+
+#include <Callback.h>
+
+class CallbackReceiverI : public CallbackReceiver
+{
+public:
+
+ virtual void callback(const Ice::Current&);
+};
+
+class CallbackI : public Callback
+{
+public:
+
+ CallbackI(const Ice::CommunicatorPtr&);
+
+ virtual void initiateCallback(const CallbackReceiverPrx&, const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+};
+
+#endif
diff --git a/cpp/demo/Ice/callback/Client.cpp b/cpp/demo/Ice/callback/Client.cpp index 0a895a39840..c5f1e726317 100644 --- a/cpp/demo/Ice/callback/Client.cpp +++ b/cpp/demo/Ice/callback/Client.cpp @@ -52,7 +52,7 @@ CallbackClient::run(int argc, char* argv[]) PropertiesPtr properties = communicator()->getProperties(); const char* refProperty = "Callback.Callback"; std::string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << appName() << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -60,7 +60,7 @@ CallbackClient::run(int argc, char* argv[]) ObjectPrx base = communicator()->stringToProxy(ref); CallbackPrx twoway = CallbackPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); - if (!twoway) + if(!twoway) { cerr << appName() << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -94,54 +94,54 @@ CallbackClient::run(int argc, char* argv[]) { cout << "==> "; cin >> c; - if (c == 't') + if(c == 't') { Context context; context["_fwd"] = "t" + secureStr; twoway->initiateCallback(twowayR, context); } - else if (c == 'o') + else if(c == 'o') { Context context; context["_fwd"] = "o" + secureStr; - if (!overwrite.empty()) + if(!overwrite.empty()) { context["ovrd"] = overwrite; } oneway->initiateCallback(onewayR, context); } - else if (c == 'O') + else if(c == 'O') { Context context; context["_fwd"] = "O" + secureStr; - if (!overwrite.empty()) + if(!overwrite.empty()) { context["ovrd"] = overwrite; } batchOneway->initiateCallback(onewayR, context); } - else if (c == 'd') + else if(c == 'd') { Context context; context["_fwd"] = "d" + secureStr; datagram->initiateCallback(datagramR, context); } - else if (c == 'D') + else if(c == 'D') { Context context; context["_fwd"] = "D" + secureStr; - if (!overwrite.empty()) + if(!overwrite.empty()) { context["ovrd"] = overwrite; } batchDatagram->initiateCallback(datagramR, context); } - else if (c == 'f') + else if(c == 'f') { batchOneway->ice_flush(); batchDatagram->ice_flush(); } - else if (c == 'S') + else if(c == 'S') { secure = !secure; secureStr = secure ? "s" : ""; @@ -158,7 +158,7 @@ CallbackClient::run(int argc, char* argv[]) datagramR = CallbackReceiverPrx::uncheckedCast(datagramR->ice_secure(secure)); // batchDatagramR = CallbackReceiverPrx::uncheckedCast(batchDatagramR->ice_secure(secure)); - if (secure) + if(secure) { cout << "secure mode is now on" << endl; } @@ -167,9 +167,9 @@ CallbackClient::run(int argc, char* argv[]) cout << "secure mode is now off" << endl; } } - else if (c == 'v') + else if(c == 'v') { - if (overwrite.empty()) + if(overwrite.empty()) { overwrite = "some_value"; cout << "overwrite context field is now `" << overwrite << "'" << endl; @@ -180,15 +180,15 @@ CallbackClient::run(int argc, char* argv[]) cout << "overwrite context field is empty" << endl; } } - else if (c == 's') + else if(c == 's') { twoway->shutdown(); } - else if (c == 'x') + else if(c == 'x') { // Nothing to do } - else if (c == '?') + else if(c == '?') { menu(); } @@ -203,7 +203,7 @@ CallbackClient::run(int argc, char* argv[]) cerr << ex << endl; } } - while (cin.good() && c != 'x'); + while(cin.good() && c != 'x'); return EXIT_SUCCESS; } diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp index f75e749047d..1541d533202 100644 --- a/cpp/demo/Ice/hello/Client.cpp +++ b/cpp/demo/Ice/hello/Client.cpp @@ -37,7 +37,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); const char* refProperty = "Hello.Hello"; std::string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -45,7 +45,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::ObjectPrx base = communicator->stringToProxy(ref); HelloPrx twoway = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); - if (!twoway) + if(!twoway) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -67,34 +67,34 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { cout << "==> "; cin >> c; - if (c == 't') + if(c == 't') { twoway->hello(); } - else if (c == 'o') + else if(c == 'o') { oneway->hello(); } - else if (c == 'O') + else if(c == 'O') { batchOneway->hello(); } - else if (c == 'd') + else if(c == 'd') { datagram->hello(); } - else if (c == 'D') + else if(c == 'D') { batchDatagram->hello(); } - else if (c == 'f') + else if(c == 'f') { batchOneway->ice_flush(); batchDatagram->ice_flush(); } - else if (c == 'T') + else if(c == 'T') { - if (timeout == -1) + if(timeout == -1) { timeout = 2000; } @@ -107,7 +107,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); - if (timeout == -1) + if(timeout == -1) { cout << "timeout is now switched off" << endl; } @@ -116,7 +116,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cout << "timeout is now set to 2000ms" << endl; } } - else if (c == 'S') + else if(c == 'S') { secure = !secure; @@ -126,7 +126,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - if (secure) + if(secure) { cout << "secure mode is now on" << endl; } @@ -135,15 +135,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cout << "secure mode is now off" << endl; } } - else if (c == 's') + else if(c == 's') { twoway->shutdown(); } - else if (c == 'x') + else if(c == 'x') { // Nothing to do } - else if (c == '?') + else if(c == '?') { menu(); } @@ -158,7 +158,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cerr << ex << endl; } } - while (cin.good() && c != 'x'); + while(cin.good() && c != 'x'); return EXIT_SUCCESS; } @@ -182,7 +182,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/hello/HelloI.h b/cpp/demo/Ice/hello/HelloI.h index 88801bbcd8b..210d4135f8d 100644 --- a/cpp/demo/Ice/hello/HelloI.h +++ b/cpp/demo/Ice/hello/HelloI.h @@ -1,30 +1,30 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef HELLO_I_H -#define HELLO_I_H - -#include <Hello.h> - -class HelloI : public Hello -{ -public: - - HelloI(const Ice::CommunicatorPtr&); - - virtual void hello(const Ice::Current&); - virtual void shutdown(const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef HELLO_I_H
+#define HELLO_I_H
+
+#include <Hello.h>
+
+class HelloI : public Hello
+{
+public:
+
+ HelloI(const Ice::CommunicatorPtr&);
+
+ virtual void hello(const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+};
+
+#endif
diff --git a/cpp/demo/Ice/hello/Server.cpp b/cpp/demo/Ice/hello/Server.cpp index bf5a14b33f8..8b288c11bc1 100644 --- a/cpp/demo/Ice/hello/Server.cpp +++ b/cpp/demo/Ice/hello/Server.cpp @@ -43,7 +43,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/latency/Client.cpp b/cpp/demo/Ice/latency/Client.cpp index df89dc79758..3daea88fdfe 100644 --- a/cpp/demo/Ice/latency/Client.cpp +++ b/cpp/demo/Ice/latency/Client.cpp @@ -19,7 +19,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); const char* refProperty = "Latency.Ping"; std::string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -27,7 +27,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::ObjectPrx base = communicator->stringToProxy(ref); PingPrx ping = PingPrx::checkedCast(base); - if (!ping) + if(!ping) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -40,7 +40,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) const int repetitions = 100000; cout << "pinging server " << repetitions << " times (this may take a while)" << endl; - for (int i = 0; i < repetitions; ++i) + for(int i = 0; i < repetitions; ++i) { ping->ice_ping(); } @@ -74,7 +74,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/latency/Server.cpp b/cpp/demo/Ice/latency/Server.cpp index 610e9b1e5f3..a09ff49780b 100644 --- a/cpp/demo/Ice/latency/Server.cpp +++ b/cpp/demo/Ice/latency/Server.cpp @@ -43,7 +43,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/nested/Client.cpp b/cpp/demo/Ice/nested/Client.cpp index 67be9e8c482..94cfb330077 100644 --- a/cpp/demo/Ice/nested/Client.cpp +++ b/cpp/demo/Ice/nested/Client.cpp @@ -34,7 +34,7 @@ NestedClient::run(int argc, char* argv[]) PropertiesPtr properties = communicator()->getProperties(); const char* refProperty = "Nested.NestedServer"; std::string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << appName() << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -42,7 +42,7 @@ NestedClient::run(int argc, char* argv[]) ObjectPrx base = communicator()->stringToProxy(ref); NestedPrx nested = NestedPrx::checkedCast(base); - if (!nested) + if(!nested) { cerr << appName() << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -67,7 +67,7 @@ NestedClient::run(int argc, char* argv[]) cout << "enter nesting level or 'x' for exit: "; cin >> s; int level = atoi(s.c_str()); - if (level > 0) + if(level > 0) { nested->nested(level, self); } @@ -77,7 +77,7 @@ NestedClient::run(int argc, char* argv[]) cerr << ex << endl; } } - while (cin.good() && s != "x"); + while(cin.good() && s != "x"); return EXIT_SUCCESS; } diff --git a/cpp/demo/Ice/nested/NestedI.cpp b/cpp/demo/Ice/nested/NestedI.cpp index f5c91651f59..de18f33f744 100644 --- a/cpp/demo/Ice/nested/NestedI.cpp +++ b/cpp/demo/Ice/nested/NestedI.cpp @@ -23,7 +23,7 @@ void NestedI::nested(Int level, const NestedPrx& proxy, const Ice::Current& current) { cout << level << endl; - if (--level > 0) + if(--level > 0) { proxy->nested(level, _self, current.context); } diff --git a/cpp/demo/Ice/nested/NestedI.h b/cpp/demo/Ice/nested/NestedI.h index 8b5293c53c3..27960cbe2b8 100644 --- a/cpp/demo/Ice/nested/NestedI.h +++ b/cpp/demo/Ice/nested/NestedI.h @@ -1,28 +1,28 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef NESTED_I_H -#define NESTED_I_H - -#include <Nested.h> - -class NestedI : public Nested -{ -public: - - NestedI(const NestedPrx&); - virtual void nested(Ice::Int, const NestedPrx&, const Ice::Current&); - -private: - - NestedPrx _self; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef NESTED_I_H
+#define NESTED_I_H
+
+#include <Nested.h>
+
+class NestedI : public Nested
+{
+public:
+
+ NestedI(const NestedPrx&);
+ virtual void nested(Ice::Int, const NestedPrx&, const Ice::Current&);
+
+private:
+
+ NestedPrx _self;
+};
+
+#endif
diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index 5ef90c9e2b0..ca2a0ce1bb8 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -20,7 +20,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); const char* refProperty = "Value.Initial"; std::string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -28,7 +28,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::ObjectPrx base = communicator->stringToProxy(ref); InitialPrx initial = InitialPrx::checkedCast(base); - if (!initial) + if(!initial) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -185,7 +185,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/value/ObjectFactory.cpp b/cpp/demo/Ice/value/ObjectFactory.cpp index e37800aa2be..506319bd0a0 100644 --- a/cpp/demo/Ice/value/ObjectFactory.cpp +++ b/cpp/demo/Ice/value/ObjectFactory.cpp @@ -17,12 +17,12 @@ using namespace std; Ice::ObjectPtr ObjectFactory::create(const string& type) { - if (type == "::Printer") + if(type == "::Printer") { return new PrinterI; } - if (type == "::DerivedPrinter") + if(type == "::DerivedPrinter") { return new DerivedPrinterI; } diff --git a/cpp/demo/Ice/value/ObjectFactory.h b/cpp/demo/Ice/value/ObjectFactory.h index 463ccef33fe..2056fcdcb8e 100644 --- a/cpp/demo/Ice/value/ObjectFactory.h +++ b/cpp/demo/Ice/value/ObjectFactory.h @@ -1,22 +1,22 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SERVANT_FACTORY_H -#define SERVANT_FACTORY_H - -class ObjectFactory : public Ice::ObjectFactory -{ -public: - - virtual Ice::ObjectPtr create(const std::string&); - virtual void destroy(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SERVANT_FACTORY_H
+#define SERVANT_FACTORY_H
+
+class ObjectFactory : public Ice::ObjectFactory
+{
+public:
+
+ virtual Ice::ObjectPtr create(const std::string&);
+ virtual void destroy();
+};
+
+#endif
diff --git a/cpp/demo/Ice/value/Server.cpp b/cpp/demo/Ice/value/Server.cpp index 6a4a9a3f1db..b5fd84bce0f 100644 --- a/cpp/demo/Ice/value/Server.cpp +++ b/cpp/demo/Ice/value/Server.cpp @@ -43,7 +43,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/Ice/value/ValueI.h b/cpp/demo/Ice/value/ValueI.h index ee710b34e56..2deb75497a2 100644 --- a/cpp/demo/Ice/value/ValueI.h +++ b/cpp/demo/Ice/value/ValueI.h @@ -1,50 +1,50 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef VALUE_I_H -#define VALUE_I_H - -#include <Value.h> - -class InitialI : public Initial -{ -public: - - InitialI(const Ice::ObjectAdapterPtr&); - - virtual SimplePtr simple(const Ice::Current&); - virtual void printer(PrinterPtr&, PrinterPrx&, const Ice::Current&); - virtual PrinterPtr derivedPrinter(const Ice::Current&); - virtual void throwDerivedPrinter(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; - SimplePtr _simple; - PrinterPtr _printer; - PrinterPrx _printerProxy; - DerivedPrinterPtr _derivedPrinter; -}; - -class PrinterI : virtual public Printer -{ -public: - - virtual void printBackwards(const Ice::Current&); -}; - -class DerivedPrinterI : virtual public DerivedPrinter, virtual public PrinterI -{ -public: - - virtual void printUppercase(const Ice::Current&); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef VALUE_I_H
+#define VALUE_I_H
+
+#include <Value.h>
+
+class InitialI : public Initial
+{
+public:
+
+ InitialI(const Ice::ObjectAdapterPtr&);
+
+ virtual SimplePtr simple(const Ice::Current&);
+ virtual void printer(PrinterPtr&, PrinterPrx&, const Ice::Current&);
+ virtual PrinterPtr derivedPrinter(const Ice::Current&);
+ virtual void throwDerivedPrinter(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+ SimplePtr _simple;
+ PrinterPtr _printer;
+ PrinterPrx _printerProxy;
+ DerivedPrinterPtr _derivedPrinter;
+};
+
+class PrinterI : virtual public Printer
+{
+public:
+
+ virtual void printBackwards(const Ice::Current&);
+};
+
+class DerivedPrinterI : virtual public DerivedPrinter, virtual public PrinterI
+{
+public:
+
+ virtual void printUppercase(const Ice::Current&);
+};
+
+#endif
diff --git a/cpp/demo/IceBox/hello/Client.cpp b/cpp/demo/IceBox/hello/Client.cpp index 3309f463a15..6270caf14b8 100644 --- a/cpp/demo/IceBox/hello/Client.cpp +++ b/cpp/demo/IceBox/hello/Client.cpp @@ -36,7 +36,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::PropertiesPtr properties = communicator->getProperties(); const char* refProperty = "Hello.Hello"; std::string ref = properties->getProperty(refProperty); - if (ref.empty()) + if(ref.empty()) { cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; @@ -44,7 +44,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) Ice::ObjectPrx base = communicator->stringToProxy(ref); HelloPrx twoway = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); - if (!twoway) + if(!twoway) { cerr << argv[0] << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -66,34 +66,34 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { cout << "==> "; cin >> c; - if (c == 't') + if(c == 't') { twoway->hello(); } - else if (c == 'o') + else if(c == 'o') { oneway->hello(); } - else if (c == 'O') + else if(c == 'O') { batchOneway->hello(); } - else if (c == 'd') + else if(c == 'd') { datagram->hello(); } - else if (c == 'D') + else if(c == 'D') { batchDatagram->hello(); } - else if (c == 'f') + else if(c == 'f') { batchOneway->ice_flush(); batchDatagram->ice_flush(); } - else if (c == 'T') + else if(c == 'T') { - if (timeout == -1) + if(timeout == -1) { timeout = 2000; } @@ -106,7 +106,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); - if (timeout == -1) + if(timeout == -1) { cout << "timeout is now switched off" << endl; } @@ -115,7 +115,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cout << "timeout is now set to 2000ms" << endl; } } - else if (c == 'S') + else if(c == 'S') { secure = !secure; @@ -125,7 +125,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure)); batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure)); - if (secure) + if(secure) { cout << "secure mode is now on" << endl; } @@ -134,11 +134,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cout << "secure mode is now off" << endl; } } - else if (c == 'x') + else if(c == 'x') { // Nothing to do } - else if (c == '?') + else if(c == '?') { menu(); } @@ -153,7 +153,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cerr << ex << endl; } } - while (cin.good() && c != 'x'); + while(cin.good() && c != 'x'); return EXIT_SUCCESS; } @@ -177,7 +177,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/demo/IceBox/hello/HelloI.h b/cpp/demo/IceBox/hello/HelloI.h index 3a08e54b241..0e0028b66fe 100644 --- a/cpp/demo/IceBox/hello/HelloI.h +++ b/cpp/demo/IceBox/hello/HelloI.h @@ -1,36 +1,36 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef HELLO_I_H -#define HELLO_I_H - -#include <Hello.h> - -#if defined(_WIN32) -# define HELLO_API __declspec(dllexport) -#else -# define HELLO_API /**/ -#endif - -class HELLO_API HelloI : public Hello -{ -public: - - HelloI(const Ice::CommunicatorPtr&); - - virtual void hello(const Ice::Current&); - virtual void shutdown(const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef HELLO_I_H
+#define HELLO_I_H
+
+#include <Hello.h>
+
+#if defined(_WIN32)
+# define HELLO_API __declspec(dllexport)
+#else
+# define HELLO_API /**/
+#endif
+
+class HELLO_API HelloI : public Hello
+{
+public:
+
+ HelloI(const Ice::CommunicatorPtr&);
+
+ virtual void hello(const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+};
+
+#endif
diff --git a/cpp/demo/IceBox/hello/HelloServiceI.h b/cpp/demo/IceBox/hello/HelloServiceI.h index 6d0601e3d31..72d2a06f007 100644 --- a/cpp/demo/IceBox/hello/HelloServiceI.h +++ b/cpp/demo/IceBox/hello/HelloServiceI.h @@ -1,43 +1,43 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef HELLO_SERVICE_I_H -#define HELLO_SERVICE_I_H - -#include <IceBox/IceBox.h> - -#if defined(_WIN32) -# define HELLO_API __declspec(dllexport) -#else -# define HELLO_API /**/ -#endif - -class HELLO_API HelloServiceI : public ::IceBox::Service -{ -public: - - HelloServiceI(); - virtual ~HelloServiceI(); - - virtual void init(const ::std::string&, - const ::Ice::CommunicatorPtr&, - const ::Ice::PropertiesPtr&, - const ::Ice::StringSeq&); - - virtual void start(); - - virtual void stop(); - -private: - - ::Ice::ObjectAdapterPtr _adapter; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef HELLO_SERVICE_I_H
+#define HELLO_SERVICE_I_H
+
+#include <IceBox/IceBox.h>
+
+#if defined(_WIN32)
+# define HELLO_API __declspec(dllexport)
+#else
+# define HELLO_API /**/
+#endif
+
+class HELLO_API HelloServiceI : public ::IceBox::Service
+{
+public:
+
+ HelloServiceI();
+ virtual ~HelloServiceI();
+
+ virtual void init(const ::std::string&,
+ const ::Ice::CommunicatorPtr&,
+ const ::Ice::PropertiesPtr&,
+ const ::Ice::StringSeq&);
+
+ virtual void start();
+
+ virtual void stop();
+
+private:
+
+ ::Ice::ObjectAdapterPtr _adapter;
+};
+
+#endif
diff --git a/cpp/demo/IceStorm/clock/ClockI.h b/cpp/demo/IceStorm/clock/ClockI.h index 0924e0cf43f..c1d8eb880bc 100644 --- a/cpp/demo/IceStorm/clock/ClockI.h +++ b/cpp/demo/IceStorm/clock/ClockI.h @@ -1,23 +1,23 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef CLOCK_I_H -#define CLOCK_I_H - -#include <Clock.h> - -class ClockI : public Clock -{ -public: - - virtual void tick(const Ice::Current&); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef CLOCK_I_H
+#define CLOCK_I_H
+
+#include <Clock.h>
+
+class ClockI : public Clock
+{
+public:
+
+ virtual void tick(const Ice::Current&);
+};
+
+#endif
diff --git a/cpp/demo/IceStorm/clock/Publisher.cpp b/cpp/demo/IceStorm/clock/Publisher.cpp index a932c8aca87..6c6f4467a15 100644 --- a/cpp/demo/IceStorm/clock/Publisher.cpp +++ b/cpp/demo/IceStorm/clock/Publisher.cpp @@ -36,7 +36,7 @@ Publisher::run(int argc, char* argv[]) static const string endpointsProperty = "IceStorm.TopicManager.Endpoints"; string endpoints = properties->getProperty(endpointsProperty); - if (endpoints.empty()) + if(endpoints.empty()) { cerr << appName() << ": property `" << endpointsProperty << "' not set" << endl; return EXIT_FAILURE; @@ -44,7 +44,7 @@ Publisher::run(int argc, char* argv[]) Ice::ObjectPrx base = communicator()->stringToProxy("TopicManager:" + endpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << appName() << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -75,7 +75,7 @@ Publisher::run(int argc, char* argv[]) ClockPrx clock = ClockPrx::uncheckedCast(obj); cout << "publishing 10 tick events" << endl; - for (int i = 0; i < 10; ++i) + for(int i = 0; i < 10; ++i) { clock->tick(); } diff --git a/cpp/demo/IceStorm/clock/Subscriber.cpp b/cpp/demo/IceStorm/clock/Subscriber.cpp index 78d47f0c73c..92ff42fa7ad 100644 --- a/cpp/demo/IceStorm/clock/Subscriber.cpp +++ b/cpp/demo/IceStorm/clock/Subscriber.cpp @@ -39,7 +39,7 @@ Subscriber::run(int argc, char* argv[]) static const string endpointsProperty = "IceStorm.TopicManager.Endpoints"; string endpoints = properties->getProperty(endpointsProperty); - if (endpoints.empty()) + if(endpoints.empty()) { cerr << appName() << ": property `" << endpointsProperty << "' not set" << endl; return EXIT_FAILURE; @@ -47,7 +47,7 @@ Subscriber::run(int argc, char* argv[]) Ice::ObjectPrx base = communicator()->stringToProxy("TopicManager:" + endpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << appName() << ": invalid object reference" << endl; return EXIT_FAILURE; @@ -58,9 +58,9 @@ Subscriber::run(int argc, char* argv[]) // the set provided on the command line, or the topic "time". // Ice::StringSeq topics; - if (argc > 1) + if(argc > 1) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { topics.push_back(argv[i]); } @@ -101,7 +101,7 @@ Subscriber::run(int argc, char* argv[]) // topics. Alternatively a ServantLocator could have been used for // the same purpose. // - for (Ice::StringSeq::iterator p = topics.begin(); p != topics.end(); ++p) + for(Ice::StringSeq::iterator p = topics.begin(); p != topics.end(); ++p) { // // The category is the name of the topic. @@ -137,7 +137,7 @@ Subscriber::run(int argc, char* argv[]) // problem. If there was an error the application should terminate // without accepting any events. // - if (subscribers.size() == topics.size()) + if(subscribers.size() == topics.size()) { adapter->activate(); communicator()->waitForShutdown(); @@ -146,7 +146,7 @@ Subscriber::run(int argc, char* argv[]) // // Unsubscribe all subscribed objects. // - for (list<Ice::ObjectPrx>::const_iterator q = subscribers.begin(); q != subscribers.end(); ++q) + for(list<Ice::ObjectPrx>::const_iterator q = subscribers.begin(); q != subscribers.end(); ++q) { try { diff --git a/cpp/demo/IceUtil/workqueue/WorkQueue.cpp b/cpp/demo/IceUtil/workqueue/WorkQueue.cpp index 7aa13f54d3e..79f04a30b93 100644 --- a/cpp/demo/IceUtil/workqueue/WorkQueue.cpp +++ b/cpp/demo/IceUtil/workqueue/WorkQueue.cpp @@ -27,10 +27,10 @@ public: virtual void run() { - while (1) + while(1) { string item = nextItem(); - if (item == "destroy") + if(item == "destroy") { break; } @@ -44,7 +44,7 @@ public: add(const string& item) { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); - if (_queue.empty()) + if(_queue.empty()) { _monitor.notify(); } @@ -57,7 +57,7 @@ private: nextItem() { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); - while (_queue.empty()) + while(_queue.empty()) { _monitor.wait(); } diff --git a/cpp/include/Freeze/Application.h b/cpp/include/Freeze/Application.h index 5050a360be8..decbed3f696 100644 --- a/cpp/include/Freeze/Application.h +++ b/cpp/include/Freeze/Application.h @@ -1,48 +1,48 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FREEZE_APPLICATION_H -#define FREEZE_APPLICATION_H - -#ifdef _WIN32 -# ifdef FREEZE_API_EXPORTS -# define FREEZE_API __declspec(dllexport) -# else -# define FREEZE_API __declspec(dllimport) -# endif -#else -# define FREEZE_API /**/ -#endif - -#include <Ice/Application.h> -#include <Freeze/Freeze.h> - -namespace Freeze -{ - -class FREEZE_API Application : public Ice::Application -{ -public: - - Application(const std::string&); - virtual ~Application(); - - virtual int runFreeze(int, char*[], const DBEnvironmentPtr&) = 0; - -private: - - virtual int run(int, char*[]); - - const std::string _dbEnvName; -}; - -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FREEZE_APPLICATION_H
+#define FREEZE_APPLICATION_H
+
+#ifdef _WIN32
+# ifdef FREEZE_API_EXPORTS
+# define FREEZE_API __declspec(dllexport)
+# else
+# define FREEZE_API __declspec(dllimport)
+# endif
+#else
+# define FREEZE_API /**/
+#endif
+
+#include <Ice/Application.h>
+#include <Freeze/Freeze.h>
+
+namespace Freeze
+{
+
+class FREEZE_API Application : public Ice::Application
+{
+public:
+
+ Application(const std::string&);
+ virtual ~Application();
+
+ virtual int runFreeze(int, char*[], const DBEnvironmentPtr&) = 0;
+
+private:
+
+ virtual int run(int, char*[]);
+
+ const std::string _dbEnvName;
+};
+
+};
+
+#endif
diff --git a/cpp/include/Freeze/Freeze.h b/cpp/include/Freeze/Freeze.h index 1a04dedab75..24cbd11f9b2 100644 --- a/cpp/include/Freeze/Freeze.h +++ b/cpp/include/Freeze/Freeze.h @@ -1,19 +1,19 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FREEZE_FREEZE_H -#define FREEZE_FREEZE_H - -#include <Freeze/Initialize.h> -#include <Freeze/DB.h> -#include <Freeze/Evictor.h> -#include <Freeze/Map.h> - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FREEZE_FREEZE_H
+#define FREEZE_FREEZE_H
+
+#include <Freeze/Initialize.h>
+#include <Freeze/DB.h>
+#include <Freeze/Evictor.h>
+#include <Freeze/Map.h>
+
+#endif
diff --git a/cpp/include/Freeze/Initialize.h b/cpp/include/Freeze/Initialize.h index b68647805f0..20c97972296 100644 --- a/cpp/include/Freeze/Initialize.h +++ b/cpp/include/Freeze/Initialize.h @@ -1,34 +1,34 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FREEZE_INITIALIZE_H -#define FREEZE_INITIALIZE_H - -#include <Ice/Ice.h> -#include <Freeze/DBF.h> - -#ifdef _WIN32 -# ifdef FREEZE_API_EXPORTS -# define FREEZE_API __declspec(dllexport) -# else -# define FREEZE_API __declspec(dllimport) -# endif -#else -# define FREEZE_API /**/ -#endif - -namespace Freeze -{ - -FREEZE_API DBEnvironmentPtr initialize(const ::Ice::CommunicatorPtr&, const std::string&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FREEZE_INITIALIZE_H
+#define FREEZE_INITIALIZE_H
+
+#include <Ice/Ice.h>
+#include <Freeze/DBF.h>
+
+#ifdef _WIN32
+# ifdef FREEZE_API_EXPORTS
+# define FREEZE_API __declspec(dllexport)
+# else
+# define FREEZE_API __declspec(dllimport)
+# endif
+#else
+# define FREEZE_API /**/
+#endif
+
+namespace Freeze
+{
+
+FREEZE_API DBEnvironmentPtr initialize(const ::Ice::CommunicatorPtr&, const std::string&);
+
+}
+
+#endif
diff --git a/cpp/include/Freeze/Map.h b/cpp/include/Freeze/Map.h index 0da098edc77..47f28f2c320 100644 --- a/cpp/include/Freeze/Map.h +++ b/cpp/include/Freeze/Map.h @@ -1,805 +1,805 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FREEZE_MAP_H -#define FREEZE_MAP_H - -#include <Ice/Ice.h> -#include <Freeze/DB.h> - -#include <iterator> - -namespace Freeze -{ - -// -// Forward declaration -// -template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec> -class DBMap; -template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec> -class ConstDBIterator; - -// -// This is necessary for MSVC support. -// -struct DBIteratorBase -{ - typedef std::forward_iterator_tag iterator_category; -}; - -// -// Database iterator. This implements a forward iterator with the -// restriction that it's only possible to explicitely write back into -// the database. -// -// Equality and inequality are based on whether the iterator is -// "valid". An valid iterator contains a valid database and cursor -// pointer, otherwise the iterator is invalid. -// -// TODO: It's possible to implement bidirectional iterators, if -// necessary. -// -template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec> -class DBIterator : public DBIteratorBase -{ -public: - - typedef ptrdiff_t difference_type; - - typedef std::pair<const key_type, const mapped_type> value_type; - - typedef value_type* pointer; - - typedef value_type& reference; - - DBIterator(const DBPtr& db, const DBCursorPtr& cursor) - : _db(db), _cursor(cursor) - { - } - - DBIterator() - { - } - - DBIterator(const DBIterator& rhs) - { - if (rhs._cursor) - { - _cursor = rhs._cursor->clone(); - } - - _db = rhs._db; - } - - DBIterator& operator=(const DBIterator& rhs) - { - if (_cursor) - { - _cursor->close(); - } - - if (rhs._cursor) - { - _cursor = rhs._cursor->clone(); - } - - _db = rhs._db; - - return *this; - } - - ~DBIterator() - { - if (_cursor) - { - _cursor->close(); - } - } - - bool operator==(const DBIterator& rhs) const - { - if (!_db && !rhs._db) - { - return true; - } - return false; - } - - bool operator!=(const DBIterator& rhs) const - { - return !(*this == rhs); - } - - DBIterator& operator++() - { - incr(); - return *this; - } - - DBIterator operator++(int) - { - DBIterator tmp = *this; - tmp.incr(); - return tmp; - } - - // - // Note that this doesn't follow the regular iterator mapping: - // - // value_type& operator*(), value_type operator*() const - // - value_type& operator*() const - { - key_type key; - mapped_type value; - - getCurrentValue(key, value); - - // - // !IMPORTANT! - // - // This method has to cache the returned value to implement - // operator->(). - // - const_cast<key_type&>(_ref.first) = key; - const_cast<mapped_type&>(_ref.second) = value; - return _ref; - } - - value_type* operator->() { return &(operator*()); } - - // - // This special method allows writing back into the database. - // - void set(const mapped_type& value) - { - Freeze::Value v; - ValueCodec::write(value, v, _db->getCommunicator()); - _cursor->set(v); - } - -private: - - void incr() - { - assert(_cursor && _db); - if (!_cursor->next()) - { - // - // The iterator has been moved past the end, and is now - // invalid. - // - _cursor->close(); - _cursor = 0; - _db = 0; - } - } - - void getCurrentValue(key_type& key, mapped_type& value) const - { - Freeze::Key k; - Freeze::Value v; - - _cursor->curr(k, v); - - ::Ice::CommunicatorPtr communicator = _db->getCommunicator(); - KeyCodec::read(key, k, communicator); - ValueCodec::read(value, v, communicator); - } - - friend class ConstDBIterator<key_type, mapped_type, KeyCodec, ValueCodec>; - friend class DBMap<key_type, mapped_type, KeyCodec, ValueCodec>; - - DBPtr _db; - DBCursorPtr _cursor; - - // - // Cached last return value. This is so that operator->() can - // actually return a pointer. - // - mutable value_type _ref; -}; - -// -// See DBIterator comments for design notes -// -template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec> -class ConstDBIterator : public DBIteratorBase -{ -public: - - typedef ptrdiff_t difference_type; - - typedef std::pair<const key_type, const mapped_type> value_type; - - typedef value_type* pointer; - - typedef value_type& reference; - - ConstDBIterator(const DBPtr& db, const DBCursorPtr& cursor) - : _db(db), _cursor(cursor) - { - } - ConstDBIterator() { } - - ConstDBIterator(const ConstDBIterator& rhs) - { - if (rhs._cursor) - { - _cursor = rhs._cursor->clone(); - } - - _db = rhs._db; - } - - // - // A DBIterator can be converted to a ConstDBIterator (but not - // vice versa) - same for operator=. - // - ConstDBIterator(const DBIterator<key_type, mapped_type, KeyCodec, ValueCodec>& rhs) - { - if (rhs._cursor) - { - _cursor = rhs._cursor->clone(); - } - - _db = rhs._db; - } - - ConstDBIterator& operator=(const ConstDBIterator& rhs) - { - if (_cursor) - { - _cursor->close(); - } - - if (rhs._cursor) - { - _cursor = rhs._cursor->clone(); - } - - _db = rhs._db; - - return *this; - } - - // - // Create const_iterator from iterator. - // - ConstDBIterator& operator=(const DBIterator<key_type, mapped_type, KeyCodec, ValueCodec>& rhs) - { - if (_cursor) - { - _cursor->close(); - } - - if (rhs._cursor) - { - _cursor = rhs._cursor->clone(); - } - - _db = rhs._db; - - return *this; - } - - ~ConstDBIterator() - { - if (_cursor) - { - _cursor->close(); - } - } - - bool operator==(const ConstDBIterator& rhs) - { - if (!_db && !rhs._db) - { - return true; - } - return false; - } - - bool operator!=(const ConstDBIterator& rhs) - { - return !(*this == rhs); - } - - ConstDBIterator& operator++() - { - incr(); - return *this; - } - - ConstDBIterator operator++(int) - { - ConstDBIterator tmp = *this; - tmp.incr(); - return tmp; - } - - // - // Note that this doesn't follow the regular iterator mapping: - // - // value_type operator*() const - // - value_type& operator*() const - { - key_type key; - mapped_type value; - - getCurrentValue(key, value); - - // - // !IMPORTANT! - // - // This method has to cache the returned value to implement - // operator->(). - // - const_cast<key_type&>(_ref.first) = key; - const_cast<mapped_type&>(_ref.second) = value; - return _ref; - } - - pointer operator->() const { return &(operator*()); } - -private: - - void incr() - { - assert(_cursor); - if (!_cursor->next()) - { - // - // The iterator has been moved past the end, and is now - // invalid. - // - _cursor->close(); - _cursor = 0; - _db = 0; - } - } - - void getCurrentValue(key_type& key, mapped_type& value) const - { - Freeze::Key k; - Freeze::Value v; - - _cursor->curr(k, v); - - ::Ice::CommunicatorPtr communicator = _db->getCommunicator(); - KeyCodec::read(key, k, communicator); - ValueCodec::read(value, v, communicator); - } - - friend class DBMap<key_type, mapped_type, KeyCodec, ValueCodec>; - - DBPtr _db; - DBCursorPtr _cursor; - - // - // Cached last return value. This is so that operator->() can - // actually return a pointer. - // - mutable value_type _ref; -}; - -// -// This is an STL container that matches the requirements of a -// Associated Container - with the restriction that operator[] isn't -// implemented. It also supports the same interface as a Hashed -// Associative Container (with the above restrictions), except the -// hasher & key_equal methods. -// -// TODO: If necessary it would be possible to implement reverse and -// bidirectional iterators. -// -template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec> -class DBMap -{ -public: - - typedef std::pair<const key_type, const mapped_type> value_type; - - // - // These are not supported: - // - // hasher, key_equal, key_compare, value_compare - // - - typedef DBIterator<key_type, mapped_type, KeyCodec, ValueCodec > iterator; - typedef ConstDBIterator<key_type, mapped_type, KeyCodec, ValueCodec > const_iterator; - - // - // No definition for reference, const_reference, pointer or - // const_pointer. - // - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - // - // Allocators are not supported. - // - // allocator_type - // - - // - // Constructors - // - DBMap(const DBPtr& db) : - _db(db) - { - } - -#ifdef __STL_MEMBER_TEMPLATES - template <class _InputIterator> - DBMap(const DBPtr& db, _InputIterator first, _InputIterator last) : - _db(db) - { - while (first != last) - { - insert(*first); - ++first; - } - } -#else - DBMap(const DBPtr& db, const value_type* first, const value_type* last) : - _db(db) - { - while (first != last) - { - insert(*first); - ++first; - } - } - DBMap(const DBPtr& db, const_iterator first, const_iterator last) : - _db(db) - { - while (first != last) - { - insert(*first); - ++first; - } - } -#endif /*__STL_MEMBER_TEMPLATES */ - - ~DBMap() - { - } - - // - // Neither of these operations are supported. - // - // key_compare key_comp() const, value_compare value_comp() const, - // hasher hash_funct() const, key_equal key_eq() const - // - - bool operator==(const DBMap& rhs) const - { - // - // This does a memberwise equality for the entire contents of - // the database. While slow this is always correct. Database - // equality is not necessarily correct in the context of a - // transaction. - // - if (count() != rhs.count()) - return false; - - for (const_iterator p = rhs.begin() ; p != rhs.end() ; ++p) - { - const_iterator q = rhs.find(p->first); - if (q == rhs.end()) - { - return false; - } - if (p->second != q->second) - { - return false; - } - } - return true; - } - - bool operator!=(const DBMap& rhs) const - { - return !(*this == rhs); - } - - void swap(DBMap& rhs) - { - DBPtr tmp = _db; - _db = rhs._db; - rhs._db = tmp; - } - - iterator begin() - { - try - { - return iterator(_db, _db->getCursor()); - } - catch(const DBNotFoundException&) - { - return iterator(); - } - } - const_iterator begin() const - { - try - { - return const_iterator(_db, _db->getCursor()); - } - catch(const DBNotFoundException&) - { - return const_iterator(); - } - } - - iterator end() - { - return iterator(); - } - - const_iterator end() const - { - return const_iterator(); - } - - bool empty() const - { - return size() == 0; - } - - size_type size() const - { - return (size_type)_db->getNumberOfRecords(); - } - - size_type max_size() const - { - return 0xffffffff; // TODO: is this the max? - } - - // - // This method isn't implemented. - // - // mapped_type& operator[](const key_type& key) - // - - // - // This method isn't in the STLport library - but it's referenced - // in "STL Tutorial and Refrence Guide, Second Edition". It's not - // currently implemented. - // - // const mapped_type& operator[](const key_type& key) const; - // - - // - // No allocators. - // - //allocator_type get_allocator() const; - // - - iterator insert(iterator /*position*/, const value_type& key) - { - // - // position is ignored. - // - ::Ice::CommunicatorPtr communicator = _db->getCommunicator(); - - Freeze::Key k; - Freeze::Value v; - KeyCodec::write(key.first, k, communicator); - ValueCodec::write(key.second, v, communicator); - - _db->put(k, v); - DBCursorPtr cursor = _db->getCursorAtKey(k); - - return iterator(_db, cursor); - } - - std::pair<iterator, bool> insert(const value_type& key) - { - ::Ice::CommunicatorPtr communicator = _db->getCommunicator(); - - Freeze::Key k; - Freeze::Value v; - KeyCodec::write(key.first, k, communicator); - ValueCodec::write(key.second, v, communicator); - - DBCursorPtr cursor; - bool inserted; - - try - { - // - // Does the value exist already? - // - cursor = _db->getCursorAtKey(k); - inserted = false; - } - catch(const DBNotFoundException&) - { - inserted = true; - } - - _db->put(k, v); - if (inserted) - { - cursor = _db->getCursorAtKey(k); - } - return std::pair<iterator, bool>(iterator(_db, cursor), inserted); - } - -#ifdef __STL_MEMBER_TEMPLATES - template <typename InputIterator> - void insert(InputIterator first, InputIterator last) - { - while (first != last) - { - insert(*first); - ++first; - } - } -#else - void insert(const value_type* first, const value_type* last) - { - while (first != last) - { - insert(*first); - ++first; - } - } - void insert(const_iterator first, const_iterator last) - { - while (first != last) - { - insert(*first); - ++first; - } - } -#endif - - void erase(iterator position) - { - position._cursor->del(); - } - - size_type erase(const key_type& key) - { - Freeze::Key k; - KeyCodec::write(key, k, _db->getCommunicator()); - - try - { - _db->del(k); - } - catch(const DBNotFoundException&) - { - return 0; - } - - return 1; - } - - void erase(iterator first, iterator last) - { - while (first != last) - { - first._cursor->del(); - ++first; - } - } - - void clear() - { - _db->clear(); - } - - iterator find(const key_type& key) - { - Freeze::Key k; - KeyCodec::write(key, k, _db->getCommunicator()); - - try - { - DBCursorPtr cursor = _db->getCursorAtKey(k); - return iterator(_db, cursor); - } - catch(const DBNotFoundException&) - { - // - // The record doesn't exist, return the end() iterator. - // - } - return end(); - } - - const_iterator find(const key_type& key) const - { - Freeze::Key k; - KeyCodec::write(key, k, _db->getCommunicator()); - - try - { - DBCursorPtr cursor = _db->getCursorAtKey(k); - return const_iterator(_db, cursor); - } - catch(const DBNotFoundException&) - { - // - // The record doesn't exist, return the end() iterator. - // - } - return end(); - } - - size_type count(const key_type& key) const - { - if (find(key) != end()) - return 1; - return 0; - } - - std::pair<iterator, iterator> equal_range(const key_type& key) - { - iterator p = find(key); - return std::pair<iterator,iterator>(p,p); - } - - std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const - { - const_iterator p = find(key); - return std::pair<const_iterator,const_iterator>(p,p); - } - -private: - - DBPtr _db; -}; - -} // End namespace Freeze - -// -// This is for MSVC. -// -# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES -namespace std -{ - -//XXX update -template <class key_type, class mapped_type, class KeyCodec, class ValueCodec> -inline pair<const key_type, const mapped_type>* -value_type(const Freeze::DBIterator<key_type, mapped_type, KeyCodec, ValueCodec>&) -{ - return (pair<const key_type, const mapped_type>*)0; -} - -template <class key_type, class mapped_type, class KeyCodec, class ValueCodec> -inline pair<const key_type, const mapped_type>* -value_type(const Freeze::ConstDBIterator<key_type, mapped_type, KeyCodec, ValueCodec>&) -{ - return (pair<const key_type, const mapped_type>*)0; -} - -inline forward_iterator_tag iterator_category(const Freeze::DBIteratorBase&) -{ - return forward_iterator_tag(); -} - -inline ptrdiff_t* distance_type(const Freeze::DBIteratorBase&) { return (ptrdiff_t*) 0; } - -} // End namespace std - -#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FREEZE_MAP_H
+#define FREEZE_MAP_H
+
+#include <Ice/Ice.h>
+#include <Freeze/DB.h>
+
+#include <iterator>
+
+namespace Freeze
+{
+
+//
+// Forward declaration
+//
+template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec>
+class DBMap;
+template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec>
+class ConstDBIterator;
+
+//
+// This is necessary for MSVC support.
+//
+struct DBIteratorBase
+{
+ typedef std::forward_iterator_tag iterator_category;
+};
+
+//
+// Database iterator. This implements a forward iterator with the
+// restriction that it's only possible to explicitely write back into
+// the database.
+//
+// Equality and inequality are based on whether the iterator is
+// "valid". An valid iterator contains a valid database and cursor
+// pointer, otherwise the iterator is invalid.
+//
+// TODO: It's possible to implement bidirectional iterators, if
+// necessary.
+//
+template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec>
+class DBIterator : public DBIteratorBase
+{
+public:
+
+ typedef ptrdiff_t difference_type;
+
+ typedef std::pair<const key_type, const mapped_type> value_type;
+
+ typedef value_type* pointer;
+
+ typedef value_type& reference;
+
+ DBIterator(const DBPtr& db, const DBCursorPtr& cursor)
+ : _db(db), _cursor(cursor)
+ {
+ }
+
+ DBIterator()
+ {
+ }
+
+ DBIterator(const DBIterator& rhs)
+ {
+ if(rhs._cursor)
+ {
+ _cursor = rhs._cursor->clone();
+ }
+
+ _db = rhs._db;
+ }
+
+ DBIterator& operator=(const DBIterator& rhs)
+ {
+ if(_cursor)
+ {
+ _cursor->close();
+ }
+
+ if(rhs._cursor)
+ {
+ _cursor = rhs._cursor->clone();
+ }
+
+ _db = rhs._db;
+
+ return *this;
+ }
+
+ ~DBIterator()
+ {
+ if(_cursor)
+ {
+ _cursor->close();
+ }
+ }
+
+ bool operator==(const DBIterator& rhs) const
+ {
+ if(!_db && !rhs._db)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ bool operator!=(const DBIterator& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ DBIterator& operator++()
+ {
+ incr();
+ return *this;
+ }
+
+ DBIterator operator++(int)
+ {
+ DBIterator tmp = *this;
+ tmp.incr();
+ return tmp;
+ }
+
+ //
+ // Note that this doesn't follow the regular iterator mapping:
+ //
+ // value_type& operator*(), value_type operator*() const
+ //
+ value_type& operator*() const
+ {
+ key_type key;
+ mapped_type value;
+
+ getCurrentValue(key, value);
+
+ //
+ // !IMPORTANT!
+ //
+ // This method has to cache the returned value to implement
+ // operator->().
+ //
+ const_cast<key_type&>(_ref.first) = key;
+ const_cast<mapped_type&>(_ref.second) = value;
+ return _ref;
+ }
+
+ value_type* operator->() { return &(operator*()); }
+
+ //
+ // This special method allows writing back into the database.
+ //
+ void set(const mapped_type& value)
+ {
+ Freeze::Value v;
+ ValueCodec::write(value, v, _db->getCommunicator());
+ _cursor->set(v);
+ }
+
+private:
+
+ void incr()
+ {
+ assert(_cursor && _db);
+ if(!_cursor->next())
+ {
+ //
+ // The iterator has been moved past the end, and is now
+ // invalid.
+ //
+ _cursor->close();
+ _cursor = 0;
+ _db = 0;
+ }
+ }
+
+ void getCurrentValue(key_type& key, mapped_type& value) const
+ {
+ Freeze::Key k;
+ Freeze::Value v;
+
+ _cursor->curr(k, v);
+
+ ::Ice::CommunicatorPtr communicator = _db->getCommunicator();
+ KeyCodec::read(key, k, communicator);
+ ValueCodec::read(value, v, communicator);
+ }
+
+ friend class ConstDBIterator<key_type, mapped_type, KeyCodec, ValueCodec>;
+ friend class DBMap<key_type, mapped_type, KeyCodec, ValueCodec>;
+
+ DBPtr _db;
+ DBCursorPtr _cursor;
+
+ //
+ // Cached last return value. This is so that operator->() can
+ // actually return a pointer.
+ //
+ mutable value_type _ref;
+};
+
+//
+// See DBIterator comments for design notes
+//
+template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec>
+class ConstDBIterator : public DBIteratorBase
+{
+public:
+
+ typedef ptrdiff_t difference_type;
+
+ typedef std::pair<const key_type, const mapped_type> value_type;
+
+ typedef value_type* pointer;
+
+ typedef value_type& reference;
+
+ ConstDBIterator(const DBPtr& db, const DBCursorPtr& cursor)
+ : _db(db), _cursor(cursor)
+ {
+ }
+ ConstDBIterator() { }
+
+ ConstDBIterator(const ConstDBIterator& rhs)
+ {
+ if(rhs._cursor)
+ {
+ _cursor = rhs._cursor->clone();
+ }
+
+ _db = rhs._db;
+ }
+
+ //
+ // A DBIterator can be converted to a ConstDBIterator (but not
+ // vice versa) - same for operator=.
+ //
+ ConstDBIterator(const DBIterator<key_type, mapped_type, KeyCodec, ValueCodec>& rhs)
+ {
+ if(rhs._cursor)
+ {
+ _cursor = rhs._cursor->clone();
+ }
+
+ _db = rhs._db;
+ }
+
+ ConstDBIterator& operator=(const ConstDBIterator& rhs)
+ {
+ if(_cursor)
+ {
+ _cursor->close();
+ }
+
+ if(rhs._cursor)
+ {
+ _cursor = rhs._cursor->clone();
+ }
+
+ _db = rhs._db;
+
+ return *this;
+ }
+
+ //
+ // Create const_iterator from iterator.
+ //
+ ConstDBIterator& operator=(const DBIterator<key_type, mapped_type, KeyCodec, ValueCodec>& rhs)
+ {
+ if(_cursor)
+ {
+ _cursor->close();
+ }
+
+ if(rhs._cursor)
+ {
+ _cursor = rhs._cursor->clone();
+ }
+
+ _db = rhs._db;
+
+ return *this;
+ }
+
+ ~ConstDBIterator()
+ {
+ if(_cursor)
+ {
+ _cursor->close();
+ }
+ }
+
+ bool operator==(const ConstDBIterator& rhs)
+ {
+ if(!_db && !rhs._db)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ bool operator!=(const ConstDBIterator& rhs)
+ {
+ return !(*this == rhs);
+ }
+
+ ConstDBIterator& operator++()
+ {
+ incr();
+ return *this;
+ }
+
+ ConstDBIterator operator++(int)
+ {
+ ConstDBIterator tmp = *this;
+ tmp.incr();
+ return tmp;
+ }
+
+ //
+ // Note that this doesn't follow the regular iterator mapping:
+ //
+ // value_type operator*() const
+ //
+ value_type& operator*() const
+ {
+ key_type key;
+ mapped_type value;
+
+ getCurrentValue(key, value);
+
+ //
+ // !IMPORTANT!
+ //
+ // This method has to cache the returned value to implement
+ // operator->().
+ //
+ const_cast<key_type&>(_ref.first) = key;
+ const_cast<mapped_type&>(_ref.second) = value;
+ return _ref;
+ }
+
+ pointer operator->() const { return &(operator*()); }
+
+private:
+
+ void incr()
+ {
+ assert(_cursor);
+ if(!_cursor->next())
+ {
+ //
+ // The iterator has been moved past the end, and is now
+ // invalid.
+ //
+ _cursor->close();
+ _cursor = 0;
+ _db = 0;
+ }
+ }
+
+ void getCurrentValue(key_type& key, mapped_type& value) const
+ {
+ Freeze::Key k;
+ Freeze::Value v;
+
+ _cursor->curr(k, v);
+
+ ::Ice::CommunicatorPtr communicator = _db->getCommunicator();
+ KeyCodec::read(key, k, communicator);
+ ValueCodec::read(value, v, communicator);
+ }
+
+ friend class DBMap<key_type, mapped_type, KeyCodec, ValueCodec>;
+
+ DBPtr _db;
+ DBCursorPtr _cursor;
+
+ //
+ // Cached last return value. This is so that operator->() can
+ // actually return a pointer.
+ //
+ mutable value_type _ref;
+};
+
+//
+// This is an STL container that matches the requirements of a
+// Associated Container - with the restriction that operator[] isn't
+// implemented. It also supports the same interface as a Hashed
+// Associative Container (with the above restrictions), except the
+// hasher & key_equal methods.
+//
+// TODO: If necessary it would be possible to implement reverse and
+// bidirectional iterators.
+//
+template <typename key_type, typename mapped_type, typename KeyCodec, typename ValueCodec>
+class DBMap
+{
+public:
+
+ typedef std::pair<const key_type, const mapped_type> value_type;
+
+ //
+ // These are not supported:
+ //
+ // hasher, key_equal, key_compare, value_compare
+ //
+
+ typedef DBIterator<key_type, mapped_type, KeyCodec, ValueCodec > iterator;
+ typedef ConstDBIterator<key_type, mapped_type, KeyCodec, ValueCodec > const_iterator;
+
+ //
+ // No definition for reference, const_reference, pointer or
+ // const_pointer.
+ //
+
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ //
+ // Allocators are not supported.
+ //
+ // allocator_type
+ //
+
+ //
+ // Constructors
+ //
+ DBMap(const DBPtr& db) :
+ _db(db)
+ {
+ }
+
+#ifdef __STL_MEMBER_TEMPLATES
+ template <class _InputIterator>
+ DBMap(const DBPtr& db, _InputIterator first, _InputIterator last) :
+ _db(db)
+ {
+ while(first != last)
+ {
+ insert(*first);
+ ++first;
+ }
+ }
+#else
+ DBMap(const DBPtr& db, const value_type* first, const value_type* last) :
+ _db(db)
+ {
+ while(first != last)
+ {
+ insert(*first);
+ ++first;
+ }
+ }
+ DBMap(const DBPtr& db, const_iterator first, const_iterator last) :
+ _db(db)
+ {
+ while(first != last)
+ {
+ insert(*first);
+ ++first;
+ }
+ }
+#endif /*__STL_MEMBER_TEMPLATES */
+
+ ~DBMap()
+ {
+ }
+
+ //
+ // Neither of these operations are supported.
+ //
+ // key_compare key_comp() const, value_compare value_comp() const,
+ // hasher hash_funct() const, key_equal key_eq() const
+ //
+
+ bool operator==(const DBMap& rhs) const
+ {
+ //
+ // This does a memberwise equality for the entire contents of
+ // the database. While slow this is always correct. Database
+ // equality is not necessarily correct in the context of a
+ // transaction.
+ //
+ if(count() != rhs.count())
+ return false;
+
+ for(const_iterator p = rhs.begin() ; p != rhs.end() ; ++p)
+ {
+ const_iterator q = rhs.find(p->first);
+ if(q == rhs.end())
+ {
+ return false;
+ }
+ if(p->second != q->second)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ bool operator!=(const DBMap& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ void swap(DBMap& rhs)
+ {
+ DBPtr tmp = _db;
+ _db = rhs._db;
+ rhs._db = tmp;
+ }
+
+ iterator begin()
+ {
+ try
+ {
+ return iterator(_db, _db->getCursor());
+ }
+ catch(const DBNotFoundException&)
+ {
+ return iterator();
+ }
+ }
+ const_iterator begin() const
+ {
+ try
+ {
+ return const_iterator(_db, _db->getCursor());
+ }
+ catch(const DBNotFoundException&)
+ {
+ return const_iterator();
+ }
+ }
+
+ iterator end()
+ {
+ return iterator();
+ }
+
+ const_iterator end() const
+ {
+ return const_iterator();
+ }
+
+ bool empty() const
+ {
+ return size() == 0;
+ }
+
+ size_type size() const
+ {
+ return (size_type)_db->getNumberOfRecords();
+ }
+
+ size_type max_size() const
+ {
+ return 0xffffffff; // TODO: is this the max?
+ }
+
+ //
+ // This method isn't implemented.
+ //
+ // mapped_type& operator[](const key_type& key)
+ //
+
+ //
+ // This method isn't in the STLport library - but it's referenced
+ // in "STL Tutorial and Refrence Guide, Second Edition". It's not
+ // currently implemented.
+ //
+ // const mapped_type& operator[](const key_type& key) const;
+ //
+
+ //
+ // No allocators.
+ //
+ //allocator_type get_allocator() const;
+ //
+
+ iterator insert(iterator /*position*/, const value_type& key)
+ {
+ //
+ // position is ignored.
+ //
+ ::Ice::CommunicatorPtr communicator = _db->getCommunicator();
+
+ Freeze::Key k;
+ Freeze::Value v;
+ KeyCodec::write(key.first, k, communicator);
+ ValueCodec::write(key.second, v, communicator);
+
+ _db->put(k, v);
+ DBCursorPtr cursor = _db->getCursorAtKey(k);
+
+ return iterator(_db, cursor);
+ }
+
+ std::pair<iterator, bool> insert(const value_type& key)
+ {
+ ::Ice::CommunicatorPtr communicator = _db->getCommunicator();
+
+ Freeze::Key k;
+ Freeze::Value v;
+ KeyCodec::write(key.first, k, communicator);
+ ValueCodec::write(key.second, v, communicator);
+
+ DBCursorPtr cursor;
+ bool inserted;
+
+ try
+ {
+ //
+ // Does the value exist already?
+ //
+ cursor = _db->getCursorAtKey(k);
+ inserted = false;
+ }
+ catch(const DBNotFoundException&)
+ {
+ inserted = true;
+ }
+
+ _db->put(k, v);
+ if(inserted)
+ {
+ cursor = _db->getCursorAtKey(k);
+ }
+ return std::pair<iterator, bool>(iterator(_db, cursor), inserted);
+ }
+
+#ifdef __STL_MEMBER_TEMPLATES
+ template <typename InputIterator>
+ void insert(InputIterator first, InputIterator last)
+ {
+ while(first != last)
+ {
+ insert(*first);
+ ++first;
+ }
+ }
+#else
+ void insert(const value_type* first, const value_type* last)
+ {
+ while(first != last)
+ {
+ insert(*first);
+ ++first;
+ }
+ }
+ void insert(const_iterator first, const_iterator last)
+ {
+ while(first != last)
+ {
+ insert(*first);
+ ++first;
+ }
+ }
+#endif
+
+ void erase(iterator position)
+ {
+ position._cursor->del();
+ }
+
+ size_type erase(const key_type& key)
+ {
+ Freeze::Key k;
+ KeyCodec::write(key, k, _db->getCommunicator());
+
+ try
+ {
+ _db->del(k);
+ }
+ catch(const DBNotFoundException&)
+ {
+ return 0;
+ }
+
+ return 1;
+ }
+
+ void erase(iterator first, iterator last)
+ {
+ while(first != last)
+ {
+ first._cursor->del();
+ ++first;
+ }
+ }
+
+ void clear()
+ {
+ _db->clear();
+ }
+
+ iterator find(const key_type& key)
+ {
+ Freeze::Key k;
+ KeyCodec::write(key, k, _db->getCommunicator());
+
+ try
+ {
+ DBCursorPtr cursor = _db->getCursorAtKey(k);
+ return iterator(_db, cursor);
+ }
+ catch(const DBNotFoundException&)
+ {
+ //
+ // The record doesn't exist, return the end() iterator.
+ //
+ }
+ return end();
+ }
+
+ const_iterator find(const key_type& key) const
+ {
+ Freeze::Key k;
+ KeyCodec::write(key, k, _db->getCommunicator());
+
+ try
+ {
+ DBCursorPtr cursor = _db->getCursorAtKey(k);
+ return const_iterator(_db, cursor);
+ }
+ catch(const DBNotFoundException&)
+ {
+ //
+ // The record doesn't exist, return the end() iterator.
+ //
+ }
+ return end();
+ }
+
+ size_type count(const key_type& key) const
+ {
+ if(find(key) != end())
+ return 1;
+ return 0;
+ }
+
+ std::pair<iterator, iterator> equal_range(const key_type& key)
+ {
+ iterator p = find(key);
+ return std::pair<iterator,iterator>(p,p);
+ }
+
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const
+ {
+ const_iterator p = find(key);
+ return std::pair<const_iterator,const_iterator>(p,p);
+ }
+
+private:
+
+ DBPtr _db;
+};
+
+} // End namespace Freeze
+
+//
+// This is for MSVC.
+//
+# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
+namespace std
+{
+
+//XXX update
+template <class key_type, class mapped_type, class KeyCodec, class ValueCodec>
+inline pair<const key_type, const mapped_type>*
+value_type(const Freeze::DBIterator<key_type, mapped_type, KeyCodec, ValueCodec>&)
+{
+ return (pair<const key_type, const mapped_type>*)0;
+}
+
+template <class key_type, class mapped_type, class KeyCodec, class ValueCodec>
+inline pair<const key_type, const mapped_type>*
+value_type(const Freeze::ConstDBIterator<key_type, mapped_type, KeyCodec, ValueCodec>&)
+{
+ return (pair<const key_type, const mapped_type>*)0;
+}
+
+inline forward_iterator_tag iterator_category(const Freeze::DBIteratorBase&)
+{
+ return forward_iterator_tag();
+}
+
+inline ptrdiff_t* distance_type(const Freeze::DBIteratorBase&) { return (ptrdiff_t*) 0; }
+
+} // End namespace std
+
+#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
+
+#endif
diff --git a/cpp/include/Glacier/Glacier.h b/cpp/include/Glacier/Glacier.h index ac1e0426a34..1732ba70ff5 100644 --- a/cpp/include/Glacier/Glacier.h +++ b/cpp/include/Glacier/Glacier.h @@ -1,18 +1,18 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GLACIER_H -#define GLACIER_H - -#include <Glacier/Starter.h> -#include <Glacier/Session.h> -#include <Glacier/SessionManager.h> - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GLACIER_H
+#define GLACIER_H
+
+#include <Glacier/Starter.h>
+#include <Glacier/Session.h>
+#include <Glacier/SessionManager.h>
+
+#endif
diff --git a/cpp/include/Ice/Application.h b/cpp/include/Ice/Application.h index 124dec9b4bb..d7714c20906 100644 --- a/cpp/include/Ice/Application.h +++ b/cpp/include/Ice/Application.h @@ -1,70 +1,70 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_APPLICATION_H -#define ICE_APPLICATION_H - -#include <Ice/Ice.h> - -namespace Ice -{ - -class ICE_API Application : public IceUtil::noncopyable -{ -public: - - Application(); - virtual ~Application(); - - // - // This main() must be called by the global main(). main() - // initializes the Communicator, calls run() as a template method, - // and destroys the Communicator upon return from run(). It - // thereby handles all exceptions properly, i.e., error messages - // are printed if exceptions propagate to main(), and the - // Communicator is always destroyed, regardless of exceptions. - // - int main(int, char*[], const char* = 0); - virtual int run(int, char*[]) = 0; - - // - // Return the application name, i.e., argv[0]. - // - static const char* appName(); - - // - // One limitation of this class is that there can only be one - // Application instance, with one global Communicator, accessible - // with this communicator() operation. This limitiation is due to - // how the signal handling functions below operate. If you require - // multiple Communicators, then you cannot use this Application - // framework class. - // - static CommunicatorPtr communicator(); - - // - // These methods can be used to set a signal handler that calls - // communicator()->shutdown() upon interrupt (to make - // communicator()->waitForShutdown() return), to ignore - // interrupts, or to set interrupts back to default behavior. - // - static void shutdownOnInterrupt(); - static void ignoreInterrupt(); - static void defaultInterrupt(); - -private: - - static const char* _appName; - static CommunicatorPtr _communicator; -}; - -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_APPLICATION_H
+#define ICE_APPLICATION_H
+
+#include <Ice/Ice.h>
+
+namespace Ice
+{
+
+class ICE_API Application : public IceUtil::noncopyable
+{
+public:
+
+ Application();
+ virtual ~Application();
+
+ //
+ // This main() must be called by the global main(). main()
+ // initializes the Communicator, calls run() as a template method,
+ // and destroys the Communicator upon return from run(). It
+ // thereby handles all exceptions properly, i.e., error messages
+ // are printed if exceptions propagate to main(), and the
+ // Communicator is always destroyed, regardless of exceptions.
+ //
+ int main(int, char*[], const char* = 0);
+ virtual int run(int, char*[]) = 0;
+
+ //
+ // Return the application name, i.e., argv[0].
+ //
+ static const char* appName();
+
+ //
+ // One limitation of this class is that there can only be one
+ // Application instance, with one global Communicator, accessible
+ // with this communicator() operation. This limitiation is due to
+ // how the signal handling functions below operate. If you require
+ // multiple Communicators, then you cannot use this Application
+ // framework class.
+ //
+ static CommunicatorPtr communicator();
+
+ //
+ // These methods can be used to set a signal handler that calls
+ // communicator()->shutdown() upon interrupt (to make
+ // communicator()->waitForShutdown() return), to ignore
+ // interrupts, or to set interrupts back to default behavior.
+ //
+ static void shutdownOnInterrupt();
+ static void ignoreInterrupt();
+ static void defaultInterrupt();
+
+private:
+
+ static const char* _appName;
+ static CommunicatorPtr _communicator;
+};
+
+};
+
+#endif
diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index 155a0c839a9..8c841f8c4ba 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -1,145 +1,145 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_STREAM_H -#define ICE_STREAM_H - -#include <Ice/InstanceF.h> -#include <Ice/ObjectF.h> -#include <Ice/ProxyF.h> -#include <Ice/Buffer.h> -#include <Ice/ObjectFactoryF.h> - -namespace Ice -{ - -class UserException; - -} - -namespace IceInternal -{ - -class ICE_API BasicStream : public Buffer -{ -public: - - BasicStream(const InstancePtr&); - - InstancePtr instance() const; - - void swap(BasicStream&); - - void resize(int); - void reserve(int); - - void startWriteEncaps(); - void endWriteEncaps(); - void startReadEncaps(); - void endReadEncaps(); - void checkReadEncaps(); - Ice::Int getReadEncapsSize(); - void skipEncaps(); - - void writeSize(Ice::Int); - void readSize(Ice::Int&); - - void writeBlob(const std::vector<Ice::Byte>&); - void readBlob(std::vector<Ice::Byte>&, Ice::Int); - - // Performance critical function inlined, as writing single bytes - // is used in many places in Ice code. - void write(Ice::Byte v) - { - b.push_back(v); - } - void write(const std::vector<Ice::Byte>&); - void read(Ice::Byte&); - void read(std::vector<Ice::Byte>&); - - // Performance critical function inlined, as writing single bools - // is used in many places in Ice code. - void write(bool v) - { - b.push_back(static_cast<Ice::Byte>(v)); - } - void write(const std::vector<bool>&); - void read(bool&); - void read(std::vector<bool>&); - - void write(Ice::Short); - void write(const std::vector<Ice::Short>&); - void read(Ice::Short&); - void read(std::vector<Ice::Short>&); - - void write(Ice::Int); - void write(const std::vector<Ice::Int>&); - void read(Ice::Int&); - void read(std::vector<Ice::Int>&); - - void write(Ice::Long); - void write(const std::vector<Ice::Long>&); - void read(Ice::Long&); - void read(std::vector<Ice::Long>&); - - void write(Ice::Float); - void write(const std::vector<Ice::Float>&); - void read(Ice::Float&); - void read(std::vector<Ice::Float>&); - - void write(Ice::Double); - void write(const std::vector<Ice::Double>&); - void read(Ice::Double&); - void read(std::vector<Ice::Double>&); - - void write(const std::string&); - void write(const std::vector<std::string>&); - void read(std::string&); - void read(std::vector<std::string>&); - - void write(const Ice::ObjectPrx&); - void read(Ice::ObjectPrx&); - - void write(const Ice::ObjectPtr&); - void read(const std::string&, const ::Ice::ObjectFactoryPtr&, Ice::ObjectPtr&); - - void write(const Ice::UserException&); - ::Ice::Int throwException(const std::string*, const std::string*); - -private: - - // - // Optimization. The instance may not be deleted while a - // stack-allocated Incoming still holds it. - // - const InstancePtr& _instance; - - struct ReadEncaps - { - Container::size_type start; - Ice::Byte encoding; - std::vector<Ice::ObjectPtr> objectsRead; - }; - - struct WriteEncaps - { - Container::size_type start; - std::map<Ice::ObjectPtr, Ice::Int> objectsWritten; - }; - - std::vector<ReadEncaps> _readEncapsStack; - std::vector<WriteEncaps> _writeEncapsStack; - ReadEncaps* _currentReadEncaps; - WriteEncaps* _currentWriteEncaps; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_STREAM_H
+#define ICE_STREAM_H
+
+#include <Ice/InstanceF.h>
+#include <Ice/ObjectF.h>
+#include <Ice/ProxyF.h>
+#include <Ice/Buffer.h>
+#include <Ice/ObjectFactoryF.h>
+
+namespace Ice
+{
+
+class UserException;
+
+}
+
+namespace IceInternal
+{
+
+class ICE_API BasicStream : public Buffer
+{
+public:
+
+ BasicStream(const InstancePtr&);
+
+ InstancePtr instance() const;
+
+ void swap(BasicStream&);
+
+ void resize(int);
+ void reserve(int);
+
+ void startWriteEncaps();
+ void endWriteEncaps();
+ void startReadEncaps();
+ void endReadEncaps();
+ void checkReadEncaps();
+ Ice::Int getReadEncapsSize();
+ void skipEncaps();
+
+ void writeSize(Ice::Int);
+ void readSize(Ice::Int&);
+
+ void writeBlob(const std::vector<Ice::Byte>&);
+ void readBlob(std::vector<Ice::Byte>&, Ice::Int);
+
+ // Performance critical function inlined, as writing single bytes
+ // is used in many places in Ice code.
+ void write(Ice::Byte v)
+ {
+ b.push_back(v);
+ }
+ void write(const std::vector<Ice::Byte>&);
+ void read(Ice::Byte&);
+ void read(std::vector<Ice::Byte>&);
+
+ // Performance critical function inlined, as writing single bools
+ // is used in many places in Ice code.
+ void write(bool v)
+ {
+ b.push_back(static_cast<Ice::Byte>(v));
+ }
+ void write(const std::vector<bool>&);
+ void read(bool&);
+ void read(std::vector<bool>&);
+
+ void write(Ice::Short);
+ void write(const std::vector<Ice::Short>&);
+ void read(Ice::Short&);
+ void read(std::vector<Ice::Short>&);
+
+ void write(Ice::Int);
+ void write(const std::vector<Ice::Int>&);
+ void read(Ice::Int&);
+ void read(std::vector<Ice::Int>&);
+
+ void write(Ice::Long);
+ void write(const std::vector<Ice::Long>&);
+ void read(Ice::Long&);
+ void read(std::vector<Ice::Long>&);
+
+ void write(Ice::Float);
+ void write(const std::vector<Ice::Float>&);
+ void read(Ice::Float&);
+ void read(std::vector<Ice::Float>&);
+
+ void write(Ice::Double);
+ void write(const std::vector<Ice::Double>&);
+ void read(Ice::Double&);
+ void read(std::vector<Ice::Double>&);
+
+ void write(const std::string&);
+ void write(const std::vector<std::string>&);
+ void read(std::string&);
+ void read(std::vector<std::string>&);
+
+ void write(const Ice::ObjectPrx&);
+ void read(Ice::ObjectPrx&);
+
+ void write(const Ice::ObjectPtr&);
+ void read(const std::string&, const ::Ice::ObjectFactoryPtr&, Ice::ObjectPtr&);
+
+ void write(const Ice::UserException&);
+ ::Ice::Int throwException(const std::string*, const std::string*);
+
+private:
+
+ //
+ // Optimization. The instance may not be deleted while a
+ // stack-allocated Incoming still holds it.
+ //
+ const InstancePtr& _instance;
+
+ struct ReadEncaps
+ {
+ Container::size_type start;
+ Ice::Byte encoding;
+ std::vector<Ice::ObjectPtr> objectsRead;
+ };
+
+ struct WriteEncaps
+ {
+ Container::size_type start;
+ std::map<Ice::ObjectPtr, Ice::Int> objectsWritten;
+ };
+
+ std::vector<ReadEncaps> _readEncapsStack;
+ std::vector<WriteEncaps> _writeEncapsStack;
+ ReadEncaps* _currentReadEncaps;
+ WriteEncaps* _currentWriteEncaps;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Buffer.h b/cpp/include/Ice/Buffer.h index a9a93cef5d9..f538283c1f5 100644 --- a/cpp/include/Ice/Buffer.h +++ b/cpp/include/Ice/Buffer.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_BUFFER_H -#define ICE_BUFFER_H - -#include <Ice/Config.h> - -namespace IceInternal -{ - -class ICE_API Buffer : public ::IceUtil::noncopyable -{ -public: - - // TODO: Should not be inline, as this is not performance critical. - Buffer() - { - b.reserve(1000); - i = b.begin(); - } - - typedef std::vector<Ice::Byte> Container; - Container b; - Container::iterator i; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_BUFFER_H
+#define ICE_BUFFER_H
+
+#include <Ice/Config.h>
+
+namespace IceInternal
+{
+
+class ICE_API Buffer : public ::IceUtil::noncopyable
+{
+public:
+
+ // TODO: Should not be inline, as this is not performance critical.
+ Buffer()
+ {
+ b.reserve(1000);
+ i = b.begin();
+ }
+
+ typedef std::vector<Ice::Byte> Container;
+ Container b;
+ Container::iterator i;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h index 2e4eff7d4d2..4bf6a85ccc1 100644 --- a/cpp/include/Ice/Config.h +++ b/cpp/include/Ice/Config.h @@ -1,106 +1,106 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONFIG_H -#define ICE_CONFIG_H - -#include <IceUtil/Config.h> - -// -// Some include files we need almost everywhere -// -#include <cerrno> -#include <cstdio> -#include <cstring> -#include <string> -#include <vector> -#include <map> - -// -// Define the Ice and IceInternal namespace, so that we can use the following -// everywhere in our code: -// -// using namespace Ice; -// using namespace IceInternal; -// -namespace Ice -{ -} - -namespace IceInternal -{ -} - -#if defined(_WIN32) - -# ifdef ICE_API_EXPORTS -# define ICE_API __declspec(dllexport) -# else -# define ICE_API __declspec(dllimport) -# endif - -# ifdef ICE_PROTOCOL_API_EXPORTS -# define ICE_PROTOCOL_API __declspec(dllexport) -# else -# define ICE_PROTOCOL_API __declspec(dllimport) -# endif - -# include <process.h> - -namespace Ice -{ - -typedef char Byte; -typedef short Short; -typedef int Int; -typedef __int64 Long; -typedef float Float; -typedef double Double; - -} - -// TODO: Should not be inline, this is not performance critical. -inline int getSystemErrno() { return GetLastError(); } -inline int getSocketErrno() { return WSAGetLastError(); } -inline int getDNSErrno() { return WSAGetLastError(); } - -#elif defined(__linux__) && defined(i386) - -# include <sys/types.h> -# include <unistd.h> - -# define ICE_API /**/ -# define ICE_PROTOCOL_API /**/ - -namespace Ice -{ - -typedef char Byte; -typedef short Short; -typedef int Int; -typedef long long Long; -typedef float Float; -typedef double Double; - -} - -// TODO: Should not be inline, this is not performance critical. -inline int getSystemErrno() { return errno; } -inline int getSocketErrno() { return errno; } -extern int h_errno; -inline int getDNSErrno() { return h_errno; } - -#else - -# error "Unsupported operating system or platform!" - -#endif - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONFIG_H
+#define ICE_CONFIG_H
+
+#include <IceUtil/Config.h>
+
+//
+// Some include files we need almost everywhere
+//
+#include <cerrno>
+#include <cstdio>
+#include <cstring>
+#include <string>
+#include <vector>
+#include <map>
+
+//
+// Define the Ice and IceInternal namespace, so that we can use the following
+// everywhere in our code:
+//
+// using namespace Ice;
+// using namespace IceInternal;
+//
+namespace Ice
+{
+}
+
+namespace IceInternal
+{
+}
+
+#if defined(_WIN32)
+
+# ifdef ICE_API_EXPORTS
+# define ICE_API __declspec(dllexport)
+# else
+# define ICE_API __declspec(dllimport)
+# endif
+
+# ifdef ICE_PROTOCOL_API_EXPORTS
+# define ICE_PROTOCOL_API __declspec(dllexport)
+# else
+# define ICE_PROTOCOL_API __declspec(dllimport)
+# endif
+
+# include <process.h>
+
+namespace Ice
+{
+
+typedef char Byte;
+typedef short Short;
+typedef int Int;
+typedef __int64 Long;
+typedef float Float;
+typedef double Double;
+
+}
+
+// TODO: Should not be inline, this is not performance critical.
+inline int getSystemErrno() { return GetLastError(); }
+inline int getSocketErrno() { return WSAGetLastError(); }
+inline int getDNSErrno() { return WSAGetLastError(); }
+
+#elif defined(__linux__) && defined(i386)
+
+# include <sys/types.h>
+# include <unistd.h>
+
+# define ICE_API /**/
+# define ICE_PROTOCOL_API /**/
+
+namespace Ice
+{
+
+typedef char Byte;
+typedef short Short;
+typedef int Int;
+typedef long long Long;
+typedef float Float;
+typedef double Double;
+
+}
+
+// TODO: Should not be inline, this is not performance critical.
+inline int getSystemErrno() { return errno; }
+inline int getSocketErrno() { return errno; }
+extern int h_errno;
+inline int getDNSErrno() { return h_errno; }
+
+#else
+
+# error "Unsupported operating system or platform!"
+
+#endif
+
+#endif
diff --git a/cpp/include/Ice/ConnectionF.h b/cpp/include/Ice/ConnectionF.h index 81e86dd962b..df7e98ec0d8 100644 --- a/cpp/include/Ice/ConnectionF.h +++ b/cpp/include/Ice/ConnectionF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONNECTION_F_H -#define ICE_CONNECTION_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Connection; -ICE_API void incRef(Connection*); -ICE_API void decRef(Connection*); -typedef IceInternal::Handle<Connection> ConnectionPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONNECTION_F_H
+#define ICE_CONNECTION_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Connection;
+ICE_API void incRef(Connection*);
+ICE_API void decRef(Connection*);
+typedef IceInternal::Handle<Connection> ConnectionPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ConnectionFactoryF.h b/cpp/include/Ice/ConnectionFactoryF.h index fbc41654338..b894aa7d8bb 100644 --- a/cpp/include/Ice/ConnectionFactoryF.h +++ b/cpp/include/Ice/ConnectionFactoryF.h @@ -1,31 +1,31 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONNECTION_FACTORY_F_H -#define ICE_CONNECTION_FACTORY_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class OutgoingConnectionFactory; -ICE_API void incRef(OutgoingConnectionFactory*); -ICE_API void decRef(OutgoingConnectionFactory*); -typedef IceInternal::Handle<OutgoingConnectionFactory> OutgoingConnectionFactoryPtr; - -class IncomingConnectionFactory; -ICE_API void incRef(IncomingConnectionFactory*); -ICE_API void decRef(IncomingConnectionFactory*); -typedef IceInternal::Handle<IncomingConnectionFactory> IncomingConnectionFactoryPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONNECTION_FACTORY_F_H
+#define ICE_CONNECTION_FACTORY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class OutgoingConnectionFactory;
+ICE_API void incRef(OutgoingConnectionFactory*);
+ICE_API void decRef(OutgoingConnectionFactory*);
+typedef IceInternal::Handle<OutgoingConnectionFactory> OutgoingConnectionFactoryPtr;
+
+class IncomingConnectionFactory;
+ICE_API void incRef(IncomingConnectionFactory*);
+ICE_API void decRef(IncomingConnectionFactory*);
+typedef IceInternal::Handle<IncomingConnectionFactory> IncomingConnectionFactoryPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Direct.h b/cpp/include/Ice/Direct.h index adc532ef524..ae9a3c500b4 100644 --- a/cpp/include/Ice/Direct.h +++ b/cpp/include/Ice/Direct.h @@ -1,45 +1,45 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DIRECT_H -#define ICE_DIRECT_H - -#include <Ice/ObjectAdapterF.h> -#include <Ice/ServantLocatorF.h> -#include <Ice/ReferenceF.h> -#include <Ice/ObjectF.h> -#include <Ice/LocalObjectF.h> -#include <Ice/Current.h> - -namespace IceInternal -{ - -class ICE_API Direct : public ::IceUtil::noncopyable -{ -public: - - Direct(const ::Ice::ObjectAdapterPtr&, const ::Ice::Current&); - ~Direct(); - - const ::Ice::ObjectPtr& facetServant(); - -private: - - const ::Ice::ObjectAdapterPtr& _adapter; - ::Ice::Current _current; - ::Ice::ObjectPtr _servant; - ::Ice::ObjectPtr _facetServant; - ::Ice::ServantLocatorPtr _locator; - ::Ice::LocalObjectPtr _cookie; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DIRECT_H
+#define ICE_DIRECT_H
+
+#include <Ice/ObjectAdapterF.h>
+#include <Ice/ServantLocatorF.h>
+#include <Ice/ReferenceF.h>
+#include <Ice/ObjectF.h>
+#include <Ice/LocalObjectF.h>
+#include <Ice/Current.h>
+
+namespace IceInternal
+{
+
+class ICE_API Direct : public ::IceUtil::noncopyable
+{
+public:
+
+ Direct(const ::Ice::ObjectAdapterPtr&, const ::Ice::Current&);
+ ~Direct();
+
+ const ::Ice::ObjectPtr& facetServant();
+
+private:
+
+ const ::Ice::ObjectAdapterPtr& _adapter;
+ ::Ice::Current _current;
+ ::Ice::ObjectPtr _servant;
+ ::Ice::ObjectPtr _facetServant;
+ ::Ice::ServantLocatorPtr _locator;
+ ::Ice::LocalObjectPtr _cookie;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/DynamicLibrary.h b/cpp/include/Ice/DynamicLibrary.h index ac520e2f946..fd69f5a4fbd 100644 --- a/cpp/include/Ice/DynamicLibrary.h +++ b/cpp/include/Ice/DynamicLibrary.h @@ -1,93 +1,93 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DYNAMIC_LIBRARY_H -#define ICE_DYNAMIC_LIBRARY_H - -#include <Ice/DynamicLibraryF.h> -#include <IceUtil/Shared.h> - -namespace IceInternal -{ - -class ICE_API DynamicLibrary : public ::IceUtil::Shared -{ -public: - - DynamicLibrary(); - ~DynamicLibrary(); - -#ifdef _WIN32 - typedef FARPROC symbol_type; -#else - typedef void* symbol_type; -#endif - - // - // Load an entry point. This is really a convenience function - // which combines calls to load() and getSymbol(). However, - // it does add some value. - // - // An entry point has the following format: - // - // name[,version]:function - // - // The name of the library is constructed from the given - // information. If no version is supplied, the Ice version - // is used. For example, consider the following entry point: - // - // foo:create - // - // This would result in libfoo.so.0.0.1 (Unix) and foo001.dll (Windows), - // where the Ice version is 0.0.1. - // - // Now consider this entry point: - // - // foo,1.1:create - // - // The library names in this case are libfoo.so.1.1 (Unix) and - // foo11.dll (Windows). - // - // On Windows platforms, a 'd' is appended to the version for debug - // builds. - // - // Returns 0 if a failure occurred. - // - symbol_type loadEntryPoint(const std::string&); - - // - // Open a library with the given path. - // - bool load(const std::string&); - - // - // Retrieve a symbol from the library. Returns 0 if no match is found. - // - symbol_type getSymbol(const std::string&); - - // - // Get the error message for the last failure. - // - const std::string& getErrorMessage() const; - -private: - -#ifdef _WIN32 - HINSTANCE _hnd; -#else - void* _hnd; -#endif - - std::string _err; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DYNAMIC_LIBRARY_H
+#define ICE_DYNAMIC_LIBRARY_H
+
+#include <Ice/DynamicLibraryF.h>
+#include <IceUtil/Shared.h>
+
+namespace IceInternal
+{
+
+class ICE_API DynamicLibrary : public ::IceUtil::Shared
+{
+public:
+
+ DynamicLibrary();
+ ~DynamicLibrary();
+
+#ifdef _WIN32
+ typedef FARPROC symbol_type;
+#else
+ typedef void* symbol_type;
+#endif
+
+ //
+ // Load an entry point. This is really a convenience function
+ // which combines calls to load() and getSymbol(). However,
+ // it does add some value.
+ //
+ // An entry point has the following format:
+ //
+ // name[,version]:function
+ //
+ // The name of the library is constructed from the given
+ // information. If no version is supplied, the Ice version
+ // is used. For example, consider the following entry point:
+ //
+ // foo:create
+ //
+ // This would result in libfoo.so.0.0.1 (Unix) and foo001.dll (Windows),
+ // where the Ice version is 0.0.1.
+ //
+ // Now consider this entry point:
+ //
+ // foo,1.1:create
+ //
+ // The library names in this case are libfoo.so.1.1 (Unix) and
+ // foo11.dll (Windows).
+ //
+ // On Windows platforms, a 'd' is appended to the version for debug
+ // builds.
+ //
+ // Returns 0 if a failure occurred.
+ //
+ symbol_type loadEntryPoint(const std::string&);
+
+ //
+ // Open a library with the given path.
+ //
+ bool load(const std::string&);
+
+ //
+ // Retrieve a symbol from the library. Returns 0 if no match is found.
+ //
+ symbol_type getSymbol(const std::string&);
+
+ //
+ // Get the error message for the last failure.
+ //
+ const std::string& getErrorMessage() const;
+
+private:
+
+#ifdef _WIN32
+ HINSTANCE _hnd;
+#else
+ void* _hnd;
+#endif
+
+ std::string _err;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/DynamicLibraryF.h b/cpp/include/Ice/DynamicLibraryF.h index 56c8e503d95..7a992ea0334 100644 --- a/cpp/include/Ice/DynamicLibraryF.h +++ b/cpp/include/Ice/DynamicLibraryF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DYNAMIC_LIBRARY_F_H -#define ICE_DYNAMIC_LIBRARY_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class DynamicLibrary; -ICE_API void incRef(DynamicLibrary*); -ICE_API void decRef(DynamicLibrary*); -typedef Handle<DynamicLibrary> DynamicLibraryPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DYNAMIC_LIBRARY_F_H
+#define ICE_DYNAMIC_LIBRARY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class DynamicLibrary;
+ICE_API void incRef(DynamicLibrary*);
+ICE_API void decRef(DynamicLibrary*);
+typedef Handle<DynamicLibrary> DynamicLibraryPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/EndpointF.h b/cpp/include/Ice/EndpointF.h index 2ccebad8c67..6a114027b23 100644 --- a/cpp/include/Ice/EndpointF.h +++ b/cpp/include/Ice/EndpointF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ENDPOINT_F_H -#define ICE_ENDPOINT_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Endpoint; -ICE_PROTOCOL_API void incRef(Endpoint*); -ICE_PROTOCOL_API void decRef(Endpoint*); -typedef IceInternal::Handle<Endpoint> EndpointPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ENDPOINT_F_H
+#define ICE_ENDPOINT_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Endpoint;
+ICE_PROTOCOL_API void incRef(Endpoint*);
+ICE_PROTOCOL_API void decRef(Endpoint*);
+typedef IceInternal::Handle<Endpoint> EndpointPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/EndpointFactory.h b/cpp/include/Ice/EndpointFactory.h index 43715fc5f29..9da548d5e9a 100644 --- a/cpp/include/Ice/EndpointFactory.h +++ b/cpp/include/Ice/EndpointFactory.h @@ -1,42 +1,42 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ENDPOINT_FACTORY_H -#define ICE_ENDPOINT_FACTORY_H - -#include <IceUtil/Shared.h> -#include <Ice/EndpointF.h> -#include <Ice/EndpointFactoryF.h> - -namespace IceInternal -{ - -class BasicStream; - -class ICE_PROTOCOL_API EndpointFactory : public ::IceUtil::Shared -{ -public: - - virtual ~EndpointFactory(); - - virtual ::Ice::Short type() const = 0; - virtual const ::std::string& protocol() const = 0; - virtual EndpointPtr create(const std::string&) const = 0; - virtual EndpointPtr read(BasicStream*) const = 0; - virtual void destroy() = 0; - -protected: - - EndpointFactory(); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ENDPOINT_FACTORY_H
+#define ICE_ENDPOINT_FACTORY_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/EndpointF.h>
+#include <Ice/EndpointFactoryF.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+class ICE_PROTOCOL_API EndpointFactory : public ::IceUtil::Shared
+{
+public:
+
+ virtual ~EndpointFactory();
+
+ virtual ::Ice::Short type() const = 0;
+ virtual const ::std::string& protocol() const = 0;
+ virtual EndpointPtr create(const std::string&) const = 0;
+ virtual EndpointPtr read(BasicStream*) const = 0;
+ virtual void destroy() = 0;
+
+protected:
+
+ EndpointFactory();
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/EndpointFactoryF.h b/cpp/include/Ice/EndpointFactoryF.h index 11e231e1faa..540745c96ec 100644 --- a/cpp/include/Ice/EndpointFactoryF.h +++ b/cpp/include/Ice/EndpointFactoryF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ENDPOINT_FACTORY_F_H -#define ICE_ENDPOINT_FACTORY_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class EndpointFactory; -ICE_PROTOCOL_API void incRef(EndpointFactory*); -ICE_PROTOCOL_API void decRef(EndpointFactory*); -typedef Handle<EndpointFactory> EndpointFactoryPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ENDPOINT_FACTORY_F_H
+#define ICE_ENDPOINT_FACTORY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class EndpointFactory;
+ICE_PROTOCOL_API void incRef(EndpointFactory*);
+ICE_PROTOCOL_API void decRef(EndpointFactory*);
+typedef Handle<EndpointFactory> EndpointFactoryPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index faff50b3b09..bb2dc1ab114 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -1,75 +1,75 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_EXCEPTION_H -#define ICE_EXCEPTION_H - -#include <IceUtil/Exception.h> -#include <Ice/Config.h> -#include <Ice/Handle.h> - -// -// The manual forward declaration of ::Ice::Stream is necesary since -// Ice/StreamF.h includes Ice/Exception.h. -// -namespace Ice -{ - -class Stream; - -} - -namespace IceInternal -{ - -class BasicStream; - -ICE_API void incRef(::Ice::Stream*); -ICE_API void decRef(::Ice::Stream*); - -} - -namespace Ice -{ - -typedef ::IceInternal::Handle< ::Ice::Stream> StreamPtr; - -typedef IceUtil::Exception Exception; - -class LocalException : public IceUtil::Exception -{ -public: - - ICE_API LocalException(const char*, int); - virtual std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; - virtual void ice_throw() const = 0; -}; - -class ICE_API UserException : public IceUtil::Exception -{ -public: - - virtual std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; - virtual void ice_throw() const = 0; - - virtual const std::string* __getExceptionIds() const = 0; - virtual void __write(::IceInternal::BasicStream*) const = 0; - virtual void __read(::IceInternal::BasicStream*) = 0; - virtual void __marshal(const StreamPtr&) const = 0; - virtual void __unmarshal(const StreamPtr&) = 0; - - void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_EXCEPTION_H
+#define ICE_EXCEPTION_H
+
+#include <IceUtil/Exception.h>
+#include <Ice/Config.h>
+#include <Ice/Handle.h>
+
+//
+// The manual forward declaration of ::Ice::Stream is necesary since
+// Ice/StreamF.h includes Ice/Exception.h.
+//
+namespace Ice
+{
+
+class Stream;
+
+}
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+ICE_API void incRef(::Ice::Stream*);
+ICE_API void decRef(::Ice::Stream*);
+
+}
+
+namespace Ice
+{
+
+typedef ::IceInternal::Handle< ::Ice::Stream> StreamPtr;
+
+typedef IceUtil::Exception Exception;
+
+class LocalException : public IceUtil::Exception
+{
+public:
+
+ ICE_API LocalException(const char*, int);
+ virtual std::string ice_name() const = 0;
+ virtual Exception* ice_clone() const = 0;
+ virtual void ice_throw() const = 0;
+};
+
+class ICE_API UserException : public IceUtil::Exception
+{
+public:
+
+ virtual std::string ice_name() const = 0;
+ virtual Exception* ice_clone() const = 0;
+ virtual void ice_throw() const = 0;
+
+ virtual const std::string* __getExceptionIds() const = 0;
+ virtual void __write(::IceInternal::BasicStream*) const = 0;
+ virtual void __read(::IceInternal::BasicStream*) = 0;
+ virtual void __marshal(const StreamPtr&) const = 0;
+ virtual void __unmarshal(const StreamPtr&) = 0;
+
+ void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&);
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Functional.h b/cpp/include/Ice/Functional.h index b0db10c30b8..624d4858b12 100644 --- a/cpp/include/Ice/Functional.h +++ b/cpp/include/Ice/Functional.h @@ -1,139 +1,139 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_FUNCTIONAL_H -#define ICE_FUNCTIONAL_H - -#include <IceUtil/Functional.h> -#include <Ice/Handle.h> - -// ---------------------------------------------------------------------- -// Inline functions that return function objects that work with -// IceInternal::Handle -// ---------------------------------------------------------------------- - -namespace Ice -{ - -template<class R, class T> -inline ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> > -memFun(R (T::*p)(void)) -{ - return ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> >(p); -} - -template<class R, class T, class A> -inline ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A> -memFun1(R (T::*p)(A)) -{ - return ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A>(p); -} - -template<class T> -inline ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> > -voidMemFun(void (T::*p)(void)) -{ - return ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> >(p); -} - -template<class T, class A> -inline ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A> -voidMemFun1(void (T::*p)(A)) -{ - return ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A>(p); -} - -template<class R, class K, class T> -inline ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> > -secondMemFun(R (T::*p)(void)) -{ - return ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> >(p); -} - -template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A> -secondMemFun1(R (T::*p)(A)) -{ - return ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p); -} - -template<class K, class T> -inline ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> > -secondVoidMemFun(void (T::*p)(void)) -{ - return ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> >(p); -} - -template<class K, class T, class A> -inline ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A> -secondVoidMemFun1(void (T::*p)(A)) -{ - return ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p); -} - -template<class R, class T> -inline ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> > -constMemFun(R (T::*p)(void) const) -{ - return ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> >(p); -} - -template<class R, class T, class A> -inline ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A> -constMemFun1(R (T::*p)(A) const) -{ - return ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A>(p); -} - -template<class T> -inline ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> > -constVoidMemFun(void (T::*p)(void) const) -{ - return ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> >(p); -} - -template<class T, class A> -inline ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A> -constVoidMemFun1(void (T::*p)(A) const) -{ - return ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A>(p); -} - -template<class R, class K, class T> -inline ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> > -secondConstMemFun(R (T::*p)(void) const) -{ - return ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> >(p); -} - -template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A> -secondConstMemFun1(R (T::*p)(A) const) -{ - return ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p); -} - -template<class K, class T> -inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> > -secondConstVoidMemFun(void (T::*p)(void) const) -{ - return ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> >(p); -} - -template<class K, class T, class A> -inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A> -secondConstVoidMemFun1(void (T::*p)(A) const) -{ - return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p); -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_FUNCTIONAL_H
+#define ICE_FUNCTIONAL_H
+
+#include <IceUtil/Functional.h>
+#include <Ice/Handle.h>
+
+// ----------------------------------------------------------------------
+// Inline functions that return function objects that work with
+// IceInternal::Handle
+// ----------------------------------------------------------------------
+
+namespace Ice
+{
+
+template<class R, class T>
+inline ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> >
+memFun(R (T::*p)(void))
+{
+ return ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class R, class T, class A>
+inline ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A>
+memFun1(R (T::*p)(A))
+{
+ return ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class T>
+inline ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> >
+voidMemFun(void (T::*p)(void))
+{
+ return ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class T, class A>
+inline ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A>
+voidMemFun1(void (T::*p)(A))
+{
+ return ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class R, class K, class T>
+inline ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> >
+secondMemFun(R (T::*p)(void))
+{
+ return ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class R, class K, class T, class A>
+inline ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A>
+secondMemFun1(R (T::*p)(A))
+{
+ return ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class K, class T>
+inline ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> >
+secondVoidMemFun(void (T::*p)(void))
+{
+ return ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class K, class T, class A>
+inline ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>
+secondVoidMemFun1(void (T::*p)(A))
+{
+ return ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class R, class T>
+inline ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> >
+constMemFun(R (T::*p)(void) const)
+{
+ return ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class R, class T, class A>
+inline ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A>
+constMemFun1(R (T::*p)(A) const)
+{
+ return ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class T>
+inline ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> >
+constVoidMemFun(void (T::*p)(void) const)
+{
+ return ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class T, class A>
+inline ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A>
+constVoidMemFun1(void (T::*p)(A) const)
+{
+ return ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class R, class K, class T>
+inline ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> >
+secondConstMemFun(R (T::*p)(void) const)
+{
+ return ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class R, class K, class T, class A>
+inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A>
+secondConstMemFun1(R (T::*p)(A) const)
+{
+ return ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p);
+}
+
+template<class K, class T>
+inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> >
+secondConstVoidMemFun(void (T::*p)(void) const)
+{
+ return ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> >(p);
+}
+
+template<class K, class T, class A>
+inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>
+secondConstVoidMemFun1(void (T::*p)(A) const)
+{
+ return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p);
+}
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Handle.h b/cpp/include/Ice/Handle.h index 5672c0527d2..59d0e531f06 100644 --- a/cpp/include/Ice/Handle.h +++ b/cpp/include/Ice/Handle.h @@ -1,190 +1,190 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_HANDLE_H -#define ICE_HANDLE_H - -#include <IceUtil/Handle.h> -#include <Ice/Config.h> - -// -// "Handle" or "smart pointer" class for classes derived from -// IceUtil::Shared or IceUtil::SimpleShared. -// -// In constrast to IceUtil::Handle, IceInternal::Handle requires the -// declaration of the two global operations IceInternal::incRef(T*) -// and IceInternal::decRef(T*). The use of global operations allows -// this template to be used for types which are declared but not -// defined, provided that the two above mentioned operations are -// declared. -// - -namespace IceInternal -{ - -template<typename T> -class Handle : public ::IceUtil::HandleBase<T> -{ -public: - - Handle(T* p = 0) - { - _ptr = p; - - if (_ptr) - { - incRef(_ptr); - } - } - - template<typename Y> - Handle(const Handle<Y>& r) - { - _ptr = r._ptr; - - if (_ptr) - { - incRef(_ptr); - } - } - - template<typename Y> - Handle(const ::IceUtil::Handle<Y>& r) - { - _ptr = r._ptr; - - if (_ptr) - { - incRef(_ptr); - } - } - -#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? - template<> - Handle(const Handle<T>& r) -#else - Handle(const Handle& r) -#endif - { - _ptr = r._ptr; - - if (_ptr) - { - incRef(_ptr); - } - } - - ~Handle() - { - if (_ptr) - { - decRef(_ptr); - } - } - - Handle& operator=(T* p) - { - if (_ptr != p) - { - if (p) - { - incRef(p); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = p; - } - return *this; - } - - template<typename Y> - Handle& operator=(const Handle<Y>& r) - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - incRef(r._ptr); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = r._ptr; - } - return *this; - } - - template<typename Y> - Handle& operator=(const ::IceUtil::Handle<Y>& r) - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - incRef(r._ptr); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = r._ptr; - } - return *this; - } - -#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? - template<> - Handle& operator=(const Handle<T>& r) -#else - Handle& operator=(const Handle& r) -#endif - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - incRef(r._ptr); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = r._ptr; - } - return *this; - } - - template<class Y> - static Handle dynamicCast(const ::IceUtil::HandleBase<Y>& r) - { - return Handle(dynamic_cast<T*>(r._ptr)); - } - - template<class Y> - static Handle dynamicCast(Y* p) - { - return Handle(dynamic_cast<T*>(p)); - } -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_HANDLE_H
+#define ICE_HANDLE_H
+
+#include <IceUtil/Handle.h>
+#include <Ice/Config.h>
+
+//
+// "Handle" or "smart pointer" class for classes derived from
+// IceUtil::Shared or IceUtil::SimpleShared.
+//
+// In constrast to IceUtil::Handle, IceInternal::Handle requires the
+// declaration of the two global operations IceInternal::incRef(T*)
+// and IceInternal::decRef(T*). The use of global operations allows
+// this template to be used for types which are declared but not
+// defined, provided that the two above mentioned operations are
+// declared.
+//
+
+namespace IceInternal
+{
+
+template<typename T>
+class Handle : public ::IceUtil::HandleBase<T>
+{
+public:
+
+ Handle(T* p = 0)
+ {
+ _ptr = p;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+ template<typename Y>
+ Handle(const Handle<Y>& r)
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+ template<typename Y>
+ Handle(const ::IceUtil::Handle<Y>& r)
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
+ template<>
+ Handle(const Handle<T>& r)
+#else
+ Handle(const Handle& r)
+#endif
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+ ~Handle()
+ {
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+ }
+
+ Handle& operator=(T* p)
+ {
+ if(_ptr != p)
+ {
+ if(p)
+ {
+ incRef(p);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = p;
+ }
+ return *this;
+ }
+
+ template<typename Y>
+ Handle& operator=(const Handle<Y>& r)
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ incRef(r._ptr);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+ template<typename Y>
+ Handle& operator=(const ::IceUtil::Handle<Y>& r)
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ incRef(r._ptr);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
+ template<>
+ Handle& operator=(const Handle<T>& r)
+#else
+ Handle& operator=(const Handle& r)
+#endif
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ incRef(r._ptr);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+ template<class Y>
+ static Handle dynamicCast(const ::IceUtil::HandleBase<Y>& r)
+ {
+ return Handle(dynamic_cast<T*>(r._ptr));
+ }
+
+ template<class Y>
+ static Handle dynamicCast(Y* p)
+ {
+ return Handle(dynamic_cast<T*>(p));
+ }
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index b9912476fcb..4f1922dd130 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -1,30 +1,30 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ICE_H -#define ICE_ICE_H - -#include <Ice/Initialize.h> -#include <Ice/LocalException.h> -#include <Ice/Properties.h> -#include <Ice/Logger.h> -#include <Ice/LoggerUtil.h> -#include <Ice/Communicator.h> -#include <Ice/ObjectFactory.h> -#include <Ice/UserExceptionFactory.h> -#include <Ice/ObjectAdapter.h> -#include <Ice/ServantLocator.h> -#include <Ice/Proxy.h> -#include <Ice/Object.h> -#include <Ice/IdentityUtil.h> - -//#include <Ice/Stream.h> - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ICE_H
+#define ICE_ICE_H
+
+#include <Ice/Initialize.h>
+#include <Ice/LocalException.h>
+#include <Ice/Properties.h>
+#include <Ice/Logger.h>
+#include <Ice/LoggerUtil.h>
+#include <Ice/Communicator.h>
+#include <Ice/ObjectFactory.h>
+#include <Ice/UserExceptionFactory.h>
+#include <Ice/ObjectAdapter.h>
+#include <Ice/ServantLocator.h>
+#include <Ice/Proxy.h>
+#include <Ice/Object.h>
+#include <Ice/IdentityUtil.h>
+
+//#include <Ice/Stream.h>
+
+#endif
diff --git a/cpp/include/Ice/IdentityUtil.h b/cpp/include/Ice/IdentityUtil.h index 5706aa9df90..01620c53b7f 100644 --- a/cpp/include/Ice/IdentityUtil.h +++ b/cpp/include/Ice/IdentityUtil.h @@ -1,25 +1,25 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_IDENTITY_UTIL_H -#define ICE_IDENTITY_UTIL_H - -#include <Ice/Identity.h> - -namespace Ice -{ - -ICE_API std::ostream& operator<<(std::ostream&, const Identity&); -ICE_API Identity stringToIdentity(const std::string&); -ICE_API std::string identityToString(const Identity&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_IDENTITY_UTIL_H
+#define ICE_IDENTITY_UTIL_H
+
+#include <Ice/Identity.h>
+
+namespace Ice
+{
+
+ICE_API std::ostream& operator<<(std::ostream&, const Identity&);
+ICE_API Identity stringToIdentity(const std::string&);
+ICE_API std::string identityToString(const Identity&);
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index 851115c16cc..8e8322b0fb3 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -1,46 +1,46 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_INCOMING_H -#define ICE_INCOMING_H - -#include <Ice/ObjectAdapterF.h> -#include <Ice/InstanceF.h> -#include <Ice/BasicStream.h> - -namespace IceInternal -{ - -class ICE_API Incoming : public ::IceUtil::noncopyable -{ -public: - - Incoming(const InstancePtr&, const ::Ice::ObjectAdapterPtr&); - - void invoke(bool); - - BasicStream* is(); - BasicStream* os(); - -private: - - // - // Optimization. The adapter may not be deleted while a - // stack-allocated Incoming still holds it. - // - const ::Ice::ObjectAdapterPtr& _adapter; - - BasicStream _is; - BasicStream _os; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_INCOMING_H
+#define ICE_INCOMING_H
+
+#include <Ice/ObjectAdapterF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/BasicStream.h>
+
+namespace IceInternal
+{
+
+class ICE_API Incoming : public ::IceUtil::noncopyable
+{
+public:
+
+ Incoming(const InstancePtr&, const ::Ice::ObjectAdapterPtr&);
+
+ void invoke(bool);
+
+ BasicStream* is();
+ BasicStream* os();
+
+private:
+
+ //
+ // Optimization. The adapter may not be deleted while a
+ // stack-allocated Incoming still holds it.
+ //
+ const ::Ice::ObjectAdapterPtr& _adapter;
+
+ BasicStream _is;
+ BasicStream _os;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Initialize.h b/cpp/include/Ice/Initialize.h index 2b8b8f7dcab..c2f956b55c9 100644 --- a/cpp/include/Ice/Initialize.h +++ b/cpp/include/Ice/Initialize.h @@ -1,56 +1,56 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_INITIALIZE_H -#define ICE_INITIALIZE_H - -#include <Ice/CommunicatorF.h> -#include <Ice/PropertiesF.h> -#include <Ice/InstanceF.h> -#include <Ice/BuiltinSequences.h> - -namespace Ice -{ - -ICE_API CommunicatorPtr initialize(int&, char*[], Int = ICE_INT_VERSION); -ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int = ICE_INT_VERSION); - -ICE_API PropertiesPtr getDefaultProperties(); -ICE_API PropertiesPtr getDefaultProperties(StringSeq&); -ICE_API PropertiesPtr getDefaultProperties(int&, char*[]); - -ICE_API PropertiesPtr createProperties(); -ICE_API PropertiesPtr createProperties(StringSeq&); -ICE_API PropertiesPtr createProperties(int&, char*[]); - -ICE_API StringSeq argsToStringSeq(int, char*[]); -// -// This function assumes that the string sequence only contains -// elements of the argument vector. The function shifts the -// the argument vector elements so that the vector matches the -// contents of the sequence. -// -ICE_API void stringSeqToArgs(const StringSeq&, int&, char*[]); - -} - -namespace IceInternal -{ - -// -// Some Ice extensions need access to the Ice internal instance. Do -// not use this operation for regular application code! It is intended -// to be used by modules such as Freeze. -// -ICE_API InstancePtr getInstance(const ::Ice::CommunicatorPtr&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_INITIALIZE_H
+#define ICE_INITIALIZE_H
+
+#include <Ice/CommunicatorF.h>
+#include <Ice/PropertiesF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/BuiltinSequences.h>
+
+namespace Ice
+{
+
+ICE_API CommunicatorPtr initialize(int&, char*[], Int = ICE_INT_VERSION);
+ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int = ICE_INT_VERSION);
+
+ICE_API PropertiesPtr getDefaultProperties();
+ICE_API PropertiesPtr getDefaultProperties(StringSeq&);
+ICE_API PropertiesPtr getDefaultProperties(int&, char*[]);
+
+ICE_API PropertiesPtr createProperties();
+ICE_API PropertiesPtr createProperties(StringSeq&);
+ICE_API PropertiesPtr createProperties(int&, char*[]);
+
+ICE_API StringSeq argsToStringSeq(int, char*[]);
+//
+// This function assumes that the string sequence only contains
+// elements of the argument vector. The function shifts the
+// the argument vector elements so that the vector matches the
+// contents of the sequence.
+//
+ICE_API void stringSeqToArgs(const StringSeq&, int&, char*[]);
+
+}
+
+namespace IceInternal
+{
+
+//
+// Some Ice extensions need access to the Ice internal instance. Do
+// not use this operation for regular application code! It is intended
+// to be used by modules such as Freeze.
+//
+ICE_API InstancePtr getInstance(const ::Ice::CommunicatorPtr&);
+
+}
+
+#endif
diff --git a/cpp/include/Ice/InstanceF.h b/cpp/include/Ice/InstanceF.h index cbb6f1c5789..d276f7ecd4b 100644 --- a/cpp/include/Ice/InstanceF.h +++ b/cpp/include/Ice/InstanceF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_INSTANCE_F_H -#define ICE_INSTANCE_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Instance; -ICE_API void incRef(Instance*); -ICE_API void decRef(Instance*); -typedef IceInternal::Handle<Instance> InstancePtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_INSTANCE_F_H
+#define ICE_INSTANCE_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Instance;
+ICE_API void incRef(Instance*);
+ICE_API void decRef(Instance*);
+typedef IceInternal::Handle<Instance> InstancePtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/LocalObject.h b/cpp/include/Ice/LocalObject.h index d2989ffbf9c..057dc8aca31 100644 --- a/cpp/include/Ice/LocalObject.h +++ b/cpp/include/Ice/LocalObject.h @@ -1,40 +1,40 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_LOCAL_OBJECT_H -#define ICE_LOCAL_OBJECT_H - -#include <IceUtil/Shared.h> -#include <Ice/LocalObjectF.h> -#include <Ice/StreamF.h> - -namespace IceInternal -{ - -class BasicStream; - -} - -namespace Ice -{ - -class ICE_API LocalObject : virtual public ::IceUtil::Shared -{ -public: - - virtual bool operator==(const LocalObject&) const; - virtual bool operator!=(const LocalObject&) const; - virtual bool operator<(const LocalObject&) const; - virtual ::Ice::Int ice_hash() const; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_LOCAL_OBJECT_H
+#define ICE_LOCAL_OBJECT_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/LocalObjectF.h>
+#include <Ice/StreamF.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+}
+
+namespace Ice
+{
+
+class ICE_API LocalObject : virtual public ::IceUtil::Shared
+{
+public:
+
+ virtual bool operator==(const LocalObject&) const;
+ virtual bool operator!=(const LocalObject&) const;
+ virtual bool operator<(const LocalObject&) const;
+ virtual ::Ice::Int ice_hash() const;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/LocalObjectF.h b/cpp/include/Ice/LocalObjectF.h index a6be07fdefd..121743b0b62 100644 --- a/cpp/include/Ice/LocalObjectF.h +++ b/cpp/include/Ice/LocalObjectF.h @@ -1,38 +1,38 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_LOCAL_OBJECT_F_H -#define ICE_LOCAL_OBJECT_F_H - -#include <Ice/Handle.h> - -namespace Ice -{ - -class LocalObject; - -} - -namespace IceInternal -{ - -ICE_API void incRef(::Ice::LocalObject*); -ICE_API void decRef(::Ice::LocalObject*); - -} - -namespace Ice -{ - -typedef IceInternal::Handle< LocalObject > LocalObjectPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_LOCAL_OBJECT_F_H
+#define ICE_LOCAL_OBJECT_F_H
+
+#include <Ice/Handle.h>
+
+namespace Ice
+{
+
+class LocalObject;
+
+}
+
+namespace IceInternal
+{
+
+ICE_API void incRef(::Ice::LocalObject*);
+ICE_API void decRef(::Ice::LocalObject*);
+
+}
+
+namespace Ice
+{
+
+typedef IceInternal::Handle< LocalObject > LocalObjectPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/LoggerUtil.h b/cpp/include/Ice/LoggerUtil.h index 1444112da5c..c1b9a8c53b9 100644 --- a/cpp/include/Ice/LoggerUtil.h +++ b/cpp/include/Ice/LoggerUtil.h @@ -1,103 +1,103 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_LOGGER_UTIL_H -#define ICE_LOGGER_UTIL_H - -#include <Ice/LoggerF.h> - -namespace Ice -{ - -class ICE_API Warning : public IceUtil::noncopyable -{ -public: - - Warning(const LoggerPtr&); - ~Warning(); - - void flush(); - - std::ostringstream& __str(); // For internal use only. Don't use in your code. - -private: - - LoggerPtr _logger; - std::ostringstream _str; -}; - -template<typename T> -Warning& -operator<<(Warning& out, const T& val) -{ - out.__str() << val; - return out; -} - -ICE_API Warning& operator<<(Warning&, std::ios_base& (*)(std::ios_base&)); - -class ICE_API Error : public IceUtil::noncopyable -{ -public: - - Error(const LoggerPtr&); - ~Error(); - - void flush(); - - std::ostringstream& __str(); // For internal use only. Don't use in your code. - -private: - - LoggerPtr _logger; - std::ostringstream _str; -}; - -template<typename T> -Error& -operator<<(Error& out, const T& val) -{ - out.__str() << val; - return out; -} - -ICE_API Error& operator<<(Error&, std::ios_base& (*)(std::ios_base&)); - -class ICE_API Trace : public IceUtil::noncopyable -{ -public: - - Trace(const LoggerPtr&, const std::string&); - ~Trace(); - - void flush(); - - std::ostringstream& __str(); // For internal use only. Don't use in your code. - -private: - - LoggerPtr _logger; - std::string _category; - std::ostringstream _str; -}; - -template<typename T> -Trace& -operator<<(Trace& out, const T& val) -{ - out.__str() << val; - return out; -} - -ICE_API Trace& operator<<(Trace&, std::ios_base& (*)(std::ios_base&)); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_LOGGER_UTIL_H
+#define ICE_LOGGER_UTIL_H
+
+#include <Ice/LoggerF.h>
+
+namespace Ice
+{
+
+class ICE_API Warning : public IceUtil::noncopyable
+{
+public:
+
+ Warning(const LoggerPtr&);
+ ~Warning();
+
+ void flush();
+
+ std::ostringstream& __str(); // For internal use only. Don't use in your code.
+
+private:
+
+ LoggerPtr _logger;
+ std::ostringstream _str;
+};
+
+template<typename T>
+Warning&
+operator<<(Warning& out, const T& val)
+{
+ out.__str() << val;
+ return out;
+}
+
+ICE_API Warning& operator<<(Warning&, std::ios_base& (*)(std::ios_base&));
+
+class ICE_API Error : public IceUtil::noncopyable
+{
+public:
+
+ Error(const LoggerPtr&);
+ ~Error();
+
+ void flush();
+
+ std::ostringstream& __str(); // For internal use only. Don't use in your code.
+
+private:
+
+ LoggerPtr _logger;
+ std::ostringstream _str;
+};
+
+template<typename T>
+Error&
+operator<<(Error& out, const T& val)
+{
+ out.__str() << val;
+ return out;
+}
+
+ICE_API Error& operator<<(Error&, std::ios_base& (*)(std::ios_base&));
+
+class ICE_API Trace : public IceUtil::noncopyable
+{
+public:
+
+ Trace(const LoggerPtr&, const std::string&);
+ ~Trace();
+
+ void flush();
+
+ std::ostringstream& __str(); // For internal use only. Don't use in your code.
+
+private:
+
+ LoggerPtr _logger;
+ std::string _category;
+ std::ostringstream _str;
+};
+
+template<typename T>
+Trace&
+operator<<(Trace& out, const T& val)
+{
+ out.__str() << val;
+ return out;
+}
+
+ICE_API Trace& operator<<(Trace&, std::ios_base& (*)(std::ios_base&));
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index c21f46e13ff..9861f6c8dc9 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -1,124 +1,124 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OBJECT_H -#define ICE_OBJECT_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/ObjectF.h> -#include <Ice/ProxyF.h> -#include <Ice/StreamF.h> -#include <Ice/Current.h> - -namespace IceInternal -{ - -class Incoming; -class BasicStream; - -enum DispatchStatus -{ - DispatchOK, - DispatchUserException, - DispatchLocationForward, - DispatchObjectNotExist, - DispatchFacetNotExist, - DispatchOperationNotExist, - DispatchUnknownLocalException, - DispatchUnknownUserException, - DispatchUnknownException -}; - -} - -namespace Ice -{ - -class ICE_API LocationForward -{ -public: - - LocationForward(const LocationForward&); - LocationForward(const ObjectPrx&); - -protected: - - ObjectPrx _prx; - friend class ::IceProxy::Ice::Object; - friend class ::IceInternal::Incoming; -}; - -class ICE_API Object : virtual public ::IceUtil::Shared -{ -public: - - Object(); - - virtual bool operator==(const Object&) const; - virtual bool operator!=(const Object&) const; - virtual bool operator<(const Object&) const; - virtual ::Ice::Int ice_hash() const; - - static const ::std::string __ids[]; - - virtual bool ice_isA(const ::std::string&, const Current& = Current()); - ::IceInternal::DispatchStatus ___ice_isA(::IceInternal::Incoming&, const Current&); - - virtual void ice_ping(const Current& = Current()); - ::IceInternal::DispatchStatus ___ice_ping(::IceInternal::Incoming&, const Current&); - - virtual ::std::vector< ::std::string> ice_ids(const Current& = Current()); - ::IceInternal::DispatchStatus ___ice_ids(::IceInternal::Incoming&, const Current&); - - virtual const ::std::string& ice_id(const Current& = Current()); - ::IceInternal::DispatchStatus ___ice_id(::IceInternal::Incoming&, const Current&); - - ::std::vector< ::std::string> ice_facets(const Current& = Current()); - ::IceInternal::DispatchStatus ___ice_facets(::IceInternal::Incoming&, const Current&); - - static const ::std::string& ice_staticId(); - - static ::std::string __all[]; - virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const Current&); - - virtual void __write(::IceInternal::BasicStream*) const; - virtual void __read(::IceInternal::BasicStream*); - - virtual void __marshal(const ::Ice::StreamPtr&) const; - virtual void __unmarshal(const ::Ice::StreamPtr&); - - void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&); - static void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, ObjectPtr&); - - void ice_addFacet(const ObjectPtr&, const ::std::string&); - void ice_removeFacet(const ::std::string&); - void ice_removeAllFacets(); - ObjectPtr ice_findFacet(const ::std::string&); - -private: - - std::map<std::string, ObjectPtr> _activeFacetMap; - std::map<std::string, ObjectPtr>::iterator _activeFacetMapHint; - ::IceUtil::Mutex _activeFacetMapMutex; -}; - -class ICE_API Blobject : virtual public Object -{ -public: - - // Returns true if ok, false if user exception. - virtual bool ice_invoke(const std::vector<Byte>&, std::vector<Byte>&, const Current&) = 0; - virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const Current&); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OBJECT_H
+#define ICE_OBJECT_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/ObjectF.h>
+#include <Ice/ProxyF.h>
+#include <Ice/StreamF.h>
+#include <Ice/Current.h>
+
+namespace IceInternal
+{
+
+class Incoming;
+class BasicStream;
+
+enum DispatchStatus
+{
+ DispatchOK,
+ DispatchUserException,
+ DispatchLocationForward,
+ DispatchObjectNotExist,
+ DispatchFacetNotExist,
+ DispatchOperationNotExist,
+ DispatchUnknownLocalException,
+ DispatchUnknownUserException,
+ DispatchUnknownException
+};
+
+}
+
+namespace Ice
+{
+
+class ICE_API LocationForward
+{
+public:
+
+ LocationForward(const LocationForward&);
+ LocationForward(const ObjectPrx&);
+
+protected:
+
+ ObjectPrx _prx;
+ friend class ::IceProxy::Ice::Object;
+ friend class ::IceInternal::Incoming;
+};
+
+class ICE_API Object : virtual public ::IceUtil::Shared
+{
+public:
+
+ Object();
+
+ virtual bool operator==(const Object&) const;
+ virtual bool operator!=(const Object&) const;
+ virtual bool operator<(const Object&) const;
+ virtual ::Ice::Int ice_hash() const;
+
+ static const ::std::string __ids[];
+
+ virtual bool ice_isA(const ::std::string&, const Current& = Current());
+ ::IceInternal::DispatchStatus ___ice_isA(::IceInternal::Incoming&, const Current&);
+
+ virtual void ice_ping(const Current& = Current());
+ ::IceInternal::DispatchStatus ___ice_ping(::IceInternal::Incoming&, const Current&);
+
+ virtual ::std::vector< ::std::string> ice_ids(const Current& = Current());
+ ::IceInternal::DispatchStatus ___ice_ids(::IceInternal::Incoming&, const Current&);
+
+ virtual const ::std::string& ice_id(const Current& = Current());
+ ::IceInternal::DispatchStatus ___ice_id(::IceInternal::Incoming&, const Current&);
+
+ ::std::vector< ::std::string> ice_facets(const Current& = Current());
+ ::IceInternal::DispatchStatus ___ice_facets(::IceInternal::Incoming&, const Current&);
+
+ static const ::std::string& ice_staticId();
+
+ static ::std::string __all[];
+ virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const Current&);
+
+ virtual void __write(::IceInternal::BasicStream*) const;
+ virtual void __read(::IceInternal::BasicStream*);
+
+ virtual void __marshal(const ::Ice::StreamPtr&) const;
+ virtual void __unmarshal(const ::Ice::StreamPtr&);
+
+ void ice_marshal(const ::std::string&, const ::Ice::StreamPtr&);
+ static void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&, ObjectPtr&);
+
+ void ice_addFacet(const ObjectPtr&, const ::std::string&);
+ void ice_removeFacet(const ::std::string&);
+ void ice_removeAllFacets();
+ ObjectPtr ice_findFacet(const ::std::string&);
+
+private:
+
+ std::map<std::string, ObjectPtr> _activeFacetMap;
+ std::map<std::string, ObjectPtr>::iterator _activeFacetMapHint;
+ ::IceUtil::Mutex _activeFacetMapMutex;
+};
+
+class ICE_API Blobject : virtual public Object
+{
+public:
+
+ // Returns true if ok, false if user exception.
+ virtual bool ice_invoke(const std::vector<Byte>&, std::vector<Byte>&, const Current&) = 0;
+ virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const Current&);
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ObjectAdapterFactoryF.h b/cpp/include/Ice/ObjectAdapterFactoryF.h index 4b721d0cd24..95c011fc085 100644 --- a/cpp/include/Ice/ObjectAdapterFactoryF.h +++ b/cpp/include/Ice/ObjectAdapterFactoryF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OBJECT_ADAPTER_FACTORY_F_H -#define ICE_OBJECT_ADAPTER_FACTORY_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class ObjectAdapterFactory; -void incRef(ObjectAdapterFactory*); -void decRef(ObjectAdapterFactory*); -typedef IceInternal::Handle<ObjectAdapterFactory> ObjectAdapterFactoryPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OBJECT_ADAPTER_FACTORY_F_H
+#define ICE_OBJECT_ADAPTER_FACTORY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class ObjectAdapterFactory;
+void incRef(ObjectAdapterFactory*);
+void decRef(ObjectAdapterFactory*);
+typedef IceInternal::Handle<ObjectAdapterFactory> ObjectAdapterFactoryPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ObjectF.h b/cpp/include/Ice/ObjectF.h index c2c3769743d..3eb751856d7 100644 --- a/cpp/include/Ice/ObjectF.h +++ b/cpp/include/Ice/ObjectF.h @@ -1,38 +1,38 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OBJECT_F_H -#define ICE_OBJECT_F_H - -#include <Ice/Handle.h> - -namespace Ice -{ - -class Object; - -} - -namespace IceInternal -{ - -ICE_API void incRef(::Ice::Object*); -ICE_API void decRef(::Ice::Object*); - -} - -namespace Ice -{ - -typedef IceInternal::Handle< Object > ObjectPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OBJECT_F_H
+#define ICE_OBJECT_F_H
+
+#include <Ice/Handle.h>
+
+namespace Ice
+{
+
+class Object;
+
+}
+
+namespace IceInternal
+{
+
+ICE_API void incRef(::Ice::Object*);
+ICE_API void decRef(::Ice::Object*);
+
+}
+
+namespace Ice
+{
+
+typedef IceInternal::Handle< Object > ObjectPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Outgoing.h b/cpp/include/Ice/Outgoing.h index d19e1c27883..0d24b505c12 100644 --- a/cpp/include/Ice/Outgoing.h +++ b/cpp/include/Ice/Outgoing.h @@ -1,92 +1,92 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OUTGOING_H -#define ICE_OUTGOING_H - -#include <IceUtil/Mutex.h> -#include <IceUtil/Monitor.h> -#include <Ice/ConnectionF.h> -#include <Ice/ReferenceF.h> -#include <Ice/BasicStream.h> -#include <Ice/Current.h> - -namespace Ice -{ - -class LocalException; - -} - -namespace IceInternal -{ - -// -// An exception wrapper, which is used to indicate that an operation -// that failed due to an exception is not repeatable if "at-most-once" -// semantics must be guaranteed. -// -class ICE_API NonRepeatable -{ -public: - - NonRepeatable(const NonRepeatable&); - NonRepeatable(const ::Ice::LocalException&); - const ::Ice::LocalException* get() const; - -private: - - const NonRepeatable& operator=(const NonRepeatable&); - - std::auto_ptr< ::Ice::LocalException> _ex; -}; - -class ICE_API Outgoing : public ::IceUtil::noncopyable, public IceUtil::Monitor< IceUtil::Mutex > -{ -public: - - Outgoing(const ConnectionPtr&, const ReferencePtr&, const std::string&, bool, const ::Ice::Context&); - ~Outgoing(); - - bool invoke(); // Returns true if ok, false if user exception. - void finished(BasicStream&); - void finished(const ::Ice::LocalException&); - - BasicStream* is(); - BasicStream* os(); - -private: - - // - // Optimization. The connection and the reference may not be deleted - // while a stack-allocated Incoming still holds it. - // - const ConnectionPtr& _connection; - const ReferencePtr& _reference; - - std::auto_ptr< ::Ice::LocalException> _exception; - - enum - { - StateUnsent, - StateInProgress, - StateOK, - StateLocationForward, - StateUserException, - StateLocalException, - } _state; - - BasicStream _is; - BasicStream _os; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OUTGOING_H
+#define ICE_OUTGOING_H
+
+#include <IceUtil/Mutex.h>
+#include <IceUtil/Monitor.h>
+#include <Ice/ConnectionF.h>
+#include <Ice/ReferenceF.h>
+#include <Ice/BasicStream.h>
+#include <Ice/Current.h>
+
+namespace Ice
+{
+
+class LocalException;
+
+}
+
+namespace IceInternal
+{
+
+//
+// An exception wrapper, which is used to indicate that an operation
+// that failed due to an exception is not repeatable if "at-most-once"
+// semantics must be guaranteed.
+//
+class ICE_API NonRepeatable
+{
+public:
+
+ NonRepeatable(const NonRepeatable&);
+ NonRepeatable(const ::Ice::LocalException&);
+ const ::Ice::LocalException* get() const;
+
+private:
+
+ const NonRepeatable& operator=(const NonRepeatable&);
+
+ std::auto_ptr< ::Ice::LocalException> _ex;
+};
+
+class ICE_API Outgoing : public ::IceUtil::noncopyable, public IceUtil::Monitor< IceUtil::Mutex >
+{
+public:
+
+ Outgoing(const ConnectionPtr&, const ReferencePtr&, const std::string&, bool, const ::Ice::Context&);
+ ~Outgoing();
+
+ bool invoke(); // Returns true if ok, false if user exception.
+ void finished(BasicStream&);
+ void finished(const ::Ice::LocalException&);
+
+ BasicStream* is();
+ BasicStream* os();
+
+private:
+
+ //
+ // Optimization. The connection and the reference may not be deleted
+ // while a stack-allocated Incoming still holds it.
+ //
+ const ConnectionPtr& _connection;
+ const ReferencePtr& _reference;
+
+ std::auto_ptr< ::Ice::LocalException> _exception;
+
+ enum
+ {
+ StateUnsent,
+ StateInProgress,
+ StateOK,
+ StateLocationForward,
+ StateUserException,
+ StateLocalException,
+ } _state;
+
+ BasicStream _is;
+ BasicStream _os;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ProtocolPluginFacade.h b/cpp/include/Ice/ProtocolPluginFacade.h index 243f2c69edc..a9b93a42d7b 100644 --- a/cpp/include/Ice/ProtocolPluginFacade.h +++ b/cpp/include/Ice/ProtocolPluginFacade.h @@ -1,70 +1,70 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROTOCOL_PLUGIN_FACADE_H -#define ICE_PROTOCOL_PLUGIN_FACADE_H - -#include <IceUtil/Shared.h> -#include <Ice/ProtocolPluginFacadeF.h> -#include <Ice/CommunicatorF.h> -#include <Ice/EndpointFactoryF.h> -#include <Ice/InstanceF.h> - -namespace IceInternal -{ - -// -// Global function to obtain a ProtocolPluginFacade given a Communicator -// instance. -// -ICE_PROTOCOL_API ProtocolPluginFacadePtr getProtocolPluginFacade(const Ice::CommunicatorPtr&); - -// -// ProtocolPluginFacade wraps the internal operations that protocol -// plug-ins may need. -// -class ICE_PROTOCOL_API ProtocolPluginFacade : public ::IceUtil::Shared -{ -public: - - // - // Get the Communicator instance with which this facade is - // associated. - // - Ice::CommunicatorPtr getCommunicator() const; - - // - // Get the default hostname to be used in endpoints. - // - std::string getDefaultHost() const; - - // - // Get the network trace level and category name. - // - int getNetworkTraceLevel() const; - const char* getNetworkTraceCategory() const; - - // - // Register an EndpointFactory. - // - void addEndpointFactory(const EndpointFactoryPtr&) const; - -private: - - ProtocolPluginFacade(const InstancePtr&); - - friend ICE_PROTOCOL_API ProtocolPluginFacadePtr getProtocolPluginFacade(const Ice::CommunicatorPtr&); - - InstancePtr _instance; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROTOCOL_PLUGIN_FACADE_H
+#define ICE_PROTOCOL_PLUGIN_FACADE_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/ProtocolPluginFacadeF.h>
+#include <Ice/CommunicatorF.h>
+#include <Ice/EndpointFactoryF.h>
+#include <Ice/InstanceF.h>
+
+namespace IceInternal
+{
+
+//
+// Global function to obtain a ProtocolPluginFacade given a Communicator
+// instance.
+//
+ICE_PROTOCOL_API ProtocolPluginFacadePtr getProtocolPluginFacade(const Ice::CommunicatorPtr&);
+
+//
+// ProtocolPluginFacade wraps the internal operations that protocol
+// plug-ins may need.
+//
+class ICE_PROTOCOL_API ProtocolPluginFacade : public ::IceUtil::Shared
+{
+public:
+
+ //
+ // Get the Communicator instance with which this facade is
+ // associated.
+ //
+ Ice::CommunicatorPtr getCommunicator() const;
+
+ //
+ // Get the default hostname to be used in endpoints.
+ //
+ std::string getDefaultHost() const;
+
+ //
+ // Get the network trace level and category name.
+ //
+ int getNetworkTraceLevel() const;
+ const char* getNetworkTraceCategory() const;
+
+ //
+ // Register an EndpointFactory.
+ //
+ void addEndpointFactory(const EndpointFactoryPtr&) const;
+
+private:
+
+ ProtocolPluginFacade(const InstancePtr&);
+
+ friend ICE_PROTOCOL_API ProtocolPluginFacadePtr getProtocolPluginFacade(const Ice::CommunicatorPtr&);
+
+ InstancePtr _instance;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ProtocolPluginFacadeF.h b/cpp/include/Ice/ProtocolPluginFacadeF.h index 703ee9013fe..36321873976 100644 --- a/cpp/include/Ice/ProtocolPluginFacadeF.h +++ b/cpp/include/Ice/ProtocolPluginFacadeF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROTOCOL_PLUGIN_FACADE_F_H -#define ICE_PROTOCOL_PLUGIN_FACADE_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class ProtocolPluginFacade; -ICE_PROTOCOL_API void incRef(ProtocolPluginFacade*); -ICE_PROTOCOL_API void decRef(ProtocolPluginFacade*); -typedef Handle<ProtocolPluginFacade> ProtocolPluginFacadePtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROTOCOL_PLUGIN_FACADE_F_H
+#define ICE_PROTOCOL_PLUGIN_FACADE_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class ProtocolPluginFacade;
+ICE_PROTOCOL_API void incRef(ProtocolPluginFacade*);
+ICE_PROTOCOL_API void decRef(ProtocolPluginFacade*);
+typedef Handle<ProtocolPluginFacade> ProtocolPluginFacadePtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 81d438c7391..e5b23fd640e 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -1,208 +1,208 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROXY_H -#define ICE_PROXY_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/ProxyF.h> -#include <Ice/ProxyFactoryF.h> -#include <Ice/ConnectionF.h> -#include <Ice/EndpointF.h> -#include <Ice/ObjectF.h> -#include <Ice/ObjectAdapterF.h> -#include <Ice/ReferenceF.h> -//#include <Ice/RouterF.h> // Can't include RouterF.h here, otherwise we have cyclic includes -#include <Ice/Current.h> - -namespace IceProxy -{ - -namespace Ice -{ - -class Router; - -} - -} - -namespace IceInternal -{ - -ICE_API void incRef(::IceProxy::Ice::Router*); -ICE_API void decRef(::IceProxy::Ice::Router*); - -ICE_API void checkedCast(const ::Ice::ObjectPrx&, const ::std::string&, ProxyHandle< ::IceProxy::Ice::Router>&); -ICE_API void uncheckedCast(const ::Ice::ObjectPrx&, const ::std::string&, ProxyHandle< ::IceProxy::Ice::Router>&); - -} - -namespace Ice -{ - -typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::Router> RouterPrx; - -class LocalException; -class LocationForward; - -} -namespace IceProxy { namespace Ice -{ - -class ICE_API Object : public ::IceUtil::Shared, ::IceUtil::Mutex -{ -public: - - bool operator==(const Object&) const; - bool operator!=(const Object&) const; - bool operator<(const Object&) const; - ::Ice::Int ice_hash() const; - - bool ice_isA(const std::string&, const ::Ice::Context& = ::Ice::Context()); - void ice_ping(const ::Ice::Context& = ::Ice::Context()); - ::std::vector< ::std::string> ice_ids(const ::Ice::Context& = ::Ice::Context()); - ::std::string ice_id(const ::Ice::Context& = ::Ice::Context()); - ::std::vector< ::std::string> ice_facets(const ::Ice::Context& = ::Ice::Context()); - bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&, - const ::Ice::Context& = ::Ice::Context()); // Returns true if ok, false if user exception. - - ::Ice::Identity ice_getIdentity() const; - ::Ice::ObjectPrx ice_newIdentity(const ::Ice::Identity&) const; - - std::string ice_getFacet() const; - ::Ice::ObjectPrx ice_newFacet(const std::string&) const; - - ::Ice::ObjectPrx ice_twoway() const; - ::Ice::ObjectPrx ice_oneway() const; - ::Ice::ObjectPrx ice_batchOneway() const; - ::Ice::ObjectPrx ice_datagram() const; - ::Ice::ObjectPrx ice_batchDatagram() const; - ::Ice::ObjectPrx ice_secure(bool) const; - ::Ice::ObjectPrx ice_compress(bool) const; - ::Ice::ObjectPrx ice_timeout(int) const; - ::Ice::ObjectPrx ice_router(const ::Ice::RouterPrx&) const; - ::Ice::ObjectPrx ice_default() const; - - void ice_flush(); // Flush batch messages - - ::IceInternal::ReferencePtr __reference() const; - void __copyFrom(const ::Ice::ObjectPrx&); - void __handleException(const ::Ice::LocalException&, int&); - void __rethrowException(const ::Ice::LocalException&); - void __locationForward(const ::Ice::LocationForward&); - - ::IceInternal::Handle< ::IceDelegate::Ice::Object> __getDelegate(); - -protected: - - virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM(); - virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD(); - -private: - - void setup(const ::IceInternal::ReferencePtr&); - friend class ::IceInternal::ProxyFactory; - - ::IceInternal::ReferencePtr _reference; - ::IceInternal::Handle< ::IceDelegate::Ice::Object> _delegate; -}; - -} } - -namespace IceDelegate { namespace Ice -{ - -class ICE_API Object : public ::IceUtil::Shared -{ -public: - - virtual bool ice_isA(const std::string&, const ::Ice::Context&) = 0; - virtual void ice_ping(const ::Ice::Context&) = 0; - virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Context&) = 0; - virtual ::std::string ice_id(const ::Ice::Context&) = 0; - virtual ::std::vector< ::std::string> ice_facets(const ::Ice::Context&) = 0; - virtual bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&, - const ::Ice::Context&) = 0; - virtual void ice_flush() = 0; -}; - -} } - -namespace IceDelegateM { namespace Ice -{ - -class ICE_API Object : virtual public ::IceDelegate::Ice::Object -{ -public: - - virtual ~Object(); - - virtual bool ice_isA(const std::string&, const ::Ice::Context&); - virtual void ice_ping(const ::Ice::Context&); - virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Context&); - virtual ::std::string ice_id(const ::Ice::Context&); - virtual ::std::vector< ::std::string> ice_facets(const ::Ice::Context&); - virtual bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&, - const ::Ice::Context&); - virtual void ice_flush(); - - void __copyFrom(const ::IceInternal::Handle< ::IceDelegateM::Ice::Object>&); - -protected: - - ::IceInternal::ConnectionPtr __connection; - ::IceInternal::ReferencePtr __reference; - -private: - - void setup(const ::IceInternal::ReferencePtr&); - friend class ::IceProxy::Ice::Object; - - std::vector< ::IceInternal::EndpointPtr> filterEndpoints(const std::vector< ::IceInternal::EndpointPtr>&) const; -}; - -} } - -namespace IceDelegateD { namespace Ice -{ - -class ICE_API Object : virtual public ::IceDelegate::Ice::Object -{ -public: - - virtual bool ice_isA(const std::string&, const ::Ice::Context&); - virtual void ice_ping(const ::Ice::Context&); - virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Context&); - virtual ::std::string ice_id(const ::Ice::Context&); - virtual ::std::vector< ::std::string> ice_facets(const ::Ice::Context&); - virtual bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&, - const ::Ice::Context&); - virtual void ice_flush(); - - void __copyFrom(const ::IceInternal::Handle< ::IceDelegateD::Ice::Object>&); - -protected: - - ::Ice::ObjectAdapterPtr __adapter; - ::IceInternal::ReferencePtr __reference; - - void __initCurrent(::Ice::Current&, const std::string&, bool, const ::Ice::Context&); - -private: - - void setup(const ::IceInternal::ReferencePtr&, const ::Ice::ObjectAdapterPtr&); - friend class ::IceProxy::Ice::Object; -}; - -} } - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROXY_H
+#define ICE_PROXY_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/ProxyF.h>
+#include <Ice/ProxyFactoryF.h>
+#include <Ice/ConnectionF.h>
+#include <Ice/EndpointF.h>
+#include <Ice/ObjectF.h>
+#include <Ice/ObjectAdapterF.h>
+#include <Ice/ReferenceF.h>
+//#include <Ice/RouterF.h> // Can't include RouterF.h here, otherwise we have cyclic includes
+#include <Ice/Current.h>
+
+namespace IceProxy
+{
+
+namespace Ice
+{
+
+class Router;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+ICE_API void incRef(::IceProxy::Ice::Router*);
+ICE_API void decRef(::IceProxy::Ice::Router*);
+
+ICE_API void checkedCast(const ::Ice::ObjectPrx&, const ::std::string&, ProxyHandle< ::IceProxy::Ice::Router>&);
+ICE_API void uncheckedCast(const ::Ice::ObjectPrx&, const ::std::string&, ProxyHandle< ::IceProxy::Ice::Router>&);
+
+}
+
+namespace Ice
+{
+
+typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::Router> RouterPrx;
+
+class LocalException;
+class LocationForward;
+
+}
+namespace IceProxy { namespace Ice
+{
+
+class ICE_API Object : public ::IceUtil::Shared, ::IceUtil::Mutex
+{
+public:
+
+ bool operator==(const Object&) const;
+ bool operator!=(const Object&) const;
+ bool operator<(const Object&) const;
+ ::Ice::Int ice_hash() const;
+
+ bool ice_isA(const std::string&, const ::Ice::Context& = ::Ice::Context());
+ void ice_ping(const ::Ice::Context& = ::Ice::Context());
+ ::std::vector< ::std::string> ice_ids(const ::Ice::Context& = ::Ice::Context());
+ ::std::string ice_id(const ::Ice::Context& = ::Ice::Context());
+ ::std::vector< ::std::string> ice_facets(const ::Ice::Context& = ::Ice::Context());
+ bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&,
+ const ::Ice::Context& = ::Ice::Context()); // Returns true if ok, false if user exception.
+
+ ::Ice::Identity ice_getIdentity() const;
+ ::Ice::ObjectPrx ice_newIdentity(const ::Ice::Identity&) const;
+
+ std::string ice_getFacet() const;
+ ::Ice::ObjectPrx ice_newFacet(const std::string&) const;
+
+ ::Ice::ObjectPrx ice_twoway() const;
+ ::Ice::ObjectPrx ice_oneway() const;
+ ::Ice::ObjectPrx ice_batchOneway() const;
+ ::Ice::ObjectPrx ice_datagram() const;
+ ::Ice::ObjectPrx ice_batchDatagram() const;
+ ::Ice::ObjectPrx ice_secure(bool) const;
+ ::Ice::ObjectPrx ice_compress(bool) const;
+ ::Ice::ObjectPrx ice_timeout(int) const;
+ ::Ice::ObjectPrx ice_router(const ::Ice::RouterPrx&) const;
+ ::Ice::ObjectPrx ice_default() const;
+
+ void ice_flush(); // Flush batch messages
+
+ ::IceInternal::ReferencePtr __reference() const;
+ void __copyFrom(const ::Ice::ObjectPrx&);
+ void __handleException(const ::Ice::LocalException&, int&);
+ void __rethrowException(const ::Ice::LocalException&);
+ void __locationForward(const ::Ice::LocationForward&);
+
+ ::IceInternal::Handle< ::IceDelegate::Ice::Object> __getDelegate();
+
+protected:
+
+ virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();
+ virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();
+
+private:
+
+ void setup(const ::IceInternal::ReferencePtr&);
+ friend class ::IceInternal::ProxyFactory;
+
+ ::IceInternal::ReferencePtr _reference;
+ ::IceInternal::Handle< ::IceDelegate::Ice::Object> _delegate;
+};
+
+} }
+
+namespace IceDelegate { namespace Ice
+{
+
+class ICE_API Object : public ::IceUtil::Shared
+{
+public:
+
+ virtual bool ice_isA(const std::string&, const ::Ice::Context&) = 0;
+ virtual void ice_ping(const ::Ice::Context&) = 0;
+ virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Context&) = 0;
+ virtual ::std::string ice_id(const ::Ice::Context&) = 0;
+ virtual ::std::vector< ::std::string> ice_facets(const ::Ice::Context&) = 0;
+ virtual bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&,
+ const ::Ice::Context&) = 0;
+ virtual void ice_flush() = 0;
+};
+
+} }
+
+namespace IceDelegateM { namespace Ice
+{
+
+class ICE_API Object : virtual public ::IceDelegate::Ice::Object
+{
+public:
+
+ virtual ~Object();
+
+ virtual bool ice_isA(const std::string&, const ::Ice::Context&);
+ virtual void ice_ping(const ::Ice::Context&);
+ virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Context&);
+ virtual ::std::string ice_id(const ::Ice::Context&);
+ virtual ::std::vector< ::std::string> ice_facets(const ::Ice::Context&);
+ virtual bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&,
+ const ::Ice::Context&);
+ virtual void ice_flush();
+
+ void __copyFrom(const ::IceInternal::Handle< ::IceDelegateM::Ice::Object>&);
+
+protected:
+
+ ::IceInternal::ConnectionPtr __connection;
+ ::IceInternal::ReferencePtr __reference;
+
+private:
+
+ void setup(const ::IceInternal::ReferencePtr&);
+ friend class ::IceProxy::Ice::Object;
+
+ std::vector< ::IceInternal::EndpointPtr> filterEndpoints(const std::vector< ::IceInternal::EndpointPtr>&) const;
+};
+
+} }
+
+namespace IceDelegateD { namespace Ice
+{
+
+class ICE_API Object : virtual public ::IceDelegate::Ice::Object
+{
+public:
+
+ virtual bool ice_isA(const std::string&, const ::Ice::Context&);
+ virtual void ice_ping(const ::Ice::Context&);
+ virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Context&);
+ virtual ::std::string ice_id(const ::Ice::Context&);
+ virtual ::std::vector< ::std::string> ice_facets(const ::Ice::Context&);
+ virtual bool ice_invoke(const std::string&, bool, const std::vector< ::Ice::Byte>&, std::vector< ::Ice::Byte>&,
+ const ::Ice::Context&);
+ virtual void ice_flush();
+
+ void __copyFrom(const ::IceInternal::Handle< ::IceDelegateD::Ice::Object>&);
+
+protected:
+
+ ::Ice::ObjectAdapterPtr __adapter;
+ ::IceInternal::ReferencePtr __reference;
+
+ void __initCurrent(::Ice::Current&, const std::string&, bool, const ::Ice::Context&);
+
+private:
+
+ void setup(const ::IceInternal::ReferencePtr&, const ::Ice::ObjectAdapterPtr&);
+ friend class ::IceProxy::Ice::Object;
+};
+
+} }
+
+#endif
diff --git a/cpp/include/Ice/ProxyF.h b/cpp/include/Ice/ProxyF.h index ce1496a4bbc..1133bee2dbd 100644 --- a/cpp/include/Ice/ProxyF.h +++ b/cpp/include/Ice/ProxyF.h @@ -1,93 +1,93 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROXY_F_H -#define ICE_PROXY_F_H - -#include <Ice/ProxyHandle.h> - -namespace IceProxy -{ - -namespace Ice -{ - -class Object; - -} - -} - -namespace IceDelegate -{ - -namespace Ice -{ - -class Object; - -} - -} - -namespace IceDelegateM -{ - -namespace Ice -{ - -class Object; - -} - -} - -namespace IceDelegateD -{ - -namespace Ice -{ - -class Object; - -} - -} - -namespace IceInternal -{ - -ICE_API void incRef(::IceProxy::Ice::Object*); -ICE_API void decRef(::IceProxy::Ice::Object*); - -ICE_API void incRef(::IceDelegate::Ice::Object*); -ICE_API void decRef(::IceDelegate::Ice::Object*); - -ICE_API void incRef(::IceDelegateM::Ice::Object*); -ICE_API void decRef(::IceDelegateM::Ice::Object*); - -ICE_API void incRef(::IceDelegateD::Ice::Object*); -ICE_API void decRef(::IceDelegateD::Ice::Object*); - -ICE_API void checkedCast(const ProxyHandle< ::IceProxy::Ice::Object>&, const ::std::string&, - ProxyHandle< ::IceProxy::Ice::Object>&); -ICE_API void uncheckedCast(const ProxyHandle< ::IceProxy::Ice::Object>&, const ::std::string&, - ProxyHandle< ::IceProxy::Ice::Object>&); - -} - -namespace Ice -{ - -typedef IceInternal::ProxyHandle< ::IceProxy::Ice::Object> ObjectPrx; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROXY_F_H
+#define ICE_PROXY_F_H
+
+#include <Ice/ProxyHandle.h>
+
+namespace IceProxy
+{
+
+namespace Ice
+{
+
+class Object;
+
+}
+
+}
+
+namespace IceDelegate
+{
+
+namespace Ice
+{
+
+class Object;
+
+}
+
+}
+
+namespace IceDelegateM
+{
+
+namespace Ice
+{
+
+class Object;
+
+}
+
+}
+
+namespace IceDelegateD
+{
+
+namespace Ice
+{
+
+class Object;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+ICE_API void incRef(::IceProxy::Ice::Object*);
+ICE_API void decRef(::IceProxy::Ice::Object*);
+
+ICE_API void incRef(::IceDelegate::Ice::Object*);
+ICE_API void decRef(::IceDelegate::Ice::Object*);
+
+ICE_API void incRef(::IceDelegateM::Ice::Object*);
+ICE_API void decRef(::IceDelegateM::Ice::Object*);
+
+ICE_API void incRef(::IceDelegateD::Ice::Object*);
+ICE_API void decRef(::IceDelegateD::Ice::Object*);
+
+ICE_API void checkedCast(const ProxyHandle< ::IceProxy::Ice::Object>&, const ::std::string&,
+ ProxyHandle< ::IceProxy::Ice::Object>&);
+ICE_API void uncheckedCast(const ProxyHandle< ::IceProxy::Ice::Object>&, const ::std::string&,
+ ProxyHandle< ::IceProxy::Ice::Object>&);
+
+}
+
+namespace Ice
+{
+
+typedef IceInternal::ProxyHandle< ::IceProxy::Ice::Object> ObjectPrx;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ProxyFactoryF.h b/cpp/include/Ice/ProxyFactoryF.h index 2bf9c138927..0c5fdfe6ba0 100644 --- a/cpp/include/Ice/ProxyFactoryF.h +++ b/cpp/include/Ice/ProxyFactoryF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROXY_FACTORY_F_H -#define ICE_PROXY_FACTORY_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class ProxyFactory; -void incRef(ProxyFactory*); -void decRef(ProxyFactory*); -typedef IceInternal::Handle<ProxyFactory> ProxyFactoryPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROXY_FACTORY_F_H
+#define ICE_PROXY_FACTORY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class ProxyFactory;
+void incRef(ProxyFactory*);
+void decRef(ProxyFactory*);
+typedef IceInternal::Handle<ProxyFactory> ProxyFactoryPtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ProxyHandle.h b/cpp/include/Ice/ProxyHandle.h index 842cd09d313..686f3224200 100644 --- a/cpp/include/Ice/ProxyHandle.h +++ b/cpp/include/Ice/ProxyHandle.h @@ -1,187 +1,187 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROXY_HANDLE_H -#define ICE_PROXY_HANDLE_H - -#include <IceUtil/Handle.h> -#include <Ice/Config.h> - -namespace IceInternal -{ - -// -// Like IceInternal::Handle, but specifically for proxies, with -// support for checkedCast() and uncheckedCast() instead of -// dynamicCast(). -// -template<typename T> -class ProxyHandle : public ::IceUtil::HandleBase<T> -{ -public: - - ProxyHandle(T* p = 0) - { - _ptr = p; - - if (_ptr) - { - incRef(_ptr); - } - } - - template<typename Y> - ProxyHandle(const ProxyHandle<Y>& r) - { - _ptr = r._ptr; - - if (_ptr) - { - incRef(_ptr); - } - } - - template<typename Y> - ProxyHandle(const ::IceUtil::Handle<Y>& r) - { - _ptr = r._ptr; - - if (_ptr) - { - incRef(_ptr); - } - } - -#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? - template<> - ProxyHandle(const ProxyHandle<T>& r) -#else - ProxyHandle(const ProxyHandle& r) -#endif - { - _ptr = r._ptr; - - if (_ptr) - { - incRef(_ptr); - } - } - - ~ProxyHandle() - { - if (_ptr) - { - decRef(_ptr); - } - } - - ProxyHandle& operator=(T* p) - { - if (_ptr != p) - { - if (p) - { - incRef(p); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = p; - } - return *this; - } - - template<typename Y> - ProxyHandle& operator=(const ProxyHandle<Y>& r) - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - incRef(r._ptr); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = r._ptr; - } - return *this; - } - - template<typename Y> - ProxyHandle& operator=(const ::IceUtil::Handle<Y>& r) - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - incRef(r._ptr); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = r._ptr; - } - return *this; - } - -#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? - template<> - ProxyHandle& operator=(const ProxyHandle<T>& r) -#else - ProxyHandle& operator=(const ProxyHandle& r) -#endif - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - incRef(r._ptr); - } - - if (_ptr) - { - decRef(_ptr); - } - - _ptr = r._ptr; - } - return *this; - } - - template<class Y> - static ProxyHandle checkedCast(const ProxyHandle<Y>& r, const std::string& f = "") - { - ProxyHandle p; - ::IceInternal::checkedCast(r, f, p); - return p; - } - - template<class Y> - static ProxyHandle uncheckedCast(const ProxyHandle<Y>& r, const std::string& f = "") - { - ProxyHandle p; - ::IceInternal::uncheckedCast(r, f, p); - return p; - } -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROXY_HANDLE_H
+#define ICE_PROXY_HANDLE_H
+
+#include <IceUtil/Handle.h>
+#include <Ice/Config.h>
+
+namespace IceInternal
+{
+
+//
+// Like IceInternal::Handle, but specifically for proxies, with
+// support for checkedCast() and uncheckedCast() instead of
+// dynamicCast().
+//
+template<typename T>
+class ProxyHandle : public ::IceUtil::HandleBase<T>
+{
+public:
+
+ ProxyHandle(T* p = 0)
+ {
+ _ptr = p;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+ template<typename Y>
+ ProxyHandle(const ProxyHandle<Y>& r)
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+ template<typename Y>
+ ProxyHandle(const ::IceUtil::Handle<Y>& r)
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
+ template<>
+ ProxyHandle(const ProxyHandle<T>& r)
+#else
+ ProxyHandle(const ProxyHandle& r)
+#endif
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ incRef(_ptr);
+ }
+ }
+
+ ~ProxyHandle()
+ {
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+ }
+
+ ProxyHandle& operator=(T* p)
+ {
+ if(_ptr != p)
+ {
+ if(p)
+ {
+ incRef(p);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = p;
+ }
+ return *this;
+ }
+
+ template<typename Y>
+ ProxyHandle& operator=(const ProxyHandle<Y>& r)
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ incRef(r._ptr);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+ template<typename Y>
+ ProxyHandle& operator=(const ::IceUtil::Handle<Y>& r)
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ incRef(r._ptr);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
+ template<>
+ ProxyHandle& operator=(const ProxyHandle<T>& r)
+#else
+ ProxyHandle& operator=(const ProxyHandle& r)
+#endif
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ incRef(r._ptr);
+ }
+
+ if(_ptr)
+ {
+ decRef(_ptr);
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+ template<class Y>
+ static ProxyHandle checkedCast(const ProxyHandle<Y>& r, const std::string& f = "")
+ {
+ ProxyHandle p;
+ ::IceInternal::checkedCast(r, f, p);
+ return p;
+ }
+
+ template<class Y>
+ static ProxyHandle uncheckedCast(const ProxyHandle<Y>& r, const std::string& f = "")
+ {
+ ProxyHandle p;
+ ::IceInternal::uncheckedCast(r, f, p);
+ return p;
+ }
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/ReferenceF.h b/cpp/include/Ice/ReferenceF.h index a154aec6398..34c05bdbc01 100644 --- a/cpp/include/Ice/ReferenceF.h +++ b/cpp/include/Ice/ReferenceF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_REFERENCE_F_H -#define ICE_REFERENCE_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Reference; -ICE_API void incRef(Reference*); -ICE_API void decRef(Reference*); -typedef IceInternal::Handle<Reference> ReferencePtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_REFERENCE_F_H
+#define ICE_REFERENCE_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Reference;
+ICE_API void incRef(Reference*);
+ICE_API void decRef(Reference*);
+typedef IceInternal::Handle<Reference> ReferencePtr;
+
+}
+
+#endif
diff --git a/cpp/include/Ice/RoutingTable.h b/cpp/include/Ice/RoutingTable.h index f0c56a672fb..2d51a5ca97d 100644 --- a/cpp/include/Ice/RoutingTable.h +++ b/cpp/include/Ice/RoutingTable.h @@ -1,53 +1,53 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ROUTING_TABLE_H -#define ICE_ROUTING_TABLE_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/RoutingTableF.h> -#include <Ice/ProxyF.h> - -namespace Ice -{ - -struct Identity; - -}; - -namespace IceInternal -{ - -class ICE_API RoutingTable : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - RoutingTable(); - - // - // Returns false if the Proxy exists already. - // - bool add(const ::Ice::ObjectPrx&); - - // - // Returns null if no Proxy exists for the given identity. - // - ::Ice::ObjectPrx get(const ::Ice::Identity&); - -private: - - std::map< ::Ice::Identity, ::Ice::ObjectPrx> _table; - std::map< ::Ice::Identity, ::Ice::ObjectPrx>::iterator _tableHint; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ROUTING_TABLE_H
+#define ICE_ROUTING_TABLE_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/RoutingTableF.h>
+#include <Ice/ProxyF.h>
+
+namespace Ice
+{
+
+struct Identity;
+
+};
+
+namespace IceInternal
+{
+
+class ICE_API RoutingTable : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ RoutingTable();
+
+ //
+ // Returns false if the Proxy exists already.
+ //
+ bool add(const ::Ice::ObjectPrx&);
+
+ //
+ // Returns null if no Proxy exists for the given identity.
+ //
+ ::Ice::ObjectPrx get(const ::Ice::Identity&);
+
+private:
+
+ std::map< ::Ice::Identity, ::Ice::ObjectPrx> _table;
+ std::map< ::Ice::Identity, ::Ice::ObjectPrx>::iterator _tableHint;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Ice/RoutingTableF.h b/cpp/include/Ice/RoutingTableF.h index 8c1a453c3c8..301769373d3 100644 --- a/cpp/include/Ice/RoutingTableF.h +++ b/cpp/include/Ice/RoutingTableF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ROUTING_TABLE_F_H -#define ICE_ROUTING_TABLE_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class RoutingTable; -ICE_API void incRef(RoutingTable*); -ICE_API void decRef(RoutingTable*); -typedef IceInternal::Handle<RoutingTable> RoutingTablePtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ROUTING_TABLE_F_H
+#define ICE_ROUTING_TABLE_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class RoutingTable;
+ICE_API void incRef(RoutingTable*);
+ICE_API void decRef(RoutingTable*);
+typedef IceInternal::Handle<RoutingTable> RoutingTablePtr;
+
+}
+
+#endif
diff --git a/cpp/include/IcePatch/FileDescFactory.h b/cpp/include/IcePatch/FileDescFactory.h index 99b897c2684..dd4e0254a52 100644 --- a/cpp/include/IcePatch/FileDescFactory.h +++ b/cpp/include/IcePatch/FileDescFactory.h @@ -1,30 +1,30 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PATCH_FILE_DESC_FACTORY_H -#define ICE_PATCH_FILE_DESC_FACTORY_H - -#include <Ice/Ice.h> -#include <IcePatch/IcePatch.h> - -namespace IcePatch -{ - -class ICE_PATCH_API FileDescFactory : public Ice::ObjectFactory -{ -public: - - Ice::ObjectPtr create(const std::string&); - void destroy(); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PATCH_FILE_DESC_FACTORY_H
+#define ICE_PATCH_FILE_DESC_FACTORY_H
+
+#include <Ice/Ice.h>
+#include <IcePatch/IcePatch.h>
+
+namespace IcePatch
+{
+
+class ICE_PATCH_API FileDescFactory : public Ice::ObjectFactory
+{
+public:
+
+ Ice::ObjectPtr create(const std::string&);
+ void destroy();
+};
+
+}
+
+#endif
diff --git a/cpp/include/IcePatch/Util.h b/cpp/include/IcePatch/Util.h index 5b02b854761..4a5034bff4b 100644 --- a/cpp/include/IcePatch/Util.h +++ b/cpp/include/IcePatch/Util.h @@ -1,72 +1,72 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PATCH_UTIL_H -#define ICE_PATCH_UTIL_H - -#include <Ice/Ice.h> -#include <IcePatch/IcePatch.h> - -namespace IcePatch -{ - -ICE_PATCH_API std::string identityToPath(const Ice::Identity&); -ICE_PATCH_API Ice::Identity pathToIdentity(const std::string&); - -ICE_PATCH_API std::string getSuffix(const std::string&); -ICE_PATCH_API bool ignoreSuffix(const std::string&); -ICE_PATCH_API std::string removeSuffix(const std::string&); - -enum FileType -{ - FileTypeNotExist, - FileTypeDirectory, - FileTypeRegular, - FileTypeUnknown -}; - -struct FileInfo -{ - FileType type; - off_t size; - time_t time; -}; - -ICE_PATCH_API FileInfo getFileInfo(const std::string&, bool); - -ICE_PATCH_API void removeRecursive(const std::string&); - -ICE_PATCH_API Ice::StringSeq readDirectory(const std::string&); -ICE_PATCH_API void createDirectory(const std::string&); - -ICE_PATCH_API Ice::ByteSeq getMD5(const std::string&); -ICE_PATCH_API Ice::ByteSeq getPartialMD5(const std::string&, Ice::Int); -ICE_PATCH_API void createMD5(const std::string&); - -ICE_PATCH_API Ice::ByteSeq getBZ2(const std::string&, Ice::Int, Ice::Int); -ICE_PATCH_API void createBZ2(const std::string&); - -class ICE_PATCH_API ProgressCB -{ -public: - - virtual void startDownload(Ice::Int, Ice::Int) = 0; - virtual void updateDownload(Ice::Int, Ice::Int) = 0; - virtual void finishedDownload(Ice::Int) = 0; - - virtual void startUncompress(Ice::Int, Ice::Int) = 0; - virtual void updateUncompress(Ice::Int, Ice::Int) = 0; - virtual void finishedUncompress(Ice::Int) = 0; -}; -ICE_PATCH_API void getRegular(const IcePatch::RegularPrx&, ProgressCB&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PATCH_UTIL_H
+#define ICE_PATCH_UTIL_H
+
+#include <Ice/Ice.h>
+#include <IcePatch/IcePatch.h>
+
+namespace IcePatch
+{
+
+ICE_PATCH_API std::string identityToPath(const Ice::Identity&);
+ICE_PATCH_API Ice::Identity pathToIdentity(const std::string&);
+
+ICE_PATCH_API std::string getSuffix(const std::string&);
+ICE_PATCH_API bool ignoreSuffix(const std::string&);
+ICE_PATCH_API std::string removeSuffix(const std::string&);
+
+enum FileType
+{
+ FileTypeNotExist,
+ FileTypeDirectory,
+ FileTypeRegular,
+ FileTypeUnknown
+};
+
+struct FileInfo
+{
+ FileType type;
+ off_t size;
+ time_t time;
+};
+
+ICE_PATCH_API FileInfo getFileInfo(const std::string&, bool);
+
+ICE_PATCH_API void removeRecursive(const std::string&);
+
+ICE_PATCH_API Ice::StringSeq readDirectory(const std::string&);
+ICE_PATCH_API void createDirectory(const std::string&);
+
+ICE_PATCH_API Ice::ByteSeq getMD5(const std::string&);
+ICE_PATCH_API Ice::ByteSeq getPartialMD5(const std::string&, Ice::Int);
+ICE_PATCH_API void createMD5(const std::string&);
+
+ICE_PATCH_API Ice::ByteSeq getBZ2(const std::string&, Ice::Int, Ice::Int);
+ICE_PATCH_API void createBZ2(const std::string&);
+
+class ICE_PATCH_API ProgressCB
+{
+public:
+
+ virtual void startDownload(Ice::Int, Ice::Int) = 0;
+ virtual void updateDownload(Ice::Int, Ice::Int) = 0;
+ virtual void finishedDownload(Ice::Int) = 0;
+
+ virtual void startUncompress(Ice::Int, Ice::Int) = 0;
+ virtual void updateUncompress(Ice::Int, Ice::Int) = 0;
+ virtual void finishedUncompress(Ice::Int) = 0;
+};
+ICE_PATCH_API void getRegular(const IcePatch::RegularPrx&, ProgressCB&);
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/CertificateVerifierOpenSSL.h b/cpp/include/IceSSL/CertificateVerifierOpenSSL.h index 6b230612df6..e06ca48f6ee 100644 --- a/cpp/include/IceSSL/CertificateVerifierOpenSSL.h +++ b/cpp/include/IceSSL/CertificateVerifierOpenSSL.h @@ -1,57 +1,57 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CERTIFICATE_VERIFIER_OPENSSL_H -#define ICE_SSL_CERTIFICATE_VERIFIER_OPENSSL_H - -#include <IceSSL/CertificateVerifier.h> -#include <openssl/ssl.h> - -#ifdef _WIN32 -# ifdef ICE_SSL_API_EXPORTS -# define ICE_SSL_API __declspec(dllexport) -# else -# define ICE_SSL_API __declspec(dllimport) -# endif -#else -# define ICE_SSL_API /**/ -#endif - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ICE_SSL_API CertificateVerifier : public IceSSL::CertificateVerifier -{ -public: - - virtual ~CertificateVerifier(); - - virtual int verify(int, X509_STORE_CTX*, SSL*) = 0; -}; - -typedef IceInternal::Handle<IceSSL::OpenSSL::CertificateVerifier> CertificateVerifierPtr; - -} - -} - -namespace IceInternal -{ - -ICE_SSL_API void incRef(IceSSL::OpenSSL::CertificateVerifier*); -ICE_SSL_API void decRef(IceSSL::OpenSSL::CertificateVerifier*); - -} - - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CERTIFICATE_VERIFIER_OPENSSL_H
+#define ICE_SSL_CERTIFICATE_VERIFIER_OPENSSL_H
+
+#include <IceSSL/CertificateVerifier.h>
+#include <openssl/ssl.h>
+
+#ifdef _WIN32
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API __declspec(dllexport)
+# else
+# define ICE_SSL_API __declspec(dllimport)
+# endif
+#else
+# define ICE_SSL_API /**/
+#endif
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ICE_SSL_API CertificateVerifier : public IceSSL::CertificateVerifier
+{
+public:
+
+ virtual ~CertificateVerifier();
+
+ virtual int verify(int, X509_STORE_CTX*, SSL*) = 0;
+};
+
+typedef IceInternal::Handle<IceSSL::OpenSSL::CertificateVerifier> CertificateVerifierPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+ICE_SSL_API void incRef(IceSSL::OpenSSL::CertificateVerifier*);
+ICE_SSL_API void decRef(IceSSL::OpenSSL::CertificateVerifier*);
+
+}
+
+
+#endif
diff --git a/cpp/include/IceSSL/RSACertificateGen.h b/cpp/include/IceSSL/RSACertificateGen.h index f6f8d74aeda..0288da8aeac 100644 --- a/cpp/include/IceSSL/RSACertificateGen.h +++ b/cpp/include/IceSSL/RSACertificateGen.h @@ -1,105 +1,105 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CERTIFICATE_GEN_H -#define ICE_SSL_CERTIFICATE_GEN_H - -#include <IceSSL/RSAKeyPairF.h> - -#ifdef _WIN32 -# ifdef ICE_SSL_API_EXPORTS -# define ICE_SSL_API __declspec(dllexport) -# else -# define ICE_SSL_API __declspec(dllimport) -# endif -#else -# define ICE_SSL_API /**/ -#endif - -namespace IceSSL -{ - -namespace OpenSSL -{ - -using namespace std; - -class ICE_SSL_API RSACertificateGenContext -{ -public: - - // - // Static - // - - // Conversion helper functions - static long minutesToSeconds(long); - static long hoursToSeconds(long); - static long daysToSeconds(long); - static long weeksToSeconds(long); - static long yearsToSeconds(long); - - // - // Instance - // - - RSACertificateGenContext(); - ~RSACertificateGenContext(); - - // Distinguished Name (setter) methods. - void setCountry(const std::string&); - void setStateProvince(const std::string&); - void setLocality(const std::string&); - void setOrganization(const std::string&); - void setOrgainizationalUnit(const std::string&); - void setCommonName(const std::string&); - - void setBitStrength(int); - void setSecondsValid(long); - - // Distinguished Name (getters) methods. - unsigned char* getCountry() const; - unsigned char* getStateProvince() const; - unsigned char* getLocality() const; - unsigned char* getOrganization() const; - unsigned char* getOrgainizationalUnit() const; - unsigned char* getCommonName() const; - - int getModulusLength() const; - long getSecondsValid() const; - -private: - - std::string _country; - std::string _stateProvince; - std::string _locality; - std::string _organization; - std::string _organizationalUnit; - std::string _commonName; - int _modulusLength; - long _secondsValid; -}; - -class ICE_SSL_API RSACertificateGen -{ -public: - - RSACertificateGen(); - ~RSACertificateGen(); - - RSAKeyPairPtr generate(const RSACertificateGenContext&); - RSAKeyPairPtr loadKeyPair(const std::string&, const std::string&); -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CERTIFICATE_GEN_H
+#define ICE_SSL_CERTIFICATE_GEN_H
+
+#include <IceSSL/RSAKeyPairF.h>
+
+#ifdef _WIN32
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API __declspec(dllexport)
+# else
+# define ICE_SSL_API __declspec(dllimport)
+# endif
+#else
+# define ICE_SSL_API /**/
+#endif
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+using namespace std;
+
+class ICE_SSL_API RSACertificateGenContext
+{
+public:
+
+ //
+ // Static
+ //
+
+ // Conversion helper functions
+ static long minutesToSeconds(long);
+ static long hoursToSeconds(long);
+ static long daysToSeconds(long);
+ static long weeksToSeconds(long);
+ static long yearsToSeconds(long);
+
+ //
+ // Instance
+ //
+
+ RSACertificateGenContext();
+ ~RSACertificateGenContext();
+
+ // Distinguished Name (setter) methods.
+ void setCountry(const std::string&);
+ void setStateProvince(const std::string&);
+ void setLocality(const std::string&);
+ void setOrganization(const std::string&);
+ void setOrgainizationalUnit(const std::string&);
+ void setCommonName(const std::string&);
+
+ void setBitStrength(int);
+ void setSecondsValid(long);
+
+ // Distinguished Name (getters) methods.
+ unsigned char* getCountry() const;
+ unsigned char* getStateProvince() const;
+ unsigned char* getLocality() const;
+ unsigned char* getOrganization() const;
+ unsigned char* getOrgainizationalUnit() const;
+ unsigned char* getCommonName() const;
+
+ int getModulusLength() const;
+ long getSecondsValid() const;
+
+private:
+
+ std::string _country;
+ std::string _stateProvince;
+ std::string _locality;
+ std::string _organization;
+ std::string _organizationalUnit;
+ std::string _commonName;
+ int _modulusLength;
+ long _secondsValid;
+};
+
+class ICE_SSL_API RSACertificateGen
+{
+public:
+
+ RSACertificateGen();
+ ~RSACertificateGen();
+
+ RSAKeyPairPtr generate(const RSACertificateGenContext&);
+ RSAKeyPairPtr loadKeyPair(const std::string&, const std::string&);
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSACertificateGenF.h b/cpp/include/IceSSL/RSACertificateGenF.h index 614310877b9..379d230e166 100644 --- a/cpp/include/IceSSL/RSACertificateGenF.h +++ b/cpp/include/IceSSL/RSACertificateGenF.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CERTIFICATE_GEN_F_H -#define ICE_SSL_CERTIFICATE_GEN_F_H - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class RSACertificateGenContext; -class RSACertificateGen; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CERTIFICATE_GEN_F_H
+#define ICE_SSL_CERTIFICATE_GEN_F_H
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class RSACertificateGenContext;
+class RSACertificateGen;
+
+}
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSAKeyPair.h b/cpp/include/IceSSL/RSAKeyPair.h index 907f0be5545..fc1518c33bf 100644 --- a/cpp/include/IceSSL/RSAKeyPair.h +++ b/cpp/include/IceSSL/RSAKeyPair.h @@ -1,78 +1,78 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_RSA_KEY_PAIR_H -#define ICE_SSL_RSA_KEY_PAIR_H - -#include <IceUtil/Shared.h> -#include <openssl/ssl.h> - -#include <Ice/BuiltinSequences.h> - -#include <IceSSL/RSAKeyPairF.h> -#include <IceSSL/RSACertificateGenF.h> -#include <IceSSL/RSAPrivateKeyF.h> -#include <IceSSL/RSAPublicKeyF.h> - -#ifdef _WIN32 -# ifdef ICE_SSL_API_EXPORTS -# define ICE_SSL_API __declspec(dllexport) -# else -# define ICE_SSL_API __declspec(dllimport) -# endif -#else -# define ICE_SSL_API /**/ -#endif - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ICE_SSL_API RSAKeyPair : public IceUtil::Shared -{ -public: - - // Construction from Base64 encodings. - RSAKeyPair(const std::string&, const std::string&); - - // Construction from binary DER encoding ByteSeq's. - RSAKeyPair(const Ice::ByteSeq&, const Ice::ByteSeq&); - - ~RSAKeyPair(); - - // Conversions to Base64 encodings. - void keyToBase64(std::string&); - void certToBase64(std::string&); - - // Conversions to binary DER encodings. - void keyToByteSeq(Ice::ByteSeq&); - void certToByteSeq(Ice::ByteSeq&); - - // Get the internal key structures as per the OpenSSL implementation. - RSA* getRSAPrivateKey() const; - X509* getX509PublicKey() const; - -private: - - RSAKeyPair(const RSAPrivateKeyPtr&, const RSAPublicKeyPtr&); - - friend class RSACertificateGen; - - RSAPrivateKeyPtr _privateKey; - RSAPublicKeyPtr _publicKey; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_RSA_KEY_PAIR_H
+#define ICE_SSL_RSA_KEY_PAIR_H
+
+#include <IceUtil/Shared.h>
+#include <openssl/ssl.h>
+
+#include <Ice/BuiltinSequences.h>
+
+#include <IceSSL/RSAKeyPairF.h>
+#include <IceSSL/RSACertificateGenF.h>
+#include <IceSSL/RSAPrivateKeyF.h>
+#include <IceSSL/RSAPublicKeyF.h>
+
+#ifdef _WIN32
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API __declspec(dllexport)
+# else
+# define ICE_SSL_API __declspec(dllimport)
+# endif
+#else
+# define ICE_SSL_API /**/
+#endif
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ICE_SSL_API RSAKeyPair : public IceUtil::Shared
+{
+public:
+
+ // Construction from Base64 encodings.
+ RSAKeyPair(const std::string&, const std::string&);
+
+ // Construction from binary DER encoding ByteSeq's.
+ RSAKeyPair(const Ice::ByteSeq&, const Ice::ByteSeq&);
+
+ ~RSAKeyPair();
+
+ // Conversions to Base64 encodings.
+ void keyToBase64(std::string&);
+ void certToBase64(std::string&);
+
+ // Conversions to binary DER encodings.
+ void keyToByteSeq(Ice::ByteSeq&);
+ void certToByteSeq(Ice::ByteSeq&);
+
+ // Get the internal key structures as per the OpenSSL implementation.
+ RSA* getRSAPrivateKey() const;
+ X509* getX509PublicKey() const;
+
+private:
+
+ RSAKeyPair(const RSAPrivateKeyPtr&, const RSAPublicKeyPtr&);
+
+ friend class RSACertificateGen;
+
+ RSAPrivateKeyPtr _privateKey;
+ RSAPublicKeyPtr _publicKey;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSAKeyPairF.h b/cpp/include/IceSSL/RSAKeyPairF.h index a2c900326af..d0698ec55bb 100644 --- a/cpp/include/IceSSL/RSAKeyPairF.h +++ b/cpp/include/IceSSL/RSAKeyPairF.h @@ -1,47 +1,47 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_RSA_KEY_PAIR_F_H -#define ICE_SSL_RSA_KEY_PAIR_F_H - -#include <Ice/Handle.h> - -#ifdef _WIN32 -# ifdef ICE_SSL_API_EXPORTS -# define ICE_SSL_API __declspec(dllexport) -# else -# define ICE_SSL_API __declspec(dllimport) -# endif -#else -# define ICE_SSL_API /**/ -#endif - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class RSAKeyPair; -typedef IceInternal::Handle<RSAKeyPair> RSAKeyPairPtr; - -} - -} - -namespace IceInternal -{ - -void ICE_SSL_API incRef(::IceSSL::OpenSSL::RSAKeyPair*); -void ICE_SSL_API decRef(::IceSSL::OpenSSL::RSAKeyPair*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_RSA_KEY_PAIR_F_H
+#define ICE_SSL_RSA_KEY_PAIR_F_H
+
+#include <Ice/Handle.h>
+
+#ifdef _WIN32
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API __declspec(dllexport)
+# else
+# define ICE_SSL_API __declspec(dllimport)
+# endif
+#else
+# define ICE_SSL_API /**/
+#endif
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class RSAKeyPair;
+typedef IceInternal::Handle<RSAKeyPair> RSAKeyPairPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void ICE_SSL_API incRef(::IceSSL::OpenSSL::RSAKeyPair*);
+void ICE_SSL_API decRef(::IceSSL::OpenSSL::RSAKeyPair*);
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSAPrivateKey.h b/cpp/include/IceSSL/RSAPrivateKey.h index 49fc18ca1f3..cf72c1bbf26 100644 --- a/cpp/include/IceSSL/RSAPrivateKey.h +++ b/cpp/include/IceSSL/RSAPrivateKey.h @@ -1,73 +1,73 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_RSA_PRIVATE_KEY_H -#define ICE_SSL_RSA_PRIVATE_KEY_H - -#include <IceUtil/Shared.h> - -#include <Ice/BuiltinSequences.h> - -#include <IceSSL/RSAPrivateKeyF.h> - -#include <openssl/ssl.h> - -#ifdef _WIN32 -# ifdef ICE_SSL_API_EXPORTS -# define ICE_SSL_API __declspec(dllexport) -# else -# define ICE_SSL_API __declspec(dllimport) -# endif -#else -# define ICE_SSL_API /**/ -#endif - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ICE_SSL_API RSAPrivateKey : public IceUtil::Shared -{ -public: - - // Construction from Base64 encoding. - RSAPrivateKey(const std::string&); - - // Construction from binary DER encoding ByteSeq. - RSAPrivateKey(const Ice::ByteSeq&); - - // Construction from RSA Private Key structure (simple initialization). - RSAPrivateKey(RSA*); - - ~RSAPrivateKey(); - - // Conversion to Base64 encoding. - void keyToBase64(std::string&); - - // Conversion to binary DER encoding. - void keyToByteSeq(Ice::ByteSeq&); - - // Get the internal key structure as per the OpenSSL implementation. - RSA* get() const; - -private: - - void byteSeqToKey(const Ice::ByteSeq&); - - RSA* _privateKey; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_RSA_PRIVATE_KEY_H
+#define ICE_SSL_RSA_PRIVATE_KEY_H
+
+#include <IceUtil/Shared.h>
+
+#include <Ice/BuiltinSequences.h>
+
+#include <IceSSL/RSAPrivateKeyF.h>
+
+#include <openssl/ssl.h>
+
+#ifdef _WIN32
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API __declspec(dllexport)
+# else
+# define ICE_SSL_API __declspec(dllimport)
+# endif
+#else
+# define ICE_SSL_API /**/
+#endif
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ICE_SSL_API RSAPrivateKey : public IceUtil::Shared
+{
+public:
+
+ // Construction from Base64 encoding.
+ RSAPrivateKey(const std::string&);
+
+ // Construction from binary DER encoding ByteSeq.
+ RSAPrivateKey(const Ice::ByteSeq&);
+
+ // Construction from RSA Private Key structure (simple initialization).
+ RSAPrivateKey(RSA*);
+
+ ~RSAPrivateKey();
+
+ // Conversion to Base64 encoding.
+ void keyToBase64(std::string&);
+
+ // Conversion to binary DER encoding.
+ void keyToByteSeq(Ice::ByteSeq&);
+
+ // Get the internal key structure as per the OpenSSL implementation.
+ RSA* get() const;
+
+private:
+
+ void byteSeqToKey(const Ice::ByteSeq&);
+
+ RSA* _privateKey;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSAPrivateKeyF.h b/cpp/include/IceSSL/RSAPrivateKeyF.h index b907d439030..e8e301845d4 100644 --- a/cpp/include/IceSSL/RSAPrivateKeyF.h +++ b/cpp/include/IceSSL/RSAPrivateKeyF.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_RSA_PRIVATE_KEY_F_H -#define ICE_SSL_RSA_PRIVATE_KEY_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class RSAPrivateKey; -typedef IceInternal::Handle<RSAPrivateKey> RSAPrivateKeyPtr; - -} - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::OpenSSL::RSAPrivateKey*); -void decRef(::IceSSL::OpenSSL::RSAPrivateKey*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_RSA_PRIVATE_KEY_F_H
+#define ICE_SSL_RSA_PRIVATE_KEY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class RSAPrivateKey;
+typedef IceInternal::Handle<RSAPrivateKey> RSAPrivateKeyPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::OpenSSL::RSAPrivateKey*);
+void decRef(::IceSSL::OpenSSL::RSAPrivateKey*);
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSAPublicKey.h b/cpp/include/IceSSL/RSAPublicKey.h index 371bb17dbba..372f36d5912 100644 --- a/cpp/include/IceSSL/RSAPublicKey.h +++ b/cpp/include/IceSSL/RSAPublicKey.h @@ -1,73 +1,73 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_RSA_PUBLIC_KEY_H -#define ICE_SSL_RSA_PUBLIC_KEY_H - -#include <IceUtil/Shared.h> - -#include <Ice/BuiltinSequences.h> - -#include <IceSSL/RSAPublicKeyF.h> - -#include <openssl/ssl.h> - -#ifdef _WIN32 -# ifdef ICE_SSL_API_EXPORTS -# define ICE_SSL_API __declspec(dllexport) -# else -# define ICE_SSL_API __declspec(dllimport) -# endif -#else -# define ICE_SSL_API /**/ -#endif - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ICE_SSL_API RSAPublicKey : public IceUtil::Shared -{ -public: - - // Construction from Base64 encoding. - RSAPublicKey(const std::string&); - - // Construction from binary DER encoding ByteSeq. - RSAPublicKey(const Ice::ByteSeq&); - - // Construction from X509 structure (simple initialization). - RSAPublicKey(X509*); - - ~RSAPublicKey(); - - // Conversion to Base64 encoding. - void certToBase64(std::string&); - - // Conversion to binary DER encoding. - void certToByteSeq(Ice::ByteSeq&); - - // Get the internal key structure as per the OpenSSL implementation. - X509* getX509PublicKey() const; - -private: - - void byteSeqToCert(const Ice::ByteSeq&); - - X509* _publicKey; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_RSA_PUBLIC_KEY_H
+#define ICE_SSL_RSA_PUBLIC_KEY_H
+
+#include <IceUtil/Shared.h>
+
+#include <Ice/BuiltinSequences.h>
+
+#include <IceSSL/RSAPublicKeyF.h>
+
+#include <openssl/ssl.h>
+
+#ifdef _WIN32
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API __declspec(dllexport)
+# else
+# define ICE_SSL_API __declspec(dllimport)
+# endif
+#else
+# define ICE_SSL_API /**/
+#endif
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ICE_SSL_API RSAPublicKey : public IceUtil::Shared
+{
+public:
+
+ // Construction from Base64 encoding.
+ RSAPublicKey(const std::string&);
+
+ // Construction from binary DER encoding ByteSeq.
+ RSAPublicKey(const Ice::ByteSeq&);
+
+ // Construction from X509 structure (simple initialization).
+ RSAPublicKey(X509*);
+
+ ~RSAPublicKey();
+
+ // Conversion to Base64 encoding.
+ void certToBase64(std::string&);
+
+ // Conversion to binary DER encoding.
+ void certToByteSeq(Ice::ByteSeq&);
+
+ // Get the internal key structure as per the OpenSSL implementation.
+ X509* getX509PublicKey() const;
+
+private:
+
+ void byteSeqToCert(const Ice::ByteSeq&);
+
+ X509* _publicKey;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/include/IceSSL/RSAPublicKeyF.h b/cpp/include/IceSSL/RSAPublicKeyF.h index b4ff5dd29b0..1cdc1103ced 100644 --- a/cpp/include/IceSSL/RSAPublicKeyF.h +++ b/cpp/include/IceSSL/RSAPublicKeyF.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_RSA_PUBLIC_KEY_F_H -#define ICE_SSL_RSA_PUBLIC_KEY_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class RSAPublicKey; -typedef IceInternal::Handle<RSAPublicKey> RSAPublicKeyPtr; - -} - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::OpenSSL::RSAPublicKey*); -void decRef(::IceSSL::OpenSSL::RSAPublicKey*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_RSA_PUBLIC_KEY_F_H
+#define ICE_SSL_RSA_PUBLIC_KEY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class RSAPublicKey;
+typedef IceInternal::Handle<RSAPublicKey> RSAPublicKeyPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::OpenSSL::RSAPublicKey*);
+void decRef(::IceSSL::OpenSSL::RSAPublicKey*);
+
+}
+
+#endif
diff --git a/cpp/include/IceUtil/Cond.h b/cpp/include/IceUtil/Cond.h index 20a22f2d522..2059bff9a00 100644 --- a/cpp/include/IceUtil/Cond.h +++ b/cpp/include/IceUtil/Cond.h @@ -1,334 +1,334 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_COND_H -#define ICE_UTIL_COND_H - -#include <IceUtil/Config.h> -#include <IceUtil/Exception.h> -#include <IceUtil/Time.h> - -#ifdef _WIN32 -// -// Needed for implementation under WIN32. -// -# include <IceUtil/Mutex.h> -// -// See member-template note for waitImpl & timedWaitImpl. -// -# include <IceUtil/RecMutex.h> -#endif - -namespace IceUtil -{ - -// -// Forward declaration (for friend declarations). -// -template <class T> class Monitor; -class RecMutex; -class Mutex; - -#ifdef _WIN32 -// -// Needed for implementation. -// -class Semaphore -{ -public: - - Semaphore(long = 0); - ~Semaphore(); - - void wait() const; - bool timedWait(const Time&) const; - void post(int = 1) const; - -private: - - mutable HANDLE _sem; -}; -#endif - -// -// Condition variable implementation. Conforms to the same semantics -// as a POSIX threads condition variable. -// -class ICE_UTIL_API Cond : public noncopyable -{ -public: - - Cond(); - ~Cond(); - - // - // signal restarts one of the threads that are waiting on the - // condition variable cond. If no threads are waiting on cond, - // nothing happens. If several threads are waiting on cond, - // exactly one is restarted, but it is not specified which. - // - void signal(); - - // - // broadcast restarts all the threads that are waiting on the - // condition variable cond. Nothing happens if no threads are - // waiting on cond. - // - void broadcast(); - - // - // MSVC doesn't support out-of-class definitions of member - // templates. See KB Article Q241949 for details. - // - - // - // wait atomically unlocks the mutex and waits for the condition - // variable to be signaled. Before returning to the calling thread - // the mutex is reaquired. - // - template <typename Lock> inline void - wait(const Lock& lock) const - { - waitImpl(lock._mutex); - } - - // - // wait atomically unlocks the mutex and waits for the condition - // variable to be signaled for up to the given timeout. Before - // returning to the calling thread the mutex is reaquired. Returns - // true if the condition variable was signaled, false on a - // timeout. - // - template <typename Lock> inline bool - timedWait(const Lock& lock, const Time& timeout) const - { - return timedWaitImpl(lock._mutex, timeout); - } - -private: - - friend class Monitor<Mutex>; - friend class Monitor<RecMutex>; - - // - // The Monitor implementation uses waitImpl & timedWaitImpl. - // -#ifdef _WIN32 - - // - // For some reason under WIN32 with VC6 using a member-template - // for waitImpl & timedWaitImpl results in a link error for - // RecMutex. - // -/* - template <typename M> void - waitImpl(const M& mutex) const - { - preWait(); - - typedef typename M::LockState LockState; - - LockState state; - mutex.unlock(state); - - try - { - dowait(-1); - mutex.lock(state); - } - catch(...) - { - mutex.lock(state); - throw; - } - } - template <typename M> bool - timedWaitImpl(const M& mutex, const Time& timeout) const - { - preWait(); - - typedef typename M::LockState LockState; - - LockState state; - mutex.unlock(state); - - try - { - bool rc = dowait(timeout); - mutex.lock(state); - return rc; - } - catch(...) - { - mutex.lock(state); - throw; - } - } - */ - - void - waitImpl(const RecMutex& mutex) const - { - preWait(); - - RecMutex::LockState state; - mutex.unlock(state); - - try - { - dowait(); - mutex.lock(state); - } - catch(...) - { - mutex.lock(state); - throw; - } - } - - void - waitImpl(const Mutex& mutex) const - { - preWait(); - - Mutex::LockState state; - mutex.unlock(state); - - try - { - dowait(); - mutex.lock(state); - } - catch(...) - { - mutex.lock(state); - throw; - } - } - - bool - timedWaitImpl(const RecMutex& mutex, const Time& timeout) const - { - preWait(); - - RecMutex::LockState state; - mutex.unlock(state); - - try - { - bool rc = timedDowait(timeout); - mutex.lock(state); - return rc; - } - catch(...) - { - mutex.lock(state); - throw; - } - } - - bool - timedWaitImpl(const Mutex& mutex, const Time& timeout) const - { - preWait(); - - Mutex::LockState state; - mutex.unlock(state); - - try - { - bool rc = timedDowait(timeout); - mutex.lock(state); - return rc; - } - catch(...) - { - mutex.lock(state); - throw; - } - } - -#else - - template <typename M> void waitImpl(const M&) const; - template <typename M> bool timedWaitImpl(const M&, const Time&) const; - -#endif - -#ifdef _WIN32 - void wake(bool); - void preWait() const; - void postWait(bool) const; - bool timedDowait(const Time&) const; - void dowait() const; - - Mutex _internal; - Semaphore _gate; - Semaphore _queue; - mutable long _blocked; - mutable long _unblocked; - mutable long _toUnblock; -#else - mutable pthread_cond_t _cond; -#endif - -}; - -#ifndef _WIN32 -template <typename M> inline void -Cond::waitImpl(const M& mutex) const -{ - typedef typename M::LockState LockState; - - LockState state; - mutex.unlock(state); - int rc = pthread_cond_wait(&_cond, state.mutex); - mutex.lock(state); - - if (rc != 0) - { - throw SyscallException(strerror(rc), __FILE__, __LINE__); - } -} - -template <typename M> inline bool -Cond::timedWaitImpl(const M& mutex, const Time& timeout) const -{ - typedef typename M::LockState LockState; - - LockState state; - mutex.unlock(state); - - timeval tv = Time::now() + timeout; - timespec ts; - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec*1000; - int rc = pthread_cond_timedwait(&_cond, state.mutex, &ts); - mutex.lock(state); - - if (rc != 0) - { - // - // pthread_cond_timedwait returns ETIMEOUT in the event of a - // timeout. - // - if (rc != ETIMEDOUT) - { - throw SyscallException(strerror(rc), __FILE__, __LINE__); - } - return false; - } - return true; -} -#endif - -} // End namespace IceUtil - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_COND_H
+#define ICE_UTIL_COND_H
+
+#include <IceUtil/Config.h>
+#include <IceUtil/Exception.h>
+#include <IceUtil/Time.h>
+
+#ifdef _WIN32
+//
+// Needed for implementation under WIN32.
+//
+# include <IceUtil/Mutex.h>
+//
+// See member-template note for waitImpl & timedWaitImpl.
+//
+# include <IceUtil/RecMutex.h>
+#endif
+
+namespace IceUtil
+{
+
+//
+// Forward declaration (for friend declarations).
+//
+template <class T> class Monitor;
+class RecMutex;
+class Mutex;
+
+#ifdef _WIN32
+//
+// Needed for implementation.
+//
+class Semaphore
+{
+public:
+
+ Semaphore(long = 0);
+ ~Semaphore();
+
+ void wait() const;
+ bool timedWait(const Time&) const;
+ void post(int = 1) const;
+
+private:
+
+ mutable HANDLE _sem;
+};
+#endif
+
+//
+// Condition variable implementation. Conforms to the same semantics
+// as a POSIX threads condition variable.
+//
+class ICE_UTIL_API Cond : public noncopyable
+{
+public:
+
+ Cond();
+ ~Cond();
+
+ //
+ // signal restarts one of the threads that are waiting on the
+ // condition variable cond. If no threads are waiting on cond,
+ // nothing happens. If several threads are waiting on cond,
+ // exactly one is restarted, but it is not specified which.
+ //
+ void signal();
+
+ //
+ // broadcast restarts all the threads that are waiting on the
+ // condition variable cond. Nothing happens if no threads are
+ // waiting on cond.
+ //
+ void broadcast();
+
+ //
+ // MSVC doesn't support out-of-class definitions of member
+ // templates. See KB Article Q241949 for details.
+ //
+
+ //
+ // wait atomically unlocks the mutex and waits for the condition
+ // variable to be signaled. Before returning to the calling thread
+ // the mutex is reaquired.
+ //
+ template <typename Lock> inline void
+ wait(const Lock& lock) const
+ {
+ waitImpl(lock._mutex);
+ }
+
+ //
+ // wait atomically unlocks the mutex and waits for the condition
+ // variable to be signaled for up to the given timeout. Before
+ // returning to the calling thread the mutex is reaquired. Returns
+ // true if the condition variable was signaled, false on a
+ // timeout.
+ //
+ template <typename Lock> inline bool
+ timedWait(const Lock& lock, const Time& timeout) const
+ {
+ return timedWaitImpl(lock._mutex, timeout);
+ }
+
+private:
+
+ friend class Monitor<Mutex>;
+ friend class Monitor<RecMutex>;
+
+ //
+ // The Monitor implementation uses waitImpl & timedWaitImpl.
+ //
+#ifdef _WIN32
+
+ //
+ // For some reason under WIN32 with VC6 using a member-template
+ // for waitImpl & timedWaitImpl results in a link error for
+ // RecMutex.
+ //
+/*
+ template <typename M> void
+ waitImpl(const M& mutex) const
+ {
+ preWait();
+
+ typedef typename M::LockState LockState;
+
+ LockState state;
+ mutex.unlock(state);
+
+ try
+ {
+ dowait(-1);
+ mutex.lock(state);
+ }
+ catch(...)
+ {
+ mutex.lock(state);
+ throw;
+ }
+ }
+ template <typename M> bool
+ timedWaitImpl(const M& mutex, const Time& timeout) const
+ {
+ preWait();
+
+ typedef typename M::LockState LockState;
+
+ LockState state;
+ mutex.unlock(state);
+
+ try
+ {
+ bool rc = dowait(timeout);
+ mutex.lock(state);
+ return rc;
+ }
+ catch(...)
+ {
+ mutex.lock(state);
+ throw;
+ }
+ }
+ */
+
+ void
+ waitImpl(const RecMutex& mutex) const
+ {
+ preWait();
+
+ RecMutex::LockState state;
+ mutex.unlock(state);
+
+ try
+ {
+ dowait();
+ mutex.lock(state);
+ }
+ catch(...)
+ {
+ mutex.lock(state);
+ throw;
+ }
+ }
+
+ void
+ waitImpl(const Mutex& mutex) const
+ {
+ preWait();
+
+ Mutex::LockState state;
+ mutex.unlock(state);
+
+ try
+ {
+ dowait();
+ mutex.lock(state);
+ }
+ catch(...)
+ {
+ mutex.lock(state);
+ throw;
+ }
+ }
+
+ bool
+ timedWaitImpl(const RecMutex& mutex, const Time& timeout) const
+ {
+ preWait();
+
+ RecMutex::LockState state;
+ mutex.unlock(state);
+
+ try
+ {
+ bool rc = timedDowait(timeout);
+ mutex.lock(state);
+ return rc;
+ }
+ catch(...)
+ {
+ mutex.lock(state);
+ throw;
+ }
+ }
+
+ bool
+ timedWaitImpl(const Mutex& mutex, const Time& timeout) const
+ {
+ preWait();
+
+ Mutex::LockState state;
+ mutex.unlock(state);
+
+ try
+ {
+ bool rc = timedDowait(timeout);
+ mutex.lock(state);
+ return rc;
+ }
+ catch(...)
+ {
+ mutex.lock(state);
+ throw;
+ }
+ }
+
+#else
+
+ template <typename M> void waitImpl(const M&) const;
+ template <typename M> bool timedWaitImpl(const M&, const Time&) const;
+
+#endif
+
+#ifdef _WIN32
+ void wake(bool);
+ void preWait() const;
+ void postWait(bool) const;
+ bool timedDowait(const Time&) const;
+ void dowait() const;
+
+ Mutex _internal;
+ Semaphore _gate;
+ Semaphore _queue;
+ mutable long _blocked;
+ mutable long _unblocked;
+ mutable long _toUnblock;
+#else
+ mutable pthread_cond_t _cond;
+#endif
+
+};
+
+#ifndef _WIN32
+template <typename M> inline void
+Cond::waitImpl(const M& mutex) const
+{
+ typedef typename M::LockState LockState;
+
+ LockState state;
+ mutex.unlock(state);
+ int rc = pthread_cond_wait(&_cond, state.mutex);
+ mutex.lock(state);
+
+ if(rc != 0)
+ {
+ throw SyscallException(strerror(rc), __FILE__, __LINE__);
+ }
+}
+
+template <typename M> inline bool
+Cond::timedWaitImpl(const M& mutex, const Time& timeout) const
+{
+ typedef typename M::LockState LockState;
+
+ LockState state;
+ mutex.unlock(state);
+
+ timeval tv = Time::now() + timeout;
+ timespec ts;
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec*1000;
+ int rc = pthread_cond_timedwait(&_cond, state.mutex, &ts);
+ mutex.lock(state);
+
+ if(rc != 0)
+ {
+ //
+ // pthread_cond_timedwait returns ETIMEOUT in the event of a
+ // timeout.
+ //
+ if(rc != ETIMEDOUT)
+ {
+ throw SyscallException(strerror(rc), __FILE__, __LINE__);
+ }
+ return false;
+ }
+ return true;
+}
+#endif
+
+} // End namespace IceUtil
+
+#endif
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h index 1250469e08a..5823038aaeb 100644 --- a/cpp/include/IceUtil/Config.h +++ b/cpp/include/IceUtil/Config.h @@ -1,131 +1,131 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_CONFIG_H -#define ICE_UTIL_CONFIG_H - -// -// For STLport. If we compile in debug mode, we want to use the debug -// STLport library. This is done by setting _STLP_DEBUG before any -// STLport header files are included. -// -# if !defined(NDEBUG) && !defined(_STLP_DEBUG) -# define _STLP_DEBUG -# endif - -// -// For STLport. If we compile in debug mode, we want to use the debug -// memory allocation, so that purify doesn't report bogus memory -// leaks. This is done by setting _STLP_USE_MALLOC before any STLport -// header files are included. -// -# if !defined(NDEBUG) && !defined(_STLP_USE_MALLOC) -# define _STLP_USE_MALLOC -# endif - -#if defined(_WIN32) - -// Necessary for TryEnterCriticalSection. -# define _WIN32_WINNT 0x0400 - -# if !defined(_UNICODE) -# error "Only unicode libraries can be used with Ice!" -# endif - -# if !defined(_DLL) || !defined(_MT) -# error "Only multi-threaded DLL libraries can be used with Ice!" -# endif - -# ifdef ICE_UTIL_API_EXPORTS -# define ICE_UTIL_API __declspec(dllexport) -# else -# define ICE_UTIL_API __declspec(dllimport) -# endif - -# include <windows.h> - -// '...' : forcing value to bool 'true' or 'false' (performance warning) -# pragma warning( disable : 4800 ) -// ... identifier was truncated to '255' characters in the debug information -# pragma warning( disable : 4786 ) -// 'this' : used in base member initializer list -# pragma warning( disable : 4355 ) -// class ... needs to have dll-interface to be used by clients of class ... -# pragma warning( disable : 4251 ) -// ... : inherits ... via dominance -# pragma warning( disable : 4250 ) -// non dll-interface class ... used as base for dll-interface class ... -# pragma warning( disable : 4275 ) -// ...: decorated name length exceeded, name was truncated -# pragma warning( disable : 4503 ) - -# define SIZEOF_WCHAR_T 2 - -#elif defined(__linux__) && defined(i386) - -# define ICE_UTIL_API /**/ -# define HAVE_READLINE -# define SIZEOF_WCHAR_T 4 - -#else - -# error "unsupported operating system or platform" - -#endif - -// -// Some include files we need almost everywhere -// -#include <cassert> -#include <iostream> -#include <sstream> - -#ifndef _WIN32 -# ifndef _REENTRANT -# define _REENTRANT 1 -# endif -# include <pthread.h> -# include <errno.h> -#endif - -// -// By deriving from this class, other classes are made non-copyable -// -namespace IceUtil -{ - -// -// TODO: Constructor and destructor should not be inlined, as they are -// not performance critical. -// -// TODO: Naming conventions? -// -class noncopyable -{ -protected: - - noncopyable() { } - ~noncopyable() { } // May not be virtual! Classes without virtual operations also derive from noncopyable. - -private: - - noncopyable(const noncopyable&); - const noncopyable& operator=(const noncopyable&); -}; - -} - -// -// The Ice version -// -#define ICE_STRING_VERSION "0.0.1" -#define ICE_INT_VERSION 0x00000001 - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_CONFIG_H
+#define ICE_UTIL_CONFIG_H
+
+//
+// For STLport. If we compile in debug mode, we want to use the debug
+// STLport library. This is done by setting _STLP_DEBUG before any
+// STLport header files are included.
+//
+# if !defined(NDEBUG) && !defined(_STLP_DEBUG)
+# define _STLP_DEBUG
+# endif
+
+//
+// For STLport. If we compile in debug mode, we want to use the debug
+// memory allocation, so that purify doesn't report bogus memory
+// leaks. This is done by setting _STLP_USE_MALLOC before any STLport
+// header files are included.
+//
+# if !defined(NDEBUG) && !defined(_STLP_USE_MALLOC)
+# define _STLP_USE_MALLOC
+# endif
+
+#if defined(_WIN32)
+
+// Necessary for TryEnterCriticalSection.
+# define _WIN32_WINNT 0x0400
+
+# if !defined(_UNICODE)
+# error "Only unicode libraries can be used with Ice!"
+# endif
+
+# if !defined(_DLL) || !defined(_MT)
+# error "Only multi-threaded DLL libraries can be used with Ice!"
+# endif
+
+# ifdef ICE_UTIL_API_EXPORTS
+# define ICE_UTIL_API __declspec(dllexport)
+# else
+# define ICE_UTIL_API __declspec(dllimport)
+# endif
+
+# include <windows.h>
+
+// '...' : forcing value to bool 'true' or 'false' (performance warning)
+# pragma warning( disable : 4800 )
+// ... identifier was truncated to '255' characters in the debug information
+# pragma warning( disable : 4786 )
+// 'this' : used in base member initializer list
+# pragma warning( disable : 4355 )
+// class ... needs to have dll-interface to be used by clients of class ...
+# pragma warning( disable : 4251 )
+// ... : inherits ... via dominance
+# pragma warning( disable : 4250 )
+// non dll-interface class ... used as base for dll-interface class ...
+# pragma warning( disable : 4275 )
+// ...: decorated name length exceeded, name was truncated
+# pragma warning( disable : 4503 )
+
+# define SIZEOF_WCHAR_T 2
+
+#elif defined(__linux__) && defined(i386)
+
+# define ICE_UTIL_API /**/
+# define HAVE_READLINE
+# define SIZEOF_WCHAR_T 4
+
+#else
+
+# error "unsupported operating system or platform"
+
+#endif
+
+//
+// Some include files we need almost everywhere
+//
+#include <cassert>
+#include <iostream>
+#include <sstream>
+
+#ifndef _WIN32
+# ifndef _REENTRANT
+# define _REENTRANT 1
+# endif
+# include <pthread.h>
+# include <errno.h>
+#endif
+
+//
+// By deriving from this class, other classes are made non-copyable
+//
+namespace IceUtil
+{
+
+//
+// TODO: Constructor and destructor should not be inlined, as they are
+// not performance critical.
+//
+// TODO: Naming conventions?
+//
+class noncopyable
+{
+protected:
+
+ noncopyable() { }
+ ~noncopyable() { } // May not be virtual! Classes without virtual operations also derive from noncopyable.
+
+private:
+
+ noncopyable(const noncopyable&);
+ const noncopyable& operator=(const noncopyable&);
+};
+
+}
+
+//
+// The Ice version
+//
+#define ICE_STRING_VERSION "0.0.1"
+#define ICE_INT_VERSION 0x00000001
+
+#endif
diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h index 2993d866a9b..5d45362db38 100644 --- a/cpp/include/IceUtil/Exception.h +++ b/cpp/include/IceUtil/Exception.h @@ -1,85 +1,85 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_EXCEPTION_H -#define ICE_UTIL_EXCEPTION_H - -#include <IceUtil/Config.h> - -namespace IceUtil -{ - -class ICE_UTIL_API Exception -{ -public: - - Exception(); - Exception(const char*, int); - virtual ~Exception(); - virtual std::string ice_name() const; - virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; - virtual void ice_throw() const; - const char* ice_file() const; - int ice_line() const; - -private: - - const char* _file; - int _line; -}; - -ICE_UTIL_API std::ostream& operator<<(std::ostream&, const Exception&); - -class ICE_UTIL_API NullHandleException : public Exception -{ -public: - - NullHandleException(const char*, int); - virtual std::string ice_name() const; - virtual Exception* ice_clone() const; - virtual void ice_throw() const; -}; - -class ICE_UTIL_API SyscallException : public Exception -{ -public: - - SyscallException(const std::string&, const char*, int); - virtual std::string ice_name() const; - virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; - virtual void ice_throw() const; - -#ifdef _WIN32 - // - // IceInternal::errorToString does the same thing... refactor? - // - static std::string errorToString(DWORD); -#endif - -private: - - std::string _error; -}; - -class ICE_UTIL_API LockedException : public Exception -{ -public: - - LockedException(const char*, int); - virtual std::string ice_name() const; - virtual Exception* ice_clone() const; - virtual void ice_throw() const; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_EXCEPTION_H
+#define ICE_UTIL_EXCEPTION_H
+
+#include <IceUtil/Config.h>
+
+namespace IceUtil
+{
+
+class ICE_UTIL_API Exception
+{
+public:
+
+ Exception();
+ Exception(const char*, int);
+ virtual ~Exception();
+ virtual std::string ice_name() const;
+ virtual void ice_print(std::ostream&) const;
+ virtual Exception* ice_clone() const;
+ virtual void ice_throw() const;
+ const char* ice_file() const;
+ int ice_line() const;
+
+private:
+
+ const char* _file;
+ int _line;
+};
+
+ICE_UTIL_API std::ostream& operator<<(std::ostream&, const Exception&);
+
+class ICE_UTIL_API NullHandleException : public Exception
+{
+public:
+
+ NullHandleException(const char*, int);
+ virtual std::string ice_name() const;
+ virtual Exception* ice_clone() const;
+ virtual void ice_throw() const;
+};
+
+class ICE_UTIL_API SyscallException : public Exception
+{
+public:
+
+ SyscallException(const std::string&, const char*, int);
+ virtual std::string ice_name() const;
+ virtual void ice_print(std::ostream&) const;
+ virtual Exception* ice_clone() const;
+ virtual void ice_throw() const;
+
+#ifdef _WIN32
+ //
+ // IceInternal::errorToString does the same thing... refactor?
+ //
+ static std::string errorToString(DWORD);
+#endif
+
+private:
+
+ std::string _error;
+};
+
+class ICE_UTIL_API LockedException : public Exception
+{
+public:
+
+ LockedException(const char*, int);
+ virtual std::string ice_name() const;
+ virtual Exception* ice_clone() const;
+ virtual void ice_throw() const;
+};
+
+}
+
+#endif
diff --git a/cpp/include/IceUtil/Functional.h b/cpp/include/IceUtil/Functional.h index 3552c9d10c6..9936bcce85d 100644 --- a/cpp/include/IceUtil/Functional.h +++ b/cpp/include/IceUtil/Functional.h @@ -1,453 +1,453 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_FUNCTIONAL_H -#define ICE_UTIL_FUNCTIONAL_H - -#include <IceUtil/Handle.h> -#include <functional> - -namespace IceUtilInternal -{ - -// ---------------------------------------------------------------------- -// Various function objects that work with handles instead of plain -// pointers. -// ---------------------------------------------------------------------- - -template<class R, class T, class H> -class MemFun : public std::unary_function<H, R> -{ - typedef R (T::*MemberFN)(void); - MemberFN _mfn; - -public: - - explicit MemFun(MemberFN p) : _mfn(p) { } - R operator()(H handle) const - { - return (handle.get() ->* _mfn)(); - } -}; - -template<class R, class T, class H, class A> -class MemFun1 : public std::binary_function<H, A, R> -{ - typedef R (T::*MemberFN)(A); - MemberFN _mfn; - -public: - - explicit MemFun1(MemberFN p) : _mfn(p) { } - R operator()(H handle, A arg) const - { - return (handle.get() ->* _mfn)(arg); - } -}; - -template<class T, class H> -class VoidMemFun : public std::unary_function<H, void> -{ - typedef void (T::*MemberFN)(void); - MemberFN _mfn; - -public: - - explicit VoidMemFun(MemberFN p) : _mfn(p) { } - void operator()(H handle) const - { - (handle.get() ->* _mfn)(); - } -}; - -template<class T, class H, class A> -class VoidMemFun1 : public std::binary_function<H, A, void> -{ - typedef void (T::*MemberFN)(A); - MemberFN _mfn; - -public: - - explicit VoidMemFun1(MemberFN p) : _mfn(p) { } - void operator()(H handle, A arg) const - { - (handle.get() ->* _mfn)(arg); - } -}; - -template<class R, class K, class T, class H> -class SecondMemFun : public std::unary_function<std::pair<K, H>, R> -{ - typedef R (T::*MemberFN)(void); - MemberFN _mfn; - -public: - - explicit SecondMemFun(MemberFN p) : _mfn(p) { } - R operator()(std::pair<K, H> pair) const - { - return (pair.second.get() ->* _mfn)(); - } -}; - -template<class R, class K, class T, class H, class A> -class SecondMemFun1 : public std::binary_function<std::pair<K, H>, A, R> -{ - typedef R (T::*MemberFN)(A); - MemberFN _mfn; - -public: - - explicit SecondMemFun1(MemberFN p) : _mfn(p) { } - R operator()(std::pair<K, H> pair, A arg) const - { - return (pair.second.get() ->* _mfn)(arg); - } -}; - -template<class K, class T, class H> -class SecondVoidMemFun : public std::unary_function<std::pair<K, H>, void> -{ - typedef void (T::*MemberFN)(void); - MemberFN _mfn; - -public: - - explicit SecondVoidMemFun(MemberFN p) : _mfn(p) { } - void operator()(std::pair<K, H> pair) const - { - (pair.second.get() ->* _mfn)(); - } -}; - -template<class K, class T, class H, class A> -class SecondVoidMemFun1 : public std::binary_function<std::pair<K, H>, A, void> -{ - typedef void (T::*MemberFN)(A); - MemberFN _mfn; - -public: - - explicit SecondVoidMemFun1(MemberFN p) : _mfn(p) { } - void operator()(std::pair<K, H> pair, A arg) const - { - (pair.second.get() ->* _mfn)(arg); - } -}; - -template<class R, class T, class H> -class ConstMemFun : public std::unary_function<H, R> -{ - typedef R (T::*MemberFN)(void) const; - MemberFN _mfn; - -public: - - explicit ConstMemFun(MemberFN p) : _mfn(p) { } - R operator()(H handle) const - { - return (handle.get() ->* _mfn)(); - } -}; - -template<class R, class T, class H, class A> -class ConstMemFun1 : public std::binary_function<H, A, R> -{ - typedef R (T::*MemberFN)(A) const; - MemberFN _mfn; - -public: - - explicit ConstMemFun1(MemberFN p) : _mfn(p) { } - R operator()(H handle, A arg) const - { - return (handle.get() ->* _mfn)(arg); - } -}; - -template<class T, class H> -class ConstVoidMemFun : public std::unary_function<H, void> -{ - typedef void (T::*MemberFN)(void) const; - MemberFN _mfn; - -public: - - explicit ConstVoidMemFun(MemberFN p) : _mfn(p) { } - void operator()(H handle) const - { - (handle.get() ->* _mfn)(); - } -}; - -template<class T, class H, class A> -class ConstVoidMemFun1 : public std::binary_function<H, A, void> -{ - typedef void (T::*MemberFN)(A) const; - MemberFN _mfn; - -public: - - explicit ConstVoidMemFun1(MemberFN p) : _mfn(p) { } - void operator()(H handle, A arg) const - { - (handle.get() ->* _mfn)(arg); - } -}; - -template<class R, class K, class T, class H> -class SecondConstMemFun : public std::unary_function<std::pair<K, H>, R> -{ - typedef R (T::*MemberFN)(void) const; - MemberFN _mfn; - -public: - - explicit SecondConstMemFun(MemberFN p) : _mfn(p) { } - R operator()(std::pair<K, H> pair) const - { - return (pair.second.get() ->* _mfn)(); - } -}; - -template<class R, class K, class T, class H, class A> -class SecondConstMemFun1 : public std::binary_function<std::pair<K, H>, A, R> -{ - typedef R (T::*MemberFN)(A) const; - MemberFN _mfn; - -public: - - explicit SecondConstMemFun1(MemberFN p) : _mfn(p) { } - R operator()(std::pair<K, H> pair, A arg) const - { - return (pair.second.get() ->* _mfn)(arg); - } -}; - -template<class K, class T, class H> -class SecondConstVoidMemFun : public std::unary_function<std::pair<K, H>, void> -{ - typedef void (T::*MemberFN)(void) const; - MemberFN _mfn; - -public: - - explicit SecondConstVoidMemFun(MemberFN p) : _mfn(p) { } - void operator()(std::pair<K, H> pair) const - { - (pair.second.get() ->* _mfn)(); - } -}; - -template<class K, class T, class H, class A> -class SecondConstVoidMemFun1 : public std::binary_function<std::pair<K, H>, A, void> -{ - typedef void (T::*MemberFN)(A) const; - MemberFN _mfn; - -public: - - explicit SecondConstVoidMemFun1(MemberFN p) : _mfn(p) { } - void operator()(std::pair<K, H> pair, A arg) const - { - (pair.second.get() ->* _mfn)(arg); - } -}; - -} - -// ---------------------------------------------------------------------- -// Inline functions that return function objects that work with -// IceUtil::Handle -// ---------------------------------------------------------------------- - -namespace IceUtil -{ - -template<class R, class T> -inline ::IceUtilInternal::MemFun<R, T, Handle<T> > -memFun(R (T::*p)(void)) -{ - return ::IceUtilInternal::MemFun<R, T, Handle<T> >(p); -} - -template<class R, class T, class A> -inline ::IceUtilInternal::MemFun1<R, T, Handle<T>, A> -memFun1(R (T::*p)(A)) -{ - return ::IceUtilInternal::MemFun1<R, T, Handle<T>, A>(p); -} - -template<class T> -inline ::IceUtilInternal::VoidMemFun<T, Handle<T> > -voidMemFun(void (T::*p)(void)) -{ - return ::IceUtilInternal::VoidMemFun<T, Handle<T> >(p); -} - -template<class T, class A> -inline ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A> -voidMemFun1(void (T::*p)(A)) -{ - return ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A>(p); -} - -template<class R, class K, class T> -inline ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> > -secondMemFun(R (T::*p)(void)) -{ - return ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> >(p); -} - -template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A> -secondMemFun1(R (T::*p)(A)) -{ - return ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A>(p); -} - -template<class K, class T> -inline ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> > -secondVoidMemFun(void (T::*p)(void)) -{ - return ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> >(p); -} - -template<class K, class T, class A> -inline ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A> -secondVoidMemFun1(void (T::*p)(A)) -{ - return ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A>(p); -} - -template<class R, class T> -inline ::IceUtilInternal::ConstMemFun<R, T, Handle<T> > -constMemFun(R (T::*p)(void) const) -{ - return ::IceUtilInternal::ConstMemFun<R, T, Handle<T> >(p); -} - -template<class R, class T, class A> -inline ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A> -constMemFun1(R (T::*p)(A) const) -{ - return ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A>(p); -} - -template<class T> -inline ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> > -constVoidMemFun(void (T::*p)(void) const) -{ - return ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> >(p); -} - -template<class T, class A> -inline ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A> -constVoidMemFun1(void (T::*p)(A) const) -{ - return ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A>(p); -} - -template<class R, class K, class T> -inline ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> > -secondConstMemFun(R (T::*p)(void) const) -{ - return ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> >(p); -} - -template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A> -secondConstMemFun1(R (T::*p)(A) const) -{ - return ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>(p); -} - -template<class K, class T> -inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> > -secondConstVoidMemFun(void (T::*p)(void) const) -{ - return ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> >(p); -} - -template<class K, class T, class A> -inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A> -secondConstVoidMemFun1(void (T::*p)(A) const) -{ - return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>(p); -} - -} - -// ---------------------------------------------------------------------- -// Extension for STLport: Special versions for bind1st and bind2nd for -// operations that do not return anything (i.e., return void). Needed -// for broken compilers, such as Visual C++ -// ---------------------------------------------------------------------- - -#ifdef _STLP_BEGIN_NAMESPACE - -_STLP_BEGIN_NAMESPACE - -template <class _Operation> -class voidbinder1st : - public unary_function<typename __BINARY_ARG(_Operation,second_argument_type), - typename __BINARY_ARG(_Operation,result_type) > { -protected: - _Operation _M_op; - typename _Operation::first_argument_type _M_value; -public: - voidbinder1st(const _Operation& __x, - const typename _Operation::first_argument_type& __y) - : _M_op(__x), _M_value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::second_argument_type& __x) const { - _M_op(_M_value, __x); - } -}; - -template <class _Operation, class _Tp> -inline voidbinder1st<_Operation> -voidbind1st(const _Operation& __fn, const _Tp& __x) -{ - typedef typename _Operation::first_argument_type _Arg1_type; - return voidbinder1st<_Operation>(__fn, _Arg1_type(__x)); -} - -template <class _Operation> -class voidbinder2nd - : public unary_function<typename __BINARY_ARG(_Operation,first_argument_type), - typename __BINARY_ARG(_Operation,result_type)> { -protected: - _Operation _M_op; - typename _Operation::second_argument_type value; -public: - voidbinder2nd(const _Operation& __x, - const typename _Operation::second_argument_type& __y) - : _M_op(__x), value(__y) {} - typename _Operation::result_type - operator()(const typename _Operation::first_argument_type& __x) const { - _M_op(__x, value); - } -}; - -template <class _Operation, class _Tp> -inline voidbinder2nd<_Operation> -voidbind2nd(const _Operation& __fn, const _Tp& __x) -{ - typedef typename _Operation::second_argument_type _Arg2_type; - return voidbinder2nd<_Operation>(__fn, _Arg2_type(__x)); -} - -_STLP_END_NAMESPACE - -#endif - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_FUNCTIONAL_H
+#define ICE_UTIL_FUNCTIONAL_H
+
+#include <IceUtil/Handle.h>
+#include <functional>
+
+namespace IceUtilInternal
+{
+
+// ----------------------------------------------------------------------
+// Various function objects that work with handles instead of plain
+// pointers.
+// ----------------------------------------------------------------------
+
+template<class R, class T, class H>
+class MemFun : public std::unary_function<H, R>
+{
+ typedef R (T::*MemberFN)(void);
+ MemberFN _mfn;
+
+public:
+
+ explicit MemFun(MemberFN p) : _mfn(p) { }
+ R operator()(H handle) const
+ {
+ return (handle.get() ->* _mfn)();
+ }
+};
+
+template<class R, class T, class H, class A>
+class MemFun1 : public std::binary_function<H, A, R>
+{
+ typedef R (T::*MemberFN)(A);
+ MemberFN _mfn;
+
+public:
+
+ explicit MemFun1(MemberFN p) : _mfn(p) { }
+ R operator()(H handle, A arg) const
+ {
+ return (handle.get() ->* _mfn)(arg);
+ }
+};
+
+template<class T, class H>
+class VoidMemFun : public std::unary_function<H, void>
+{
+ typedef void (T::*MemberFN)(void);
+ MemberFN _mfn;
+
+public:
+
+ explicit VoidMemFun(MemberFN p) : _mfn(p) { }
+ void operator()(H handle) const
+ {
+ (handle.get() ->* _mfn)();
+ }
+};
+
+template<class T, class H, class A>
+class VoidMemFun1 : public std::binary_function<H, A, void>
+{
+ typedef void (T::*MemberFN)(A);
+ MemberFN _mfn;
+
+public:
+
+ explicit VoidMemFun1(MemberFN p) : _mfn(p) { }
+ void operator()(H handle, A arg) const
+ {
+ (handle.get() ->* _mfn)(arg);
+ }
+};
+
+template<class R, class K, class T, class H>
+class SecondMemFun : public std::unary_function<std::pair<K, H>, R>
+{
+ typedef R (T::*MemberFN)(void);
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondMemFun(MemberFN p) : _mfn(p) { }
+ R operator()(std::pair<K, H> pair) const
+ {
+ return (pair.second.get() ->* _mfn)();
+ }
+};
+
+template<class R, class K, class T, class H, class A>
+class SecondMemFun1 : public std::binary_function<std::pair<K, H>, A, R>
+{
+ typedef R (T::*MemberFN)(A);
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondMemFun1(MemberFN p) : _mfn(p) { }
+ R operator()(std::pair<K, H> pair, A arg) const
+ {
+ return (pair.second.get() ->* _mfn)(arg);
+ }
+};
+
+template<class K, class T, class H>
+class SecondVoidMemFun : public std::unary_function<std::pair<K, H>, void>
+{
+ typedef void (T::*MemberFN)(void);
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondVoidMemFun(MemberFN p) : _mfn(p) { }
+ void operator()(std::pair<K, H> pair) const
+ {
+ (pair.second.get() ->* _mfn)();
+ }
+};
+
+template<class K, class T, class H, class A>
+class SecondVoidMemFun1 : public std::binary_function<std::pair<K, H>, A, void>
+{
+ typedef void (T::*MemberFN)(A);
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondVoidMemFun1(MemberFN p) : _mfn(p) { }
+ void operator()(std::pair<K, H> pair, A arg) const
+ {
+ (pair.second.get() ->* _mfn)(arg);
+ }
+};
+
+template<class R, class T, class H>
+class ConstMemFun : public std::unary_function<H, R>
+{
+ typedef R (T::*MemberFN)(void) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit ConstMemFun(MemberFN p) : _mfn(p) { }
+ R operator()(H handle) const
+ {
+ return (handle.get() ->* _mfn)();
+ }
+};
+
+template<class R, class T, class H, class A>
+class ConstMemFun1 : public std::binary_function<H, A, R>
+{
+ typedef R (T::*MemberFN)(A) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit ConstMemFun1(MemberFN p) : _mfn(p) { }
+ R operator()(H handle, A arg) const
+ {
+ return (handle.get() ->* _mfn)(arg);
+ }
+};
+
+template<class T, class H>
+class ConstVoidMemFun : public std::unary_function<H, void>
+{
+ typedef void (T::*MemberFN)(void) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit ConstVoidMemFun(MemberFN p) : _mfn(p) { }
+ void operator()(H handle) const
+ {
+ (handle.get() ->* _mfn)();
+ }
+};
+
+template<class T, class H, class A>
+class ConstVoidMemFun1 : public std::binary_function<H, A, void>
+{
+ typedef void (T::*MemberFN)(A) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit ConstVoidMemFun1(MemberFN p) : _mfn(p) { }
+ void operator()(H handle, A arg) const
+ {
+ (handle.get() ->* _mfn)(arg);
+ }
+};
+
+template<class R, class K, class T, class H>
+class SecondConstMemFun : public std::unary_function<std::pair<K, H>, R>
+{
+ typedef R (T::*MemberFN)(void) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondConstMemFun(MemberFN p) : _mfn(p) { }
+ R operator()(std::pair<K, H> pair) const
+ {
+ return (pair.second.get() ->* _mfn)();
+ }
+};
+
+template<class R, class K, class T, class H, class A>
+class SecondConstMemFun1 : public std::binary_function<std::pair<K, H>, A, R>
+{
+ typedef R (T::*MemberFN)(A) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondConstMemFun1(MemberFN p) : _mfn(p) { }
+ R operator()(std::pair<K, H> pair, A arg) const
+ {
+ return (pair.second.get() ->* _mfn)(arg);
+ }
+};
+
+template<class K, class T, class H>
+class SecondConstVoidMemFun : public std::unary_function<std::pair<K, H>, void>
+{
+ typedef void (T::*MemberFN)(void) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondConstVoidMemFun(MemberFN p) : _mfn(p) { }
+ void operator()(std::pair<K, H> pair) const
+ {
+ (pair.second.get() ->* _mfn)();
+ }
+};
+
+template<class K, class T, class H, class A>
+class SecondConstVoidMemFun1 : public std::binary_function<std::pair<K, H>, A, void>
+{
+ typedef void (T::*MemberFN)(A) const;
+ MemberFN _mfn;
+
+public:
+
+ explicit SecondConstVoidMemFun1(MemberFN p) : _mfn(p) { }
+ void operator()(std::pair<K, H> pair, A arg) const
+ {
+ (pair.second.get() ->* _mfn)(arg);
+ }
+};
+
+}
+
+// ----------------------------------------------------------------------
+// Inline functions that return function objects that work with
+// IceUtil::Handle
+// ----------------------------------------------------------------------
+
+namespace IceUtil
+{
+
+template<class R, class T>
+inline ::IceUtilInternal::MemFun<R, T, Handle<T> >
+memFun(R (T::*p)(void))
+{
+ return ::IceUtilInternal::MemFun<R, T, Handle<T> >(p);
+}
+
+template<class R, class T, class A>
+inline ::IceUtilInternal::MemFun1<R, T, Handle<T>, A>
+memFun1(R (T::*p)(A))
+{
+ return ::IceUtilInternal::MemFun1<R, T, Handle<T>, A>(p);
+}
+
+template<class T>
+inline ::IceUtilInternal::VoidMemFun<T, Handle<T> >
+voidMemFun(void (T::*p)(void))
+{
+ return ::IceUtilInternal::VoidMemFun<T, Handle<T> >(p);
+}
+
+template<class T, class A>
+inline ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A>
+voidMemFun1(void (T::*p)(A))
+{
+ return ::IceUtilInternal::VoidMemFun1<T, Handle<T>, A>(p);
+}
+
+template<class R, class K, class T>
+inline ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> >
+secondMemFun(R (T::*p)(void))
+{
+ return ::IceUtilInternal::SecondMemFun<R, K, T, Handle<T> >(p);
+}
+
+template<class R, class K, class T, class A>
+inline ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A>
+secondMemFun1(R (T::*p)(A))
+{
+ return ::IceUtilInternal::SecondMemFun1<R, K, T, Handle<T>, A>(p);
+}
+
+template<class K, class T>
+inline ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> >
+secondVoidMemFun(void (T::*p)(void))
+{
+ return ::IceUtilInternal::SecondVoidMemFun<K, T, Handle<T> >(p);
+}
+
+template<class K, class T, class A>
+inline ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A>
+secondVoidMemFun1(void (T::*p)(A))
+{
+ return ::IceUtilInternal::SecondVoidMemFun1<K, T, Handle<T>, A>(p);
+}
+
+template<class R, class T>
+inline ::IceUtilInternal::ConstMemFun<R, T, Handle<T> >
+constMemFun(R (T::*p)(void) const)
+{
+ return ::IceUtilInternal::ConstMemFun<R, T, Handle<T> >(p);
+}
+
+template<class R, class T, class A>
+inline ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A>
+constMemFun1(R (T::*p)(A) const)
+{
+ return ::IceUtilInternal::ConstMemFun1<R, T, Handle<T>, A>(p);
+}
+
+template<class T>
+inline ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> >
+constVoidMemFun(void (T::*p)(void) const)
+{
+ return ::IceUtilInternal::ConstVoidMemFun<T, Handle<T> >(p);
+}
+
+template<class T, class A>
+inline ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A>
+constVoidMemFun1(void (T::*p)(A) const)
+{
+ return ::IceUtilInternal::ConstVoidMemFun1<T, Handle<T>, A>(p);
+}
+
+template<class R, class K, class T>
+inline ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> >
+secondConstMemFun(R (T::*p)(void) const)
+{
+ return ::IceUtilInternal::SecondConstMemFun<R, K, T, Handle<T> >(p);
+}
+
+template<class R, class K, class T, class A>
+inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>
+secondConstMemFun1(R (T::*p)(A) const)
+{
+ return ::IceUtilInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>(p);
+}
+
+template<class K, class T>
+inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> >
+secondConstVoidMemFun(void (T::*p)(void) const)
+{
+ return ::IceUtilInternal::SecondConstVoidMemFun<K, T, Handle<T> >(p);
+}
+
+template<class K, class T, class A>
+inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>
+secondConstVoidMemFun1(void (T::*p)(A) const)
+{
+ return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>(p);
+}
+
+}
+
+// ----------------------------------------------------------------------
+// Extension for STLport: Special versions for bind1st and bind2nd for
+// operations that do not return anything (i.e., return void). Needed
+// for broken compilers, such as Visual C++
+// ----------------------------------------------------------------------
+
+#ifdef _STLP_BEGIN_NAMESPACE
+
+_STLP_BEGIN_NAMESPACE
+
+template <class _Operation>
+class voidbinder1st :
+ public unary_function<typename __BINARY_ARG(_Operation,second_argument_type),
+ typename __BINARY_ARG(_Operation,result_type) > {
+protected:
+ _Operation _M_op;
+ typename _Operation::first_argument_type _M_value;
+public:
+ voidbinder1st(const _Operation& __x,
+ const typename _Operation::first_argument_type& __y)
+ : _M_op(__x), _M_value(__y) {}
+ typename _Operation::result_type
+ operator()(const typename _Operation::second_argument_type& __x) const {
+ _M_op(_M_value, __x);
+ }
+};
+
+template <class _Operation, class _Tp>
+inline voidbinder1st<_Operation>
+voidbind1st(const _Operation& __fn, const _Tp& __x)
+{
+ typedef typename _Operation::first_argument_type _Arg1_type;
+ return voidbinder1st<_Operation>(__fn, _Arg1_type(__x));
+}
+
+template <class _Operation>
+class voidbinder2nd
+ : public unary_function<typename __BINARY_ARG(_Operation,first_argument_type),
+ typename __BINARY_ARG(_Operation,result_type)> {
+protected:
+ _Operation _M_op;
+ typename _Operation::second_argument_type value;
+public:
+ voidbinder2nd(const _Operation& __x,
+ const typename _Operation::second_argument_type& __y)
+ : _M_op(__x), value(__y) {}
+ typename _Operation::result_type
+ operator()(const typename _Operation::first_argument_type& __x) const {
+ _M_op(__x, value);
+ }
+};
+
+template <class _Operation, class _Tp>
+inline voidbinder2nd<_Operation>
+voidbind2nd(const _Operation& __fn, const _Tp& __x)
+{
+ typedef typename _Operation::second_argument_type _Arg2_type;
+ return voidbinder2nd<_Operation>(__fn, _Arg2_type(__x));
+}
+
+_STLP_END_NAMESPACE
+
+#endif
+
+#endif
diff --git a/cpp/include/IceUtil/Handle.h b/cpp/include/IceUtil/Handle.h index 9fb85388e4f..b319c86a7e2 100644 --- a/cpp/include/IceUtil/Handle.h +++ b/cpp/include/IceUtil/Handle.h @@ -1,231 +1,231 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_HANDLE_H -#define ICE_UTIL_HANDLE_H - -#include <IceUtil/Exception.h> -#include <algorithm> - -// -// "Handle" or "smart pointer" class for classes derived from -// IceUtil::Shared or IceUtil::SimpleShared. -// -namespace IceUtil -{ - -template<typename T> -class HandleBase -{ -public: - - typedef T element_type; - - T* get() const - { - return _ptr; - } - - T* operator->() const - { - if (!_ptr) - { - throw NullHandleException(__FILE__, __LINE__); - } - - return _ptr; - } - - operator bool() const - { - return _ptr ? true : false; - } - - void swap(HandleBase& other) - { - std::swap(_ptr, other._ptr); - } - - T* _ptr; -}; - -template<typename T, typename U> -inline bool operator==(const HandleBase<T>& lhs, const HandleBase<U>& rhs) -{ - T* l = lhs.get(); - U* r = rhs.get(); - if (l && r) - { - return *l == *r; - } - else - { - return !l && !r; - } -} - -template<typename T, typename U> -inline bool operator!=(const HandleBase<T>& lhs, const HandleBase<U>& rhs) -{ - T* l = lhs.get(); - U* r = rhs.get(); - if (l && r) - { - return *l != *r; - } - else - { - return l || r; - } -} - -template<typename T, typename U> -inline bool operator<(const HandleBase<T>& lhs, const HandleBase<U>& rhs) -{ - T* l = lhs.get(); - U* r = rhs.get(); - if (l && r) - { - return *l < *r; - } - else - { - return !l && r; - } -} - -template<typename T> -class Handle : public HandleBase<T> -{ -public: - - Handle(T* p = 0) - { - _ptr = p; - - if (_ptr) - { - _ptr->__incRef(); - } - } - - template<typename Y> - Handle(const Handle<Y>& r) - { - _ptr = r._ptr; - - if (_ptr) - { - _ptr->__incRef(); - } - } - -#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? - template<> - Handle(const Handle<T>& r) -#else - Handle(const Handle& r) -#endif - { - _ptr = r._ptr; - - if (_ptr) - { - _ptr->__incRef(); - } - } - - ~Handle() - { - if (_ptr) - { - _ptr->__decRef(); - } - } - - Handle& operator=(T* p) - { - if (_ptr != p) - { - if (p) - { - p->__incRef(); - } - - if (_ptr) - { - _ptr->__decRef(); - } - - _ptr = p; - } - return *this; - } - - template<typename Y> - Handle& operator=(const Handle<Y>& r) - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - r._ptr->__incRef(); - } - - if (_ptr) - { - _ptr->__decRef(); - } - - _ptr = r._ptr; - } - return *this; - } - -#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? - template<> - Handle& operator=(const Handle<T>& r) -#else - Handle& operator=(const Handle& r) -#endif - { - if (_ptr != r._ptr) - { - if (r._ptr) - { - r._ptr->__incRef(); - } - - if (_ptr) - { - _ptr->__decRef(); - } - - _ptr = r._ptr; - } - return *this; - } - - template<class Y> - static Handle dynamicCast(const HandleBase<Y>& r) - { - return Handle(dynamic_cast<T*>(r._ptr)); - } - - template<class Y> - static Handle dynamicCast(Y* p) - { - return Handle(dynamic_cast<T*>(p)); - } -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_HANDLE_H
+#define ICE_UTIL_HANDLE_H
+
+#include <IceUtil/Exception.h>
+#include <algorithm>
+
+//
+// "Handle" or "smart pointer" class for classes derived from
+// IceUtil::Shared or IceUtil::SimpleShared.
+//
+namespace IceUtil
+{
+
+template<typename T>
+class HandleBase
+{
+public:
+
+ typedef T element_type;
+
+ T* get() const
+ {
+ return _ptr;
+ }
+
+ T* operator->() const
+ {
+ if(!_ptr)
+ {
+ throw NullHandleException(__FILE__, __LINE__);
+ }
+
+ return _ptr;
+ }
+
+ operator bool() const
+ {
+ return _ptr ? true : false;
+ }
+
+ void swap(HandleBase& other)
+ {
+ std::swap(_ptr, other._ptr);
+ }
+
+ T* _ptr;
+};
+
+template<typename T, typename U>
+inline bool operator==(const HandleBase<T>& lhs, const HandleBase<U>& rhs)
+{
+ T* l = lhs.get();
+ U* r = rhs.get();
+ if(l && r)
+ {
+ return *l == *r;
+ }
+ else
+ {
+ return !l && !r;
+ }
+}
+
+template<typename T, typename U>
+inline bool operator!=(const HandleBase<T>& lhs, const HandleBase<U>& rhs)
+{
+ T* l = lhs.get();
+ U* r = rhs.get();
+ if(l && r)
+ {
+ return *l != *r;
+ }
+ else
+ {
+ return l || r;
+ }
+}
+
+template<typename T, typename U>
+inline bool operator<(const HandleBase<T>& lhs, const HandleBase<U>& rhs)
+{
+ T* l = lhs.get();
+ U* r = rhs.get();
+ if(l && r)
+ {
+ return *l < *r;
+ }
+ else
+ {
+ return !l && r;
+ }
+}
+
+template<typename T>
+class Handle : public HandleBase<T>
+{
+public:
+
+ Handle(T* p = 0)
+ {
+ _ptr = p;
+
+ if(_ptr)
+ {
+ _ptr->__incRef();
+ }
+ }
+
+ template<typename Y>
+ Handle(const Handle<Y>& r)
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ _ptr->__incRef();
+ }
+ }
+
+#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
+ template<>
+ Handle(const Handle<T>& r)
+#else
+ Handle(const Handle& r)
+#endif
+ {
+ _ptr = r._ptr;
+
+ if(_ptr)
+ {
+ _ptr->__incRef();
+ }
+ }
+
+ ~Handle()
+ {
+ if(_ptr)
+ {
+ _ptr->__decRef();
+ }
+ }
+
+ Handle& operator=(T* p)
+ {
+ if(_ptr != p)
+ {
+ if(p)
+ {
+ p->__incRef();
+ }
+
+ if(_ptr)
+ {
+ _ptr->__decRef();
+ }
+
+ _ptr = p;
+ }
+ return *this;
+ }
+
+ template<typename Y>
+ Handle& operator=(const Handle<Y>& r)
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ r._ptr->__incRef();
+ }
+
+ if(_ptr)
+ {
+ _ptr->__decRef();
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+#ifdef _WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here???
+ template<>
+ Handle& operator=(const Handle<T>& r)
+#else
+ Handle& operator=(const Handle& r)
+#endif
+ {
+ if(_ptr != r._ptr)
+ {
+ if(r._ptr)
+ {
+ r._ptr->__incRef();
+ }
+
+ if(_ptr)
+ {
+ _ptr->__decRef();
+ }
+
+ _ptr = r._ptr;
+ }
+ return *this;
+ }
+
+ template<class Y>
+ static Handle dynamicCast(const HandleBase<Y>& r)
+ {
+ return Handle(dynamic_cast<T*>(r._ptr));
+ }
+
+ template<class Y>
+ static Handle dynamicCast(Y* p)
+ {
+ return Handle(dynamic_cast<T*>(p));
+ }
+};
+
+}
+
+#endif
diff --git a/cpp/include/IceUtil/IceUtil.h b/cpp/include/IceUtil/IceUtil.h index e06213d0810..9f671469bd2 100644 --- a/cpp/include/IceUtil/IceUtil.h +++ b/cpp/include/IceUtil/IceUtil.h @@ -1,30 +1,30 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_ICE_UTIL_H -#define ICE_UTIL_ICE_UTIL_H - -// -// This file must include *all* other headers of IceUtil. -// - -#include <IceUtil/Functional.h> -#include <IceUtil/Shared.h> -#include <IceUtil/Unicode.h> -#include <IceUtil/UUID.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/RecMutex.h> -#include <IceUtil/RWRecMutex.h> -#include <IceUtil/Monitor.h> -#include <IceUtil/Thread.h> -#include <IceUtil/Base64.h> -#include <IceUtil/Time.h> - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_ICE_UTIL_H
+#define ICE_UTIL_ICE_UTIL_H
+
+//
+// This file must include *all* other headers of IceUtil.
+//
+
+#include <IceUtil/Functional.h>
+#include <IceUtil/Shared.h>
+#include <IceUtil/Unicode.h>
+#include <IceUtil/UUID.h>
+#include <IceUtil/Mutex.h>
+#include <IceUtil/RecMutex.h>
+#include <IceUtil/RWRecMutex.h>
+#include <IceUtil/Monitor.h>
+#include <IceUtil/Thread.h>
+#include <IceUtil/Base64.h>
+#include <IceUtil/Time.h>
+
+#endif
diff --git a/cpp/include/IceUtil/Lock.h b/cpp/include/IceUtil/Lock.h index d5b9d2ca14b..610091a12a1 100644 --- a/cpp/include/IceUtil/Lock.h +++ b/cpp/include/IceUtil/Lock.h @@ -1,72 +1,72 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_LOCK_H -#define ICE_UTIL_LOCK_H - -#include <IceUtil/Config.h> - -namespace IceUtil -{ - -// -// Forward declarations. -// -class Cond; - -template <typename T> -class Lock -{ -public: - - Lock(const T& mutex) : - _mutex(mutex) - { - _mutex.lock(); - } - - ~Lock() - { - _mutex.unlock(); - } - -private: - - const T& _mutex; - - friend class Cond; -}; - -template <typename T> -class TryLock -{ -public: - - TryLock(const T& mutex) : - _mutex(mutex) - { - _mutex.trylock(); - } - - ~TryLock() - { - _mutex.unlock(); - } - -private: - - const T& _mutex; - - friend class Cond; -}; - -} // End namespace IceUtil - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_LOCK_H
+#define ICE_UTIL_LOCK_H
+
+#include <IceUtil/Config.h>
+
+namespace IceUtil
+{
+
+//
+// Forward declarations.
+//
+class Cond;
+
+template <typename T>
+class Lock
+{
+public:
+
+ Lock(const T& mutex) :
+ _mutex(mutex)
+ {
+ _mutex.lock();
+ }
+
+ ~Lock()
+ {
+ _mutex.unlock();
+ }
+
+private:
+
+ const T& _mutex;
+
+ friend class Cond;
+};
+
+template <typename T>
+class TryLock
+{
+public:
+
+ TryLock(const T& mutex) :
+ _mutex(mutex)
+ {
+ _mutex.trylock();
+ }
+
+ ~TryLock()
+ {
+ _mutex.unlock();
+ }
+
+private:
+
+ const T& _mutex;
+
+ friend class Cond;
+};
+
+} // End namespace IceUtil
+
+#endif
diff --git a/cpp/include/IceUtil/Monitor.h b/cpp/include/IceUtil/Monitor.h index ec4e1eb3498..aba1a29fd6e 100644 --- a/cpp/include/IceUtil/Monitor.h +++ b/cpp/include/IceUtil/Monitor.h @@ -1,235 +1,235 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_MONITOR_H -#define ICE_UTIL_MONITOR_H - -#include <IceUtil/Config.h> -#include <IceUtil/Lock.h> -#include <IceUtil/Cond.h> - -namespace IceUtil -{ - -// -// This monitor implements the Mesa monitor semantics. That is any -// calls to notify() or notifyAll() are delayed until the monitor is -// unlocked. -// -template <class T> -class ICE_UTIL_API Monitor -{ -public: - - typedef Lock<Monitor<T> > Lock; - typedef TryLock<Monitor<T> > TryLock; - - Monitor(); - ~Monitor(); - - // - // Note that lock/trylock & unlock in general should not be used - // directly. Instead use Lock & TryLock. - // - void lock() const; - void unlock() const; - void trylock() const; - - void wait() const; - bool timedWait(const Time&) const; - void notify(); - void notifyAll(); - -private: - - // noncopyable - Monitor(const Monitor&); - void operator=(const Monitor&); - - void notifyImpl(int) const; - - mutable Cond _cond; - T _mutex; - mutable int _nnotify; -}; - -} // End namespace IceUtil - -// -// Since this monitor implements the Mesa monitor semantics calls to -// notify() or notifyAll() are delayed until the monitor is -// unlocked. This can happen either due to a call to unlock(), or a -// call to wait(). The _nnotify flag keeps track of the number of -// pending notification calls. -1 indicates a broadcast, a positive -// number indicates <n> calls to notify(). The _nnotify flag is reset -// upon initial acquisition of the monitor lock (either through a call -// to lock(), or a return from wait(). -// - -template <class T> inline -IceUtil::Monitor<T>::Monitor() : - _nnotify(0) -{ -} - -template <class T> inline -IceUtil::Monitor<T>::~Monitor() -{ -} - -template <class T> inline void -IceUtil::Monitor<T>::lock() const -{ - if (_mutex.lock()) - { - // - // On the first mutex acquisition reset the number pending - // notifications. - // - _nnotify = 0; - } -} - -template <class T> inline void -IceUtil::Monitor<T>::unlock() const -{ - int nnotify = _nnotify; - if (_mutex.unlock()) - { - // - // Perform any pending notifications. - // - notifyImpl(nnotify); - } -} - -template <class T> inline void -IceUtil::Monitor<T>::trylock() const -{ - if (_mutex.trylock()) - { - // - // On the first mutex acquisition reset the number pending - // notifications. - // - _nnotify = 0; - } -} - -template <class T> inline void -IceUtil::Monitor<T>::wait() const -{ - // - // Perform any pending notifies - // - notifyImpl(_nnotify); - - // - // Wait for a notification - // - try - { - _cond.waitImpl(_mutex); - // - // Reset the nnotify count once wait() returns. - // - } - catch(...) - { - _nnotify = 0; - throw; - } - _nnotify = 0; -} - -template <class T> inline bool -IceUtil::Monitor<T>::timedWait(const Time& timeout) const -{ - // - // Perform any pending notifies. - // - notifyImpl(_nnotify); - - bool rc; - // - // Wait for a notification. - // - try - { - rc = _cond.timedWaitImpl(_mutex, timeout); - - // - // Reset the nnotify count once wait() returns. - // - } - catch(...) - { - _nnotify = 0; - throw; - } - - _nnotify = 0; - return rc; -} - -template <class T> inline void -IceUtil::Monitor<T>::notify() -{ - // - // Increment the _nnotify flag, unless a broadcast has already - // been requested. - // - if (_nnotify != -1) - { - ++_nnotify; - } -} - -template <class T> inline void -IceUtil::Monitor<T>::notifyAll() -{ - // - // -1 (indicates broadcast) - // - _nnotify = -1; -} - - -template <class T> inline void -IceUtil::Monitor<T>::notifyImpl(int nnotify) const -{ - // - // Zero indicates no notifies. - // - if (nnotify != 0) - { - // - // -1 means notifyAll. - // - if (nnotify == -1) - { - _cond.broadcast(); - return; - } - else - { - // - // Otherwise notify n times. - // - while (nnotify > 0) - { - _cond.signal(); - --nnotify; - } - } - } -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_MONITOR_H
+#define ICE_UTIL_MONITOR_H
+
+#include <IceUtil/Config.h>
+#include <IceUtil/Lock.h>
+#include <IceUtil/Cond.h>
+
+namespace IceUtil
+{
+
+//
+// This monitor implements the Mesa monitor semantics. That is any
+// calls to notify() or notifyAll() are delayed until the monitor is
+// unlocked.
+//
+template <class T>
+class ICE_UTIL_API Monitor
+{
+public:
+
+ typedef Lock<Monitor<T> > Lock;
+ typedef TryLock<Monitor<T> > TryLock;
+
+ Monitor();
+ ~Monitor();
+
+ //
+ // Note that lock/trylock & unlock in general should not be used
+ // directly. Instead use Lock & TryLock.
+ //
+ void lock() const;
+ void unlock() const;
+ void trylock() const;
+
+ void wait() const;
+ bool timedWait(const Time&) const;
+ void notify();
+ void notifyAll();
+
+private:
+
+ // noncopyable
+ Monitor(const Monitor&);
+ void operator=(const Monitor&);
+
+ void notifyImpl(int) const;
+
+ mutable Cond _cond;
+ T _mutex;
+ mutable int _nnotify;
+};
+
+} // End namespace IceUtil
+
+//
+// Since this monitor implements the Mesa monitor semantics calls to
+// notify() or notifyAll() are delayed until the monitor is
+// unlocked. This can happen either due to a call to unlock(), or a
+// call to wait(). The _nnotify flag keeps track of the number of
+// pending notification calls. -1 indicates a broadcast, a positive
+// number indicates <n> calls to notify(). The _nnotify flag is reset
+// upon initial acquisition of the monitor lock (either through a call
+// to lock(), or a return from wait().
+//
+
+template <class T> inline
+IceUtil::Monitor<T>::Monitor() :
+ _nnotify(0)
+{
+}
+
+template <class T> inline
+IceUtil::Monitor<T>::~Monitor()
+{
+}
+
+template <class T> inline void
+IceUtil::Monitor<T>::lock() const
+{
+ if(_mutex.lock())
+ {
+ //
+ // On the first mutex acquisition reset the number pending
+ // notifications.
+ //
+ _nnotify = 0;
+ }
+}
+
+template <class T> inline void
+IceUtil::Monitor<T>::unlock() const
+{
+ int nnotify = _nnotify;
+ if(_mutex.unlock())
+ {
+ //
+ // Perform any pending notifications.
+ //
+ notifyImpl(nnotify);
+ }
+}
+
+template <class T> inline void
+IceUtil::Monitor<T>::trylock() const
+{
+ if(_mutex.trylock())
+ {
+ //
+ // On the first mutex acquisition reset the number pending
+ // notifications.
+ //
+ _nnotify = 0;
+ }
+}
+
+template <class T> inline void
+IceUtil::Monitor<T>::wait() const
+{
+ //
+ // Perform any pending notifies
+ //
+ notifyImpl(_nnotify);
+
+ //
+ // Wait for a notification
+ //
+ try
+ {
+ _cond.waitImpl(_mutex);
+ //
+ // Reset the nnotify count once wait() returns.
+ //
+ }
+ catch(...)
+ {
+ _nnotify = 0;
+ throw;
+ }
+ _nnotify = 0;
+}
+
+template <class T> inline bool
+IceUtil::Monitor<T>::timedWait(const Time& timeout) const
+{
+ //
+ // Perform any pending notifies.
+ //
+ notifyImpl(_nnotify);
+
+ bool rc;
+ //
+ // Wait for a notification.
+ //
+ try
+ {
+ rc = _cond.timedWaitImpl(_mutex, timeout);
+
+ //
+ // Reset the nnotify count once wait() returns.
+ //
+ }
+ catch(...)
+ {
+ _nnotify = 0;
+ throw;
+ }
+
+ _nnotify = 0;
+ return rc;
+}
+
+template <class T> inline void
+IceUtil::Monitor<T>::notify()
+{
+ //
+ // Increment the _nnotify flag, unless a broadcast has already
+ // been requested.
+ //
+ if(_nnotify != -1)
+ {
+ ++_nnotify;
+ }
+}
+
+template <class T> inline void
+IceUtil::Monitor<T>::notifyAll()
+{
+ //
+ // -1 (indicates broadcast)
+ //
+ _nnotify = -1;
+}
+
+
+template <class T> inline void
+IceUtil::Monitor<T>::notifyImpl(int nnotify) const
+{
+ //
+ // Zero indicates no notifies.
+ //
+ if(nnotify != 0)
+ {
+ //
+ // -1 means notifyAll.
+ //
+ if(nnotify == -1)
+ {
+ _cond.broadcast();
+ return;
+ }
+ else
+ {
+ //
+ // Otherwise notify n times.
+ //
+ while(nnotify > 0)
+ {
+ _cond.signal();
+ --nnotify;
+ }
+ }
+ }
+}
+
+#endif
diff --git a/cpp/include/IceUtil/Mutex.h b/cpp/include/IceUtil/Mutex.h index 3d49537fe40..d9298bbf774 100644 --- a/cpp/include/IceUtil/Mutex.h +++ b/cpp/include/IceUtil/Mutex.h @@ -1,250 +1,250 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_MUTEX_H -#define ICE_UTIL_MUTEX_H - -#include <IceUtil/Config.h> -#include <IceUtil/Exception.h> // Necessary for inline functions -#include <IceUtil/Lock.h> - -namespace IceUtil -{ - -// -// Forward declaration for friend. -// -class Cond; - -// -// Simple non-recursive Mutex implementation. -// -// Don't use noncopyable otherwise you end up with warnings like this: -// -// In file included from Connection.cpp:20: -// ../../include/Ice/Outgoing.h:88: warning: direct base -// `IceUtil::noncopyable' inaccessible in `IceInternal::Outgoing' due -// to ambiguity -// -class ICE_UTIL_API Mutex -{ -public: - - // - // Lock & TryLock typedefs. - // - typedef Lock<Mutex> Lock; - typedef TryLock<Mutex> TryLock; - - Mutex(); - ~Mutex(); - - // - // Note that lock/trylock & unlock in general should not be used - // directly. Instead use Lock & TryLock. - // - - // - // The boolean values are for the Monitor implementation which - // needs to know whether the Mutex has been locked for the first - // time, or unlocked for the last time (that is another thread is - // able to acquire the mutex). - // - - // - // Return true if the mutex has been locked for the first time. - // - bool lock() const; - - // - // Throw LockedException in the case that the lock call would - // block (that is the mutex is already owned by some other - // thread). Returns true if the mutex has been locked for the - // first time. - // - bool trylock() const; - - // - // Returns true if the mutex has been unlocked for the last time - // (false otherwise). - // - bool unlock() const; - -private: - - // noncopyable - Mutex(const Mutex&); - void operator=(const Mutex&); - - // - // LockState and the lock/unlock variations are for use by the - // Condition variable implementation. - // -#ifdef _WIN32 - struct LockState - { - }; -#else - struct LockState - { - pthread_mutex_t* mutex; - }; -#endif - - void unlock(LockState&) const; - void lock(LockState&) const; - - friend class Cond; - -#ifdef _WIN32 - mutable CRITICAL_SECTION _mutex; -#else - mutable pthread_mutex_t _mutex; -#endif -}; - -// -// For performance reasons the following functions are inlined. -// - -#ifdef _WIN32 - -inline -Mutex::Mutex() -{ - InitializeCriticalSection(&_mutex); -} - -inline -Mutex::~Mutex() -{ - DeleteCriticalSection(&_mutex); -} - -inline bool -Mutex::lock() const -{ - EnterCriticalSection(&_mutex); - // - // If necessary this can be removed and replaced with a _count - // member (like the UNIX implementation of RecMutex). - // - assert(_mutex.RecursionCount == 1); - return true; -} - -inline bool -Mutex::trylock() const -{ - if (!TryEnterCriticalSection(&_mutex)) - { - throw LockedException(__FILE__, __LINE__); - } - if(_mutex.RecursionCount > 1) - { - LeaveCriticalSection(&_mutex); - throw LockedException(__FILE__, __LINE__); - } - return true; -} - -inline bool -Mutex::unlock() const -{ - assert(_mutex.RecursionCount == 1); - LeaveCriticalSection(&_mutex); - return true; -} - -inline void -Mutex::unlock(LockState& state) const -{ - LeaveCriticalSection(&_mutex); -} - -inline void -Mutex::lock(LockState&) const -{ - EnterCriticalSection(&_mutex); -} - -#else - -inline -Mutex::Mutex() -{ - int rc = pthread_mutex_init(&_mutex, 0); - if (rc != 0) - { - throw SyscallException(strerror(rc), __FILE__, __LINE__); - } -} - -inline -Mutex::~Mutex() -{ - int rc = 0; - rc = pthread_mutex_destroy(&_mutex); - assert(rc == 0); -} - -inline bool -Mutex::lock() const -{ - int rc = pthread_mutex_lock(&_mutex); - if (rc != 0) - { - throw SyscallException(strerror(rc), __FILE__, __LINE__); - } - return true; -} - -inline bool -Mutex::trylock() const -{ - int rc = pthread_mutex_trylock(&_mutex); - if (rc != 0) - { - if (rc == EBUSY) - { - throw LockedException(__FILE__, __LINE__); - } - throw SyscallException(strerror(rc), __FILE__, __LINE__); - } - return true; -} - -inline bool -Mutex::unlock() const -{ - int rc = pthread_mutex_unlock(&_mutex); - if (rc != 0) - { - throw SyscallException(strerror(rc), __FILE__, __LINE__); - } - return true; -} - -inline void -Mutex::unlock(LockState& state) const -{ - state.mutex = &_mutex; -} - -inline void -Mutex::lock(LockState&) const -{ -} - -#endif - -} // End namespace IceUtil - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_MUTEX_H
+#define ICE_UTIL_MUTEX_H
+
+#include <IceUtil/Config.h>
+#include <IceUtil/Exception.h> // Necessary for inline functions
+#include <IceUtil/Lock.h>
+
+namespace IceUtil
+{
+
+//
+// Forward declaration for friend.
+//
+class Cond;
+
+//
+// Simple non-recursive Mutex implementation.
+//
+// Don't use noncopyable otherwise you end up with warnings like this:
+//
+// In file included from Connection.cpp:20:
+// ../../include/Ice/Outgoing.h:88: warning: direct base
+// `IceUtil::noncopyable' inaccessible in `IceInternal::Outgoing' due
+// to ambiguity
+//
+class ICE_UTIL_API Mutex
+{
+public:
+
+ //
+ // Lock & TryLock typedefs.
+ //
+ typedef Lock<Mutex> Lock;
+ typedef TryLock<Mutex> TryLock;
+
+ Mutex();
+ ~Mutex();
+
+ //
+ // Note that lock/trylock & unlock in general should not be used
+ // directly. Instead use Lock & TryLock.
+ //
+
+ //
+ // The boolean values are for the Monitor implementation which
+ // needs to know whether the Mutex has been locked for the first
+ // time, or unlocked for the last time (that is another thread is
+ // able to acquire the mutex).
+ //
+
+ //
+ // Return true if the mutex has been locked for the first time.
+ //
+ bool lock() const;
+
+ //
+ // Throw LockedException in the case that the lock call would
+ // block (that is the mutex is already owned by some other
+ // thread). Returns true if the mutex has been locked for the
+ // first time.
+ //
+ bool trylock() const;
+
+ //
+ // Returns true if the mutex has been unlocked for the last time
+ // (false otherwise).
+ //
+ bool unlock() const;
+
+private:
+
+ // noncopyable
+ Mutex(const Mutex&);
+ void operator=(const Mutex&);
+
+ //
+ // LockState and the lock/unlock variations are for use by the
+ // Condition variable implementation.
+ //
+#ifdef _WIN32
+ struct LockState
+ {
+ };
+#else
+ struct LockState
+ {
+ pthread_mutex_t* mutex;
+ };
+#endif
+
+ void unlock(LockState&) const;
+ void lock(LockState&) const;
+
+ friend class Cond;
+
+#ifdef _WIN32
+ mutable CRITICAL_SECTION _mutex;
+#else
+ mutable pthread_mutex_t _mutex;
+#endif
+};
+
+//
+// For performance reasons the following functions are inlined.
+//
+
+#ifdef _WIN32
+
+inline
+Mutex::Mutex()
+{
+ InitializeCriticalSection(&_mutex);
+}
+
+inline
+Mutex::~Mutex()
+{
+ DeleteCriticalSection(&_mutex);
+}
+
+inline bool
+Mutex::lock() const
+{
+ EnterCriticalSection(&_mutex);
+ //
+ // If necessary this can be removed and replaced with a _count
+ // member (like the UNIX implementation of RecMutex).
+ //
+ assert(_mutex.RecursionCount == 1);
+ return true;
+}
+
+inline bool
+Mutex::trylock() const
+{
+ if(!TryEnterCriticalSection(&_mutex))
+ {
+ throw LockedException(__FILE__, __LINE__);
+ }
+ if(_mutex.RecursionCount > 1)
+ {
+ LeaveCriticalSection(&_mutex);
+ throw LockedException(__FILE__, __LINE__);
+ }
+ return true;
+}
+
+inline bool
+Mutex::unlock() const
+{
+ assert(_mutex.RecursionCount == 1);
+ LeaveCriticalSection(&_mutex);
+ return true;
+}
+
+inline void
+Mutex::unlock(LockState& state) const
+{
+ LeaveCriticalSection(&_mutex);
+}
+
+inline void
+Mutex::lock(LockState&) const
+{
+ EnterCriticalSection(&_mutex);
+}
+
+#else
+
+inline
+Mutex::Mutex()
+{
+ int rc = pthread_mutex_init(&_mutex, 0);
+ if(rc != 0)
+ {
+ throw SyscallException(strerror(rc), __FILE__, __LINE__);
+ }
+}
+
+inline
+Mutex::~Mutex()
+{
+ int rc = 0;
+ rc = pthread_mutex_destroy(&_mutex);
+ assert(rc == 0);
+}
+
+inline bool
+Mutex::lock() const
+{
+ int rc = pthread_mutex_lock(&_mutex);
+ if(rc != 0)
+ {
+ throw SyscallException(strerror(rc), __FILE__, __LINE__);
+ }
+ return true;
+}
+
+inline bool
+Mutex::trylock() const
+{
+ int rc = pthread_mutex_trylock(&_mutex);
+ if(rc != 0)
+ {
+ if(rc == EBUSY)
+ {
+ throw LockedException(__FILE__, __LINE__);
+ }
+ throw SyscallException(strerror(rc), __FILE__, __LINE__);
+ }
+ return true;
+}
+
+inline bool
+Mutex::unlock() const
+{
+ int rc = pthread_mutex_unlock(&_mutex);
+ if(rc != 0)
+ {
+ throw SyscallException(strerror(rc), __FILE__, __LINE__);
+ }
+ return true;
+}
+
+inline void
+Mutex::unlock(LockState& state) const
+{
+ state.mutex = &_mutex;
+}
+
+inline void
+Mutex::lock(LockState&) const
+{
+}
+
+#endif
+
+} // End namespace IceUtil
+
+#endif
diff --git a/cpp/include/IceUtil/OutputUtil.h b/cpp/include/IceUtil/OutputUtil.h index 61ce7916949..f0ad953c21c 100644 --- a/cpp/include/IceUtil/OutputUtil.h +++ b/cpp/include/IceUtil/OutputUtil.h @@ -1,261 +1,261 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_OUTPUT_UTIL_H -#define ICE_UTIL_OUTPUT_UTIL_H - -#include <IceUtil/Config.h> -#include <fstream> -#include <stack> - -namespace IceUtil -{ - -// ---------------------------------------------------------------------- -// OutputBase -// ---------------------------------------------------------------------- - -// -// Technically it's not necessary to have print() & nl() as virtual -// since the opeator<< functions are specific to each OutputBase -// derivative. However, since it's possible to call print() & nl() -// manually I've decided to leave them as virtual. -// - -class ICE_UTIL_API OutputBase : public ::IceUtil::noncopyable -{ -public: - - OutputBase(); - OutputBase(std::ostream&); - OutputBase(const char*); - virtual ~OutputBase(); - - void setIndent(int); // What is the indent level? - void setUseTab(bool); // Should we output tabs? - - void open(const char*); // Open output stream. - - virtual void print(const char*); // Print a string. - - void inc(); // Increment indentation level. - void dec(); // Decrement indentation level. - - void useCurrentPosAsIndent(); // Save the current position as indentation. - void zeroIndent(); // Use zero identation. - void restoreIndent(); // Restore indentation. - - virtual void nl(); // Print newline. - void sp(); // Print separator. - - bool operator!() const; // Check whether the output state is ok. - -protected: - - std::ofstream _fout; - std::ostream& _out; - int _pos; - int _indent; - int _indentSize; - std::stack<int> _indentSave; - bool _useTab; - bool _separator; -}; - -class ICE_UTIL_API NextLine -{ -}; -extern ICE_UTIL_API NextLine nl; - -class ICE_UTIL_API Separator -{ -}; -extern ICE_UTIL_API Separator sp; - -// ---------------------------------------------------------------------- -// Output -// ---------------------------------------------------------------------- - -class ICE_UTIL_API Output : public OutputBase -{ -public: - - Output(); - Output(std::ostream&); - Output(const char*); - - void setBeginBlock(const char *); // what do we use at block starts? - void setEndBlock(const char *); // what do we use the block end? - - void sb(); // Start a block. - void eb(); // End a block. - -private: - - std::string _blockStart; - std::string _blockEnd; -}; - -template<typename T> -Output& -operator<<(Output& out, const T& val) -{ - std::ostringstream s; - s << val; - out.print(s.str().c_str()); - return out; -} - -template<> -inline Output& -operator<<(Output& o, const NextLine&) -{ - o.nl(); - return o; -} - -template<> -inline Output& -operator<<(Output& o, const Separator&) -{ - o.sp(); - return o; -} - -class ICE_UTIL_API StartBlock -{ -}; -extern ICE_UTIL_API StartBlock sb; - -template<> -inline Output& -operator<<(Output& o, const StartBlock&) -{ - o.sb(); - return o; -} - -class ICE_UTIL_API EndBlock -{ -}; -extern ICE_UTIL_API EndBlock eb; - -template<> -inline Output& -operator<<(Output& o, const EndBlock&) -{ - o.eb(); - return o; -} - -ICE_UTIL_API Output& operator<<(Output&, std::ios_base& (*)(std::ios_base&)); - -// ---------------------------------------------------------------------- -// XMLOutput -// ---------------------------------------------------------------------- - -class ICE_UTIL_API XMLOutput : public OutputBase -{ -public: - - XMLOutput(); - XMLOutput(std::ostream&); - XMLOutput(const char*); - - void setSGML(bool); - virtual void print(const char*); // Print a string. - - virtual void nl(); // Print newline. - - void se(const std::string&); // Start an element. - void ee(); // End an element. - -private: - - std::stack<std::string> _elementStack; - bool _printed; - bool _sgml; -}; - -template<typename T> -XMLOutput& -operator<<(XMLOutput& out, const T& val) -{ - std::ostringstream s; - s << val; - out.print(s.str().c_str()); - return out; -} - -template<> -inline XMLOutput& -operator<<(XMLOutput& o, const NextLine&) -{ - o.nl(); - return o; -} - -template<> -inline XMLOutput& -operator<<(XMLOutput& o, const Separator&) -{ - o.sp(); - return o; -} - -// TODO: Not performance critical, does not need to be inlined. -class ICE_UTIL_API StartElement -{ -public: - - StartElement(const std::string& name) : - _name(name) - { - } - - ~StartElement() - { - } - - const std::string& getName() const - { - return _name; - } - -private: - - const std::string _name; -}; -typedef StartElement se; - -template<> -inline XMLOutput& -operator<<(XMLOutput& o, const StartElement& e) -{ - o.se(e.getName()); - return o; -} - -class ICE_UTIL_API EndElement { }; -extern ICE_UTIL_API EndElement ee; - -template<> -inline XMLOutput& -operator<<(XMLOutput& o, const EndElement&) -{ - o.ee(); - return o; -} - -ICE_UTIL_API XMLOutput& operator<<(XMLOutput&, std::ios_base& (*)(std::ios_base&)); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_OUTPUT_UTIL_H
+#define ICE_UTIL_OUTPUT_UTIL_H
+
+#include <IceUtil/Config.h>
+#include <fstream>
+#include <stack>
+
+namespace IceUtil
+{
+
+// ----------------------------------------------------------------------
+// OutputBase
+// ----------------------------------------------------------------------
+
+//
+// Technically it's not necessary to have print() & nl() as virtual
+// since the opeator<< functions are specific to each OutputBase
+// derivative. However, since it's possible to call print() & nl()
+// manually I've decided to leave them as virtual.
+//
+
+class ICE_UTIL_API OutputBase : public ::IceUtil::noncopyable
+{
+public:
+
+ OutputBase();
+ OutputBase(std::ostream&);
+ OutputBase(const char*);
+ virtual ~OutputBase();
+
+ void setIndent(int); // What is the indent level?
+ void setUseTab(bool); // Should we output tabs?
+
+ void open(const char*); // Open output stream.
+
+ virtual void print(const char*); // Print a string.
+
+ void inc(); // Increment indentation level.
+ void dec(); // Decrement indentation level.
+
+ void useCurrentPosAsIndent(); // Save the current position as indentation.
+ void zeroIndent(); // Use zero identation.
+ void restoreIndent(); // Restore indentation.
+
+ virtual void nl(); // Print newline.
+ void sp(); // Print separator.
+
+ bool operator!() const; // Check whether the output state is ok.
+
+protected:
+
+ std::ofstream _fout;
+ std::ostream& _out;
+ int _pos;
+ int _indent;
+ int _indentSize;
+ std::stack<int> _indentSave;
+ bool _useTab;
+ bool _separator;
+};
+
+class ICE_UTIL_API NextLine
+{
+};
+extern ICE_UTIL_API NextLine nl;
+
+class ICE_UTIL_API Separator
+{
+};
+extern ICE_UTIL_API Separator sp;
+
+// ----------------------------------------------------------------------
+// Output
+// ----------------------------------------------------------------------
+
+class ICE_UTIL_API Output : public OutputBase
+{
+public:
+
+ Output();
+ Output(std::ostream&);
+ Output(const char*);
+
+ void setBeginBlock(const char *); // what do we use at block starts?
+ void setEndBlock(const char *); // what do we use the block end?
+
+ void sb(); // Start a block.
+ void eb(); // End a block.
+
+private:
+
+ std::string _blockStart;
+ std::string _blockEnd;
+};
+
+template<typename T>
+Output&
+operator<<(Output& out, const T& val)
+{
+ std::ostringstream s;
+ s << val;
+ out.print(s.str().c_str());
+ return out;
+}
+
+template<>
+inline Output&
+operator<<(Output& o, const NextLine&)
+{
+ o.nl();
+ return o;
+}
+
+template<>
+inline Output&
+operator<<(Output& o, const Separator&)
+{
+ o.sp();
+ return o;
+}
+
+class ICE_UTIL_API StartBlock
+{
+};
+extern ICE_UTIL_API StartBlock sb;
+
+template<>
+inline Output&
+operator<<(Output& o, const StartBlock&)
+{
+ o.sb();
+ return o;
+}
+
+class ICE_UTIL_API EndBlock
+{
+};
+extern ICE_UTIL_API EndBlock eb;
+
+template<>
+inline Output&
+operator<<(Output& o, const EndBlock&)
+{
+ o.eb();
+ return o;
+}
+
+ICE_UTIL_API Output& operator<<(Output&, std::ios_base& (*)(std::ios_base&));
+
+// ----------------------------------------------------------------------
+// XMLOutput
+// ----------------------------------------------------------------------
+
+class ICE_UTIL_API XMLOutput : public OutputBase
+{
+public:
+
+ XMLOutput();
+ XMLOutput(std::ostream&);
+ XMLOutput(const char*);
+
+ void setSGML(bool);
+ virtual void print(const char*); // Print a string.
+
+ virtual void nl(); // Print newline.
+
+ void se(const std::string&); // Start an element.
+ void ee(); // End an element.
+
+private:
+
+ std::stack<std::string> _elementStack;
+ bool _printed;
+ bool _sgml;
+};
+
+template<typename T>
+XMLOutput&
+operator<<(XMLOutput& out, const T& val)
+{
+ std::ostringstream s;
+ s << val;
+ out.print(s.str().c_str());
+ return out;
+}
+
+template<>
+inline XMLOutput&
+operator<<(XMLOutput& o, const NextLine&)
+{
+ o.nl();
+ return o;
+}
+
+template<>
+inline XMLOutput&
+operator<<(XMLOutput& o, const Separator&)
+{
+ o.sp();
+ return o;
+}
+
+// TODO: Not performance critical, does not need to be inlined.
+class ICE_UTIL_API StartElement
+{
+public:
+
+ StartElement(const std::string& name) :
+ _name(name)
+ {
+ }
+
+ ~StartElement()
+ {
+ }
+
+ const std::string& getName() const
+ {
+ return _name;
+ }
+
+private:
+
+ const std::string _name;
+};
+typedef StartElement se;
+
+template<>
+inline XMLOutput&
+operator<<(XMLOutput& o, const StartElement& e)
+{
+ o.se(e.getName());
+ return o;
+}
+
+class ICE_UTIL_API EndElement { };
+extern ICE_UTIL_API EndElement ee;
+
+template<>
+inline XMLOutput&
+operator<<(XMLOutput& o, const EndElement&)
+{
+ o.ee();
+ return o;
+}
+
+ICE_UTIL_API XMLOutput& operator<<(XMLOutput&, std::ios_base& (*)(std::ios_base&));
+
+}
+
+#endif
diff --git a/cpp/include/IceUtil/RWRecMutex.h b/cpp/include/IceUtil/RWRecMutex.h index 837bf04853a..00d8a5b5ab8 100644 --- a/cpp/include/IceUtil/RWRecMutex.h +++ b/cpp/include/IceUtil/RWRecMutex.h @@ -1,256 +1,256 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_RW_REC_MUTEX_H -#define ICE_UTIL_RW_REC_MUTEX_H - -#include <IceUtil/Mutex.h> -#include <IceUtil/Cond.h> -#include <IceUtil/Thread.h> - -namespace IceUtil -{ - -template <typename T> -class RLock -{ -public: - - RLock(const T& mutex) : - _mutex(mutex) - { - _mutex.readlock(); - } - - ~RLock() - { - _mutex.unlock(); - } - - void - upgrade() - { - _mutex.upgrade(); - } - - void - timedUpgrade(const Time& timeout) - { - _mutex.timedUpgrade(timeout); - } - -private: - - const T& _mutex; -}; - -template <typename T> -class TryRLock -{ -public: - - TryRLock(const T& mutex) : - _mutex(mutex) - { - _mutex.tryReadlock(); - } - - TryRLock(const T& mutex, const Time& timeout) : - _mutex(mutex) - { - _mutex.timedTryReadlock(timeout); - } - - ~TryRLock() - { - _mutex.unlock(); - } - - void - upgrade() - { - _mutex.upgrade(); - } - - void - timedUpgrade(const Time& timeout) - { - _mutex.timedUpgrade(timeout); - } - -private: - - const T& _mutex; -}; - -template <typename T> -class WLock -{ -public: - - WLock(const T& mutex) : - _mutex(mutex) - { - _mutex.writelock(); - } - - ~WLock() - { - _mutex.unlock(); - } - -private: - - const T& _mutex; -}; - -template <typename T> -class TryWLock -{ -public: - - TryWLock(const T& mutex) : - _mutex(mutex) - { - _mutex.tryWritelock(); - } - - TryWLock(const T& mutex, const Time& timeout) : - _mutex(mutex) - { - _mutex.timedTryWritelock(timeout); - } - - ~TryWLock() - { - _mutex.unlock(); - } - -private: - - const T& _mutex; -}; - -// -// Concurrency primitive that allows many readers & one writer access -// to a data structure. Writers have priority over readers. The -// structure is not strictly fair in that there is no absolute queue -// of waiting writers - that is managed by a condition variable. -// -// Both Reader & Writer mutexes can be recursively locked. Calling -// WLock (or TryWLock) while holding a read lock promotes the reader -// to a writer lock. -// -class ICE_UTIL_API RWRecMutex -{ -public: - - // - // RLock (reader) & WLock (writer) typedefs. - // - typedef RLock<RWRecMutex> RLock; - typedef TryRLock<RWRecMutex> TryRLock; - typedef WLock<RWRecMutex> WLock; - typedef TryWLock<RWRecMutex> TryWLock; - - RWRecMutex(); - ~RWRecMutex(); - - // - // Note that readlock/writelock & unlock in general should not be - // used directly. Instead use RLock & WLock. - // - - // - // Acquire a read lock. - // - void readlock() const; - - // - // Try to acquire a read lock. - // - void tryReadlock() const; - - // - // Try to acquire a read lock for upto the given timeout. - // - void timedTryReadlock(const Time&) const; - - // - // Acquire a write lock. - // - void writelock() const; - - // - // Acquire a write lock. - // - void tryWritelock() const; - - // - // Acquire a write lock for up to the given timeout. - // - void timedTryWritelock(const Time&) const; - - // - // Unlock the reader/writer lock. - // - void unlock() const; - - // - // Upgrade the read lock to a writer lock. Note that this method - // can only be called if the reader lock is not held recursively. - // - void upgrade() const; - - // - // Upgrade the read lock to a writer lock for up to the given - // timeout Note that this method can only be called if the reader - // lock is not held recursively. - // - void timedUpgrade(const Time&) const; - -private: - - // noncopyable - RWRecMutex(const RWRecMutex&); - void operator=(const RWRecMutex&); - - // - // Number of readers holding the lock. A positive number indicates - // readers are active. A negative number means that a writer is - // active. - // - mutable int _count; - - // - // If there is an active writer this is a control for thread. - // - mutable ThreadControl _writerControl; - - // - // Number of waiting writers. - // - mutable unsigned int _waitingWriters; - - // - // Internal mutex. - // - Mutex _mutex; - - // - // Two condition variables for waiting readers & writers. - // - mutable Cond _readers; - mutable Cond _writers; -}; - -} // End namespace IceUtil - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_RW_REC_MUTEX_H
+#define ICE_UTIL_RW_REC_MUTEX_H
+
+#include <IceUtil/Mutex.h>
+#include <IceUtil/Cond.h>
+#include <IceUtil/Thread.h>
+
+namespace IceUtil
+{
+
+template <typename T>
+class RLock
+{
+public:
+
+ RLock(const T& mutex) :
+ _mutex(mutex)
+ {
+ _mutex.readlock();
+ }
+
+ ~RLock()
+ {
+ _mutex.unlock();
+ }
+
+ void
+ upgrade()
+ {
+ _mutex.upgrade();
+ }
+
+ void
+ timedUpgrade(const Time& timeout)
+ {
+ _mutex.timedUpgrade(timeout);
+ }
+
+private:
+
+ const T& _mutex;
+};
+
+template <typename T>
+class TryRLock
+{
+public:
+
+ TryRLock(const T& mutex) :
+ _mutex(mutex)
+ {
+ _mutex.tryReadlock();
+ }
+
+ TryRLock(const T& mutex, const Time& timeout) :
+ _mutex(mutex)
+ {
+ _mutex.timedTryReadlock(timeout);
+ }
+
+ ~TryRLock()
+ {
+ _mutex.unlock();
+ }
+
+ void
+ upgrade()
+ {
+ _mutex.upgrade();
+ }
+
+ void
+ timedUpgrade(const Time& timeout)
+ {
+ _mutex.timedUpgrade(timeout);
+ }
+
+private:
+
+ const T& _mutex;
+};
+
+template <typename T>
+class WLock
+{
+public:
+
+ WLock(const T& mutex) :
+ _mutex(mutex)
+ {
+ _mutex.writelock();
+ }
+
+ ~WLock()
+ {
+ _mutex.unlock();
+ }
+
+private:
+
+ const T& _mutex;
+};
+
+template <typename T>
+class TryWLock
+{
+public:
+
+ TryWLock(const T& mutex) :
+ _mutex(mutex)
+ {
+ _mutex.tryWritelock();
+ }
+
+ TryWLock(const T& mutex, const Time& timeout) :
+ _mutex(mutex)
+ {
+ _mutex.timedTryWritelock(timeout);
+ }
+
+ ~TryWLock()
+ {
+ _mutex.unlock();
+ }
+
+private:
+
+ const T& _mutex;
+};
+
+//
+// Concurrency primitive that allows many readers & one writer access
+// to a data structure. Writers have priority over readers. The
+// structure is not strictly fair in that there is no absolute queue
+// of waiting writers - that is managed by a condition variable.
+//
+// Both Reader & Writer mutexes can be recursively locked. Calling
+// WLock (or TryWLock) while holding a read lock promotes the reader
+// to a writer lock.
+//
+class ICE_UTIL_API RWRecMutex
+{
+public:
+
+ //
+ // RLock (reader) & WLock (writer) typedefs.
+ //
+ typedef RLock<RWRecMutex> RLock;
+ typedef TryRLock<RWRecMutex> TryRLock;
+ typedef WLock<RWRecMutex> WLock;
+ typedef TryWLock<RWRecMutex> TryWLock;
+
+ RWRecMutex();
+ ~RWRecMutex();
+
+ //
+ // Note that readlock/writelock & unlock in general should not be
+ // used directly. Instead use RLock & WLock.
+ //
+
+ //
+ // Acquire a read lock.
+ //
+ void readlock() const;
+
+ //
+ // Try to acquire a read lock.
+ //
+ void tryReadlock() const;
+
+ //
+ // Try to acquire a read lock for upto the given timeout.
+ //
+ void timedTryReadlock(const Time&) const;
+
+ //
+ // Acquire a write lock.
+ //
+ void writelock() const;
+
+ //
+ // Acquire a write lock.
+ //
+ void tryWritelock() const;
+
+ //
+ // Acquire a write lock for up to the given timeout.
+ //
+ void timedTryWritelock(const Time&) const;
+
+ //
+ // Unlock the reader/writer lock.
+ //
+ void unlock() const;
+
+ //
+ // Upgrade the read lock to a writer lock. Note that this method
+ // can only be called if the reader lock is not held recursively.
+ //
+ void upgrade() const;
+
+ //
+ // Upgrade the read lock to a writer lock for up to the given
+ // timeout Note that this method can only be called if the reader
+ // lock is not held recursively.
+ //
+ void timedUpgrade(const Time&) const;
+
+private:
+
+ // noncopyable
+ RWRecMutex(const RWRecMutex&);
+ void operator=(const RWRecMutex&);
+
+ //
+ // Number of readers holding the lock. A positive number indicates
+ // readers are active. A negative number means that a writer is
+ // active.
+ //
+ mutable int _count;
+
+ //
+ // If there is an active writer this is a control for thread.
+ //
+ mutable ThreadControl _writerControl;
+
+ //
+ // Number of waiting writers.
+ //
+ mutable unsigned int _waitingWriters;
+
+ //
+ // Internal mutex.
+ //
+ Mutex _mutex;
+
+ //
+ // Two condition variables for waiting readers & writers.
+ //
+ mutable Cond _readers;
+ mutable Cond _writers;
+};
+
+} // End namespace IceUtil
+
+#endif
diff --git a/cpp/include/IceUtil/RecMutex.h b/cpp/include/IceUtil/RecMutex.h index b5373bbff4f..7d78de9d404 100644 --- a/cpp/include/IceUtil/RecMutex.h +++ b/cpp/include/IceUtil/RecMutex.h @@ -1,111 +1,111 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_RMUTEX_H -#define ICE_UTIL_RMUTEX_H - -#include <IceUtil/Config.h> -#include <IceUtil/Lock.h> - -namespace IceUtil -{ - -// -// Forward declarations for friend. -// -class Cond; - -// -// Recursive Mutex implementation. -// -class ICE_UTIL_API RecMutex -{ -public: - - // - // Lock & TryLock typedefs. - // - typedef Lock<RecMutex> Lock; - typedef TryLock<RecMutex> TryLock; - - RecMutex(); - ~RecMutex(); - - // - // Note that lock/trylock & unlock in general should not be used - // directly. Instead use Lock & TryLock. - // - - // - // The boolean values are for the Monitor implementation which - // needs to know whether the Mutex has been locked for the first - // time, or unlocked for the last time (that is another thread is - // able to acquire the mutex). - // - - // - // Return true if the mutex has been locked for the first time. - // - bool lock() const; - - // - // Throw LockedException in the case that the lock call would - // block (that is the mutex is already owned by some other - // thread). Returns true if the mutex has been locked for the - // first time. - // - bool trylock() const; - - // - // Returns true if the mutex has been unlocked for the last time - // (false otherwise). - // - bool unlock() const; - -private: - - // noncopyable - RecMutex(const RecMutex&); - void operator=(const RecMutex&); - - // - // LockState and the lock/unlock variations are for use by the - // Condition variable implementation. - // -#ifdef _WIN32 - struct LockState - { - int count; - }; -#else - struct LockState - { - pthread_mutex_t* mutex; - int count; - }; -#endif - - void unlock(LockState&) const; - void lock(LockState&) const; - - friend class Cond; - -#ifdef _WIN32 - mutable CRITICAL_SECTION _mutex; -#else - mutable pthread_mutex_t _mutex; -#endif - - mutable int _count; -}; - -} // End namespace IceUtil - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_RMUTEX_H
+#define ICE_UTIL_RMUTEX_H
+
+#include <IceUtil/Config.h>
+#include <IceUtil/Lock.h>
+
+namespace IceUtil
+{
+
+//
+// Forward declarations for friend.
+//
+class Cond;
+
+//
+// Recursive Mutex implementation.
+//
+class ICE_UTIL_API RecMutex
+{
+public:
+
+ //
+ // Lock & TryLock typedefs.
+ //
+ typedef Lock<RecMutex> Lock;
+ typedef TryLock<RecMutex> TryLock;
+
+ RecMutex();
+ ~RecMutex();
+
+ //
+ // Note that lock/trylock & unlock in general should not be used
+ // directly. Instead use Lock & TryLock.
+ //
+
+ //
+ // The boolean values are for the Monitor implementation which
+ // needs to know whether the Mutex has been locked for the first
+ // time, or unlocked for the last time (that is another thread is
+ // able to acquire the mutex).
+ //
+
+ //
+ // Return true if the mutex has been locked for the first time.
+ //
+ bool lock() const;
+
+ //
+ // Throw LockedException in the case that the lock call would
+ // block (that is the mutex is already owned by some other
+ // thread). Returns true if the mutex has been locked for the
+ // first time.
+ //
+ bool trylock() const;
+
+ //
+ // Returns true if the mutex has been unlocked for the last time
+ // (false otherwise).
+ //
+ bool unlock() const;
+
+private:
+
+ // noncopyable
+ RecMutex(const RecMutex&);
+ void operator=(const RecMutex&);
+
+ //
+ // LockState and the lock/unlock variations are for use by the
+ // Condition variable implementation.
+ //
+#ifdef _WIN32
+ struct LockState
+ {
+ int count;
+ };
+#else
+ struct LockState
+ {
+ pthread_mutex_t* mutex;
+ int count;
+ };
+#endif
+
+ void unlock(LockState&) const;
+ void lock(LockState&) const;
+
+ friend class Cond;
+
+#ifdef _WIN32
+ mutable CRITICAL_SECTION _mutex;
+#else
+ mutable pthread_mutex_t _mutex;
+#endif
+
+ mutable int _count;
+};
+
+} // End namespace IceUtil
+
+#endif
diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h index 1e16944c112..7ce6427eea6 100644 --- a/cpp/include/IceUtil/Shared.h +++ b/cpp/include/IceUtil/Shared.h @@ -1,364 +1,364 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_SHARED_H -#define ICE_UTIL_SHARED_H - -#include <IceUtil/Config.h> - -// -// The inline assembler causes problems with shared libraries. -// -#if defined(__ICC) && !defined(_WIN32) -# define ICE_USE_MUTEX_SHARED -#endif - -#ifdef ICE_USE_MUTEX_SHARED -# include <IceUtil/Mutex.h> -#endif - -#if !defined(_WIN32) && !defined(ICE_USE_MUTEX_SHARED) - -// -// Linux only. Unfortunately, asm/atomic.h builds non-SMP safe code -// with non-SMP kernels. This means that executables compiled with a -// non-SMP kernel would fail randomly due to concurrency errors with -// reference counting on SMP hosts. Therefore the relevent pieces of -// atomic.h are more-or-less duplicated. -// - -/* - * Make sure gcc doesn't try to be clever and move things around - * on us. We need to use _exactly_ the address the user gave us, - * not some alias that contains the same information. - */ -struct ice_atomic_t -{ - volatile int counter; -}; - -/* - * ice_atomic_set - set ice_atomic variable - * @v: pointer of type ice_atomic_t - * @i: required value - * - * Atomically sets the value of @v to @i. Note that the guaranteed - * useful range of an ice_atomic_t is only 24 bits. - */ -inline void ice_atomic_set(ice_atomic_t* v, int i) -{ - v->counter = i; -} - -/* - * ice_atomic_inc - increment ice_atomic variable - * @v: pointer of type ice_atomic_t - * - * Atomically increments @v by 1. Note that the guaranteed useful - * range of an ice_atomic_t is only 24 bits. - * - * Inlined because this operation is performance critical. - */ -inline void ice_atomic_inc(ice_atomic_t *v) -{ - __asm__ __volatile__( - "lock ; incl %0" - :"=m" (v->counter) - :"m" (v->counter)); -} - -/** - * ice_atomic_dec_and_test - decrement and test - * @v: pointer of type ice_atomic_t - * - * Atomically decrements @v by 1 and returns true if the result is 0, - * or false for all other cases. Note that the guaranteed useful - * range of an ice_atomic_t is only 24 bits. - * - * Inlined because this operation is performance critical. - */ -inline int ice_atomic_dec_and_test(ice_atomic_t *v) -{ - unsigned char c; - __asm__ __volatile__( - "lock ; decl %0; sete %1" - :"=m" (v->counter), "=qm" (c) - :"m" (v->counter) : "memory"); - return c != 0; -} - -/** - * ice_atomic_exchange_add - same as InterlockedExchangeAdd. This - * didn't come from atomic.h (the code was derived from similar code - * in /usr/include/asm/rwsem.h) - * - * Inlined because this operation is performance critical. - */ -inline int ice_atomic_exchange_add(int i, ice_atomic_t* v) -{ - int tmp = i; - __asm__ __volatile__( - "lock ; xadd %0,(%2)" - :"+r"(tmp), "=m"(v->counter) - :"r"(v), "m"(v->counter) - : "memory"); - return tmp + i; -} - -#endif - -// -// Base classes for reference counted types. The IceUtil::Handle -// template can be used for smart pointers to types derived from these -// bases. -// -// IceUtil::SimpleShared -// ===================== -// -// A non thread-safe base class for reference-counted types. -// -// IceUtil::Shared -// =============== -// -// A thread-safe base class for reference-counted types. -// -namespace IceUtil -{ - -// -// TODO: Not all operations in this class are performance critical, -// thus not all of them should be inlined. -// - -class SimpleShared : public noncopyable -{ -public: - - SimpleShared() : - _ref(0), - _noDelete(false) - { - } - - virtual ~SimpleShared() - { - } - - void __incRef() - { - assert(_ref >= 0); - ++_ref; - } - - void __decRef() - { - assert(_ref > 0); - if (--_ref == 0) - { - if(!_noDelete) - { - delete this; - } - } - } - - int __getRef() const - { - return _ref; - } - - void __setNoDelete(bool b) - { - _noDelete = b; - } - -private: - - int _ref; - bool _noDelete; -}; - -class Shared : public noncopyable -{ -public: - - Shared(); - virtual ~Shared(); - void __incRef(); - void __decRef(); - int __getRef() const; - void __setNoDelete(bool); - -private: - -#ifdef ICE_USE_MUTEX_SHARED - int _ref; - Mutex _mutex; -#elif defined(_WIN32) - LONG _ref; -#else - ice_atomic_t _ref; -#endif - bool _noDelete; -}; - -// -// TODO: Not all operations below are performance critical, thus not -// all of them should be inlined. -// - -#ifdef ICE_USE_MUTEX_SHARED - -inline -Shared::Shared() : - _ref(0), - _noDelete(false) -{ -} - -inline -Shared::~Shared() -{ -} - -inline void -Shared::__incRef() -{ - _mutex.lock(); - assert(_ref >= 0); - ++_ref; - _mutex.unlock(); -} - -inline void -Shared::__decRef() -{ - _mutex.lock(); - bool doDelete = false; - assert(_ref > 0); - if (--_ref == 0) - { - doDelete = !_noDelete; - } - _mutex.unlock(); - if (doDelete) - { - delete this; - } -} - -inline int -Shared::__getRef() const -{ - _mutex.lock(); - int ref = _ref; - _mutex.unlock(); - return ref; -} - -inline void -Shared::__setNoDelete(bool b) -{ - _mutex.lock(); - _noDelete = b; - _mutex.unlock(); -} - -#elif defined(_WIN32) - -inline -Shared::Shared() : - _ref(0), - _noDelete(false) -{ -} - -inline -Shared::~Shared() -{ -} - -inline void -Shared::__incRef() -{ - assert(InterlockedExchangeAdd(&_ref, 0) >= 0); - InterlockedIncrement(&_ref); -} - -inline void -Shared::__decRef() -{ - assert(InterlockedExchangeAdd(&_ref, 0) > 0); - if (InterlockedDecrement(&_ref) == 0 && !_noDelete) - { - delete this; - } -} - -inline int -Shared::__getRef() const -{ - return InterlockedExchangeAdd(const_cast<LONG*>(&_ref), 0); -} - -inline void -Shared::__setNoDelete(bool b) -{ - _noDelete = b; -} - -#else - -inline -Shared::Shared() : - _noDelete(false) -{ - ice_atomic_set(&_ref, 0); -} - -inline -Shared::~Shared() -{ -} - -inline void -Shared::__incRef() -{ - assert(ice_atomic_exchange_add(0, &_ref) >= 0); - ice_atomic_inc(&_ref); -} - -inline void -Shared::__decRef() -{ - assert(ice_atomic_exchange_add(0, &_ref) > 0); - if (ice_atomic_dec_and_test(&_ref) && !_noDelete) - { - delete this; - } -} - -inline int -Shared::__getRef() const -{ - return ice_atomic_exchange_add(0, const_cast<ice_atomic_t*>(&_ref)); -} - -inline void -Shared::__setNoDelete(bool b) -{ - _noDelete = b; -} - -#endif - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_SHARED_H
+#define ICE_UTIL_SHARED_H
+
+#include <IceUtil/Config.h>
+
+//
+// The inline assembler causes problems with shared libraries.
+//
+#if defined(__ICC) && !defined(_WIN32)
+# define ICE_USE_MUTEX_SHARED
+#endif
+
+#ifdef ICE_USE_MUTEX_SHARED
+# include <IceUtil/Mutex.h>
+#endif
+
+#if !defined(_WIN32) && !defined(ICE_USE_MUTEX_SHARED)
+
+//
+// Linux only. Unfortunately, asm/atomic.h builds non-SMP safe code
+// with non-SMP kernels. This means that executables compiled with a
+// non-SMP kernel would fail randomly due to concurrency errors with
+// reference counting on SMP hosts. Therefore the relevent pieces of
+// atomic.h are more-or-less duplicated.
+//
+
+/*
+ * Make sure gcc doesn't try to be clever and move things around
+ * on us. We need to use _exactly_ the address the user gave us,
+ * not some alias that contains the same information.
+ */
+struct ice_atomic_t
+{
+ volatile int counter;
+};
+
+/*
+ * ice_atomic_set - set ice_atomic variable
+ * @v: pointer of type ice_atomic_t
+ * @i: required value
+ *
+ * Atomically sets the value of @v to @i. Note that the guaranteed
+ * useful range of an ice_atomic_t is only 24 bits.
+ */
+inline void ice_atomic_set(ice_atomic_t* v, int i)
+{
+ v->counter = i;
+}
+
+/*
+ * ice_atomic_inc - increment ice_atomic variable
+ * @v: pointer of type ice_atomic_t
+ *
+ * Atomically increments @v by 1. Note that the guaranteed useful
+ * range of an ice_atomic_t is only 24 bits.
+ *
+ * Inlined because this operation is performance critical.
+ */
+inline void ice_atomic_inc(ice_atomic_t *v)
+{
+ __asm__ __volatile__(
+ "lock ; incl %0"
+ :"=m" (v->counter)
+ :"m" (v->counter));
+}
+
+/**
+ * ice_atomic_dec_and_test - decrement and test
+ * @v: pointer of type ice_atomic_t
+ *
+ * Atomically decrements @v by 1 and returns true if the result is 0,
+ * or false for all other cases. Note that the guaranteed useful
+ * range of an ice_atomic_t is only 24 bits.
+ *
+ * Inlined because this operation is performance critical.
+ */
+inline int ice_atomic_dec_and_test(ice_atomic_t *v)
+{
+ unsigned char c;
+ __asm__ __volatile__(
+ "lock ; decl %0; sete %1"
+ :"=m" (v->counter), "=qm" (c)
+ :"m" (v->counter) : "memory");
+ return c != 0;
+}
+
+/**
+ * ice_atomic_exchange_add - same as InterlockedExchangeAdd. This
+ * didn't come from atomic.h (the code was derived from similar code
+ * in /usr/include/asm/rwsem.h)
+ *
+ * Inlined because this operation is performance critical.
+ */
+inline int ice_atomic_exchange_add(int i, ice_atomic_t* v)
+{
+ int tmp = i;
+ __asm__ __volatile__(
+ "lock ; xadd %0,(%2)"
+ :"+r"(tmp), "=m"(v->counter)
+ :"r"(v), "m"(v->counter)
+ : "memory");
+ return tmp + i;
+}
+
+#endif
+
+//
+// Base classes for reference counted types. The IceUtil::Handle
+// template can be used for smart pointers to types derived from these
+// bases.
+//
+// IceUtil::SimpleShared
+// =====================
+//
+// A non thread-safe base class for reference-counted types.
+//
+// IceUtil::Shared
+// ===============
+//
+// A thread-safe base class for reference-counted types.
+//
+namespace IceUtil
+{
+
+//
+// TODO: Not all operations in this class are performance critical,
+// thus not all of them should be inlined.
+//
+
+class SimpleShared : public noncopyable
+{
+public:
+
+ SimpleShared() :
+ _ref(0),
+ _noDelete(false)
+ {
+ }
+
+ virtual ~SimpleShared()
+ {
+ }
+
+ void __incRef()
+ {
+ assert(_ref >= 0);
+ ++_ref;
+ }
+
+ void __decRef()
+ {
+ assert(_ref > 0);
+ if(--_ref == 0)
+ {
+ if(!_noDelete)
+ {
+ delete this;
+ }
+ }
+ }
+
+ int __getRef() const
+ {
+ return _ref;
+ }
+
+ void __setNoDelete(bool b)
+ {
+ _noDelete = b;
+ }
+
+private:
+
+ int _ref;
+ bool _noDelete;
+};
+
+class Shared : public noncopyable
+{
+public:
+
+ Shared();
+ virtual ~Shared();
+ void __incRef();
+ void __decRef();
+ int __getRef() const;
+ void __setNoDelete(bool);
+
+private:
+
+#ifdef ICE_USE_MUTEX_SHARED
+ int _ref;
+ Mutex _mutex;
+#elif defined(_WIN32)
+ LONG _ref;
+#else
+ ice_atomic_t _ref;
+#endif
+ bool _noDelete;
+};
+
+//
+// TODO: Not all operations below are performance critical, thus not
+// all of them should be inlined.
+//
+
+#ifdef ICE_USE_MUTEX_SHARED
+
+inline
+Shared::Shared() :
+ _ref(0),
+ _noDelete(false)
+{
+}
+
+inline
+Shared::~Shared()
+{
+}
+
+inline void
+Shared::__incRef()
+{
+ _mutex.lock();
+ assert(_ref >= 0);
+ ++_ref;
+ _mutex.unlock();
+}
+
+inline void
+Shared::__decRef()
+{
+ _mutex.lock();
+ bool doDelete = false;
+ assert(_ref > 0);
+ if(--_ref == 0)
+ {
+ doDelete = !_noDelete;
+ }
+ _mutex.unlock();
+ if(doDelete)
+ {
+ delete this;
+ }
+}
+
+inline int
+Shared::__getRef() const
+{
+ _mutex.lock();
+ int ref = _ref;
+ _mutex.unlock();
+ return ref;
+}
+
+inline void
+Shared::__setNoDelete(bool b)
+{
+ _mutex.lock();
+ _noDelete = b;
+ _mutex.unlock();
+}
+
+#elif defined(_WIN32)
+
+inline
+Shared::Shared() :
+ _ref(0),
+ _noDelete(false)
+{
+}
+
+inline
+Shared::~Shared()
+{
+}
+
+inline void
+Shared::__incRef()
+{
+ assert(InterlockedExchangeAdd(&_ref, 0) >= 0);
+ InterlockedIncrement(&_ref);
+}
+
+inline void
+Shared::__decRef()
+{
+ assert(InterlockedExchangeAdd(&_ref, 0) > 0);
+ if(InterlockedDecrement(&_ref) == 0 && !_noDelete)
+ {
+ delete this;
+ }
+}
+
+inline int
+Shared::__getRef() const
+{
+ return InterlockedExchangeAdd(const_cast<LONG*>(&_ref), 0);
+}
+
+inline void
+Shared::__setNoDelete(bool b)
+{
+ _noDelete = b;
+}
+
+#else
+
+inline
+Shared::Shared() :
+ _noDelete(false)
+{
+ ice_atomic_set(&_ref, 0);
+}
+
+inline
+Shared::~Shared()
+{
+}
+
+inline void
+Shared::__incRef()
+{
+ assert(ice_atomic_exchange_add(0, &_ref) >= 0);
+ ice_atomic_inc(&_ref);
+}
+
+inline void
+Shared::__decRef()
+{
+ assert(ice_atomic_exchange_add(0, &_ref) > 0);
+ if(ice_atomic_dec_and_test(&_ref) && !_noDelete)
+ {
+ delete this;
+ }
+}
+
+inline int
+Shared::__getRef() const
+{
+ return ice_atomic_exchange_add(0, const_cast<ice_atomic_t*>(&_ref));
+}
+
+inline void
+Shared::__setNoDelete(bool b)
+{
+ _noDelete = b;
+}
+
+#endif
+
+}
+
+#endif
diff --git a/cpp/include/IceUtil/Thread.h b/cpp/include/IceUtil/Thread.h index 23db59b41b7..53af95bf8cc 100644 --- a/cpp/include/IceUtil/Thread.h +++ b/cpp/include/IceUtil/Thread.h @@ -1,117 +1,117 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_THREAD_H -#define ICE_UTIL_THREAD_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Handle.h> - -namespace IceUtil -{ - -class Time; - -#ifdef _WIN32 -struct HandleWrapper : public Shared -{ - // Inline for performance reasons. - HandleWrapper(HANDLE h) : - handle(h) - { - } - - // Inline for performance reasons. - virtual ~HandleWrapper() - { - if (handle != 0) - { - CloseHandle(handle); - } - } - - HANDLE handle; -}; - -typedef Handle<HandleWrapper> HandleWrapperPtr; -#endif - -class ICE_UTIL_API ThreadControl -{ -public: - - ThreadControl(); - -#ifdef _WIN32 - ThreadControl(const HandleWrapperPtr&, unsigned); -#else - ThreadControl(pthread_t); -#endif - - bool operator==(const ThreadControl&) const; - bool operator!=(const ThreadControl&) const; - bool operator<(const ThreadControl&) const; - - // - // Wait until the controlled thread terminates. The call has POSIX - // semantics. - // - // At most one thread can wait for the termination of a given - // thread.C alling join on a thread on which another thread is - // already waiting for termination results in undefined behaviour. - // - void join(); - - static void sleep(const Time&); - static void yield(); - -private: - -#ifdef _WIN32 - HandleWrapperPtr _handle; - unsigned _id; -#else - pthread_t _id; -#endif -}; - -class ICE_UTIL_API Thread : virtual public IceUtil::Shared -{ -public: - - Thread(); - virtual ~Thread(); - - virtual void run() = 0; - - ThreadControl start(); - - ThreadControl getThreadControl(); - - bool operator==(const Thread&) const; - bool operator!=(const Thread&) const; - bool operator<(const Thread&) const; - -private: - -#ifdef _WIN32 - unsigned _id; - HandleWrapperPtr _handle; -#else - pthread_t _id; -#endif -}; - -typedef Handle<Thread> ThreadPtr; - -} // End namespace IceUtil - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_THREAD_H
+#define ICE_UTIL_THREAD_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Handle.h>
+
+namespace IceUtil
+{
+
+class Time;
+
+#ifdef _WIN32
+struct HandleWrapper : public Shared
+{
+ // Inline for performance reasons.
+ HandleWrapper(HANDLE h) :
+ handle(h)
+ {
+ }
+
+ // Inline for performance reasons.
+ virtual ~HandleWrapper()
+ {
+ if(handle != 0)
+ {
+ CloseHandle(handle);
+ }
+ }
+
+ HANDLE handle;
+};
+
+typedef Handle<HandleWrapper> HandleWrapperPtr;
+#endif
+
+class ICE_UTIL_API ThreadControl
+{
+public:
+
+ ThreadControl();
+
+#ifdef _WIN32
+ ThreadControl(const HandleWrapperPtr&, unsigned);
+#else
+ ThreadControl(pthread_t);
+#endif
+
+ bool operator==(const ThreadControl&) const;
+ bool operator!=(const ThreadControl&) const;
+ bool operator<(const ThreadControl&) const;
+
+ //
+ // Wait until the controlled thread terminates. The call has POSIX
+ // semantics.
+ //
+ // At most one thread can wait for the termination of a given
+ // thread.C alling join on a thread on which another thread is
+ // already waiting for termination results in undefined behaviour.
+ //
+ void join();
+
+ static void sleep(const Time&);
+ static void yield();
+
+private:
+
+#ifdef _WIN32
+ HandleWrapperPtr _handle;
+ unsigned _id;
+#else
+ pthread_t _id;
+#endif
+};
+
+class ICE_UTIL_API Thread : virtual public IceUtil::Shared
+{
+public:
+
+ Thread();
+ virtual ~Thread();
+
+ virtual void run() = 0;
+
+ ThreadControl start();
+
+ ThreadControl getThreadControl();
+
+ bool operator==(const Thread&) const;
+ bool operator!=(const Thread&) const;
+ bool operator<(const Thread&) const;
+
+private:
+
+#ifdef _WIN32
+ unsigned _id;
+ HandleWrapperPtr _handle;
+#else
+ pthread_t _id;
+#endif
+};
+
+typedef Handle<Thread> ThreadPtr;
+
+} // End namespace IceUtil
+
+#endif
+
diff --git a/cpp/include/IceUtil/Time.h b/cpp/include/IceUtil/Time.h index cd58ecd4ae0..ef45d9876b7 100644 --- a/cpp/include/IceUtil/Time.h +++ b/cpp/include/IceUtil/Time.h @@ -1,69 +1,69 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_TIME_H -#define ICE_UTIL_TIME_H - -#include <IceUtil/Config.h> - -namespace IceUtil -{ - -class ICE_UTIL_API Time -{ -public: - - Time(); - - // No copy constructor and assignment operator necessary. The - // automatically generated copy constructor and assignment - // operator do the right thing. - - static Time now(); - static Time seconds(long); - static Time milliSeconds(long); -#ifdef _WIN32 - static Time microSeconds(__int64); -#else - static Time microSeconds(long long); -#endif - - Time operator-() const; - Time operator-(const Time&) const; - Time operator+(const Time&) const; - Time& operator+=(const Time&); - Time& operator-=(const Time&); - - bool operator<(const Time&) const; - bool operator<=(const Time&) const; - bool operator>(const Time&) const; - bool operator>=(const Time&) const; - bool operator==(const Time&) const; - bool operator!=(const Time&) const; - - operator timeval() const; - operator double() const; - -private: - -#ifdef _WIN32 -typedef __int64 LongLong; -#else -typedef long long LongLong; -#endif - - Time(LongLong); - - LongLong _usec; -}; - -} // End namespace IceUtil - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_TIME_H
+#define ICE_UTIL_TIME_H
+
+#include <IceUtil/Config.h>
+
+namespace IceUtil
+{
+
+class ICE_UTIL_API Time
+{
+public:
+
+ Time();
+
+ // No copy constructor and assignment operator necessary. The
+ // automatically generated copy constructor and assignment
+ // operator do the right thing.
+
+ static Time now();
+ static Time seconds(long);
+ static Time milliSeconds(long);
+#ifdef _WIN32
+ static Time microSeconds(__int64);
+#else
+ static Time microSeconds(long long);
+#endif
+
+ Time operator-() const;
+ Time operator-(const Time&) const;
+ Time operator+(const Time&) const;
+ Time& operator+=(const Time&);
+ Time& operator-=(const Time&);
+
+ bool operator<(const Time&) const;
+ bool operator<=(const Time&) const;
+ bool operator>(const Time&) const;
+ bool operator>=(const Time&) const;
+ bool operator==(const Time&) const;
+ bool operator!=(const Time&) const;
+
+ operator timeval() const;
+ operator double() const;
+
+private:
+
+#ifdef _WIN32
+typedef __int64 LongLong;
+#else
+typedef long long LongLong;
+#endif
+
+ Time(LongLong);
+
+ LongLong _usec;
+};
+
+} // End namespace IceUtil
+
+#endif
diff --git a/cpp/include/IceUtil/UUID.h b/cpp/include/IceUtil/UUID.h index ba6891f019c..da677c0b388 100644 --- a/cpp/include/IceUtil/UUID.h +++ b/cpp/include/IceUtil/UUID.h @@ -1,23 +1,23 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_UUID_H -#define ICE_UTIL_UUID_H - -#include <IceUtil/Config.h> - -namespace IceUtil -{ - -ICE_UTIL_API std::string generateUUID(); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_UUID_H
+#define ICE_UTIL_UUID_H
+
+#include <IceUtil/Config.h>
+
+namespace IceUtil
+{
+
+ICE_UTIL_API std::string generateUUID();
+
+}
+
+#endif
diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h index a5d5b58514f..88dda673fe3 100644 --- a/cpp/include/IceUtil/Unicode.h +++ b/cpp/include/IceUtil/Unicode.h @@ -1,24 +1,24 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UTIL_UNICODE_H -#define ICE_UTIL_UNICODE_H - -#include <IceUtil/Config.h> - -namespace IceUtil -{ - -ICE_UTIL_API std::string wstringToString(const std::wstring&); -ICE_UTIL_API std::wstring stringToWstring(const std::string&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UTIL_UNICODE_H
+#define ICE_UTIL_UNICODE_H
+
+#include <IceUtil/Config.h>
+
+namespace IceUtil
+{
+
+ICE_UTIL_API std::string wstringToString(const std::wstring&);
+ICE_UTIL_API std::wstring stringToWstring(const std::string&);
+
+}
+
+#endif
diff --git a/cpp/include/IceXML/StreamI.h b/cpp/include/IceXML/StreamI.h index 57bdf4aebeb..29f54ac8652 100644 --- a/cpp/include/IceXML/StreamI.h +++ b/cpp/include/IceXML/StreamI.h @@ -1,232 +1,232 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_XML_STREAM_I_H -#define ICE_XML_STREAM_I_H - -#include <Ice/Stream.h> -#include <Ice/CommunicatorF.h> -#include <IceUtil/OutputUtil.h> - -#include <map> - -#ifdef _WIN32 -# ifdef ICE_XML_API_EXPORTS -# define ICE_XML_API __declspec(dllexport) -# else -# define ICE_XML_API __declspec(dllimport) -# endif -#else -# define ICE_XML_API /**/ -#endif - -namespace IceXML -{ - -// -// This is to reduce dependencies on Xerces. -// -struct StreamInputImpl; - -class ICE_XML_API StreamI : public ::Ice::Stream -{ - StreamI(); - StreamI(const StreamI&); - void operator=(const StreamI&); - -public: - - StreamI(const ::Ice::CommunicatorPtr&, std::ostream&); - - StreamI(const ::Ice::CommunicatorPtr&, std::istream&, bool = true); - - ~StreamI(); - - virtual void startWriteDictionary(const ::std::string&, ::Ice::Int); - - virtual void endWriteDictionary(); - - virtual void startWriteDictionaryElement(); - - virtual void endWriteDictionaryElement(); - - virtual ::Ice::Int startReadDictionary(const ::std::string&); - - virtual void endReadDictionary(); - - virtual void startReadDictionaryElement(); - - virtual void endReadDictionaryElement(); - - virtual void startWriteSequence(const ::std::string&, ::Ice::Int); - - virtual void endWriteSequence(); - - virtual void startWriteSequenceElement(); - - virtual void endWriteSequenceElement(); - - virtual ::Ice::Int startReadSequence(const ::std::string&); - - virtual void endReadSequence(); - - virtual void startReadSequenceElement(); - - virtual void endReadSequenceElement(); - - virtual void startWriteStruct(const ::std::string&); - - virtual void endWriteStruct(); - - virtual void startReadStruct(const ::std::string&); - - virtual void endReadStruct(); - - virtual void startWriteException(const ::std::string&); - - virtual void endWriteException(); - - virtual void startReadException(const ::std::string&); - - virtual void endReadException(); - - virtual void writeEnum(const ::std::string&, const ::Ice::StringSeq&, ::Ice::Int); - - virtual ::Ice::Int readEnum(const ::std::string&, const ::Ice::StringSeq&); - - virtual void writeByte(const ::std::string&, ::Ice::Byte); - - virtual void writeByteSeq(const ::std::string&, const ::Ice::ByteSeq&); - - virtual ::Ice::Byte readByte(const ::std::string&); - - virtual ::Ice::ByteSeq readByteSeq(const ::std::string&); - - virtual void writeBool(const ::std::string&, bool); - - virtual void writeBoolSeq(const ::std::string&, const ::Ice::BoolSeq&); - - virtual bool readBool(const ::std::string&); - - virtual ::Ice::BoolSeq readBoolSeq(const ::std::string&); - - virtual void writeShort(const ::std::string&, ::Ice::Short); - - virtual void writeShortSeq(const ::std::string&, const ::Ice::ShortSeq&); - - virtual ::Ice::Short readShort(const ::std::string&); - - virtual ::Ice::ShortSeq readShortSeq(const ::std::string&); - - virtual void writeInt(const ::std::string&, ::Ice::Int); - - virtual void writeIntSeq(const ::std::string&, const ::Ice::IntSeq&); - - virtual ::Ice::Int readInt(const ::std::string&); - - virtual ::Ice::IntSeq readIntSeq(const ::std::string&); - - virtual void writeLong(const ::std::string&, ::Ice::Long); - - virtual void writeLongSeq(const ::std::string&, const ::Ice::LongSeq&); - - virtual ::Ice::Long readLong(const ::std::string&); - - virtual ::Ice::LongSeq readLongSeq(const ::std::string&); - - virtual void writeFloat(const ::std::string&, ::Ice::Float); - - virtual void writeFloatSeq(const ::std::string&, const ::Ice::FloatSeq&); - - virtual ::Ice::Float readFloat(const ::std::string&); - - virtual ::Ice::FloatSeq readFloatSeq(const ::std::string&); - - virtual void writeDouble(const ::std::string&, ::Ice::Double); - - virtual void writeDoubleSeq(const ::std::string&, const ::Ice::DoubleSeq&); - - virtual ::Ice::Double readDouble(const ::std::string&); - - virtual ::Ice::DoubleSeq readDoubleSeq(const ::std::string&); - - virtual void writeString(const ::std::string&, const ::std::string&); - - virtual void writeStringSeq(const ::std::string&, const ::Ice::StringSeq&); - - virtual ::std::string readString(const ::std::string&); - - virtual ::Ice::StringSeq readStringSeq(const ::std::string&); - - virtual void writeProxy(const ::std::string&, const ::Ice::ObjectPrx&); - - virtual ::Ice::ObjectPrx readProxy(const ::std::string&); - - virtual void writeObject(const ::std::string&, const ::Ice::ObjectPtr&); - - virtual ::Ice::ObjectPtr readObject(const ::std::string&, const ::std::string&, const ::Ice::ObjectFactoryPtr&); - -private: - - void startWrite(const std::string&); - void endWrite(); - - void startRead(const std::string&); - void endRead(); - - void dumpUnwrittenObjects(); - void writeObjectData(const ::std::string&, const ::std::string&, const ::Ice::ObjectPtr&); - void readAttributes(::std::string&, ::std::string&, ::std::string&); - ::Ice::Int readLength(); - - ::Ice::CommunicatorPtr _communicator; - - // - // Name of the sequence element name - // - static const ::std::string seqElementName; - - // - // For reading. - // - ::std::string _content; - StreamInputImpl* _input; - - // - // For writing. - // - - // - // XML Output stream. - // - ::IceUtil::XMLOutput _os; - - // - // Current document level. - // - int _level; - - // - // Next id for marshaling objects. - // - int _nextId; - struct ObjectInfo - { - ObjectInfo(const ::std::string& i, bool w) : - id(i), written(w) { } - ::std::string id; // The id of the associated object - bool written; // Has the object been written? - }; - ::std::map<Ice::ObjectPtr, ObjectInfo> _objects; -}; - -} // End namespace IceXML - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_XML_STREAM_I_H
+#define ICE_XML_STREAM_I_H
+
+#include <Ice/Stream.h>
+#include <Ice/CommunicatorF.h>
+#include <IceUtil/OutputUtil.h>
+
+#include <map>
+
+#ifdef _WIN32
+# ifdef ICE_XML_API_EXPORTS
+# define ICE_XML_API __declspec(dllexport)
+# else
+# define ICE_XML_API __declspec(dllimport)
+# endif
+#else
+# define ICE_XML_API /**/
+#endif
+
+namespace IceXML
+{
+
+//
+// This is to reduce dependencies on Xerces.
+//
+struct StreamInputImpl;
+
+class ICE_XML_API StreamI : public ::Ice::Stream
+{
+ StreamI();
+ StreamI(const StreamI&);
+ void operator=(const StreamI&);
+
+public:
+
+ StreamI(const ::Ice::CommunicatorPtr&, std::ostream&);
+
+ StreamI(const ::Ice::CommunicatorPtr&, std::istream&, bool = true);
+
+ ~StreamI();
+
+ virtual void startWriteDictionary(const ::std::string&, ::Ice::Int);
+
+ virtual void endWriteDictionary();
+
+ virtual void startWriteDictionaryElement();
+
+ virtual void endWriteDictionaryElement();
+
+ virtual ::Ice::Int startReadDictionary(const ::std::string&);
+
+ virtual void endReadDictionary();
+
+ virtual void startReadDictionaryElement();
+
+ virtual void endReadDictionaryElement();
+
+ virtual void startWriteSequence(const ::std::string&, ::Ice::Int);
+
+ virtual void endWriteSequence();
+
+ virtual void startWriteSequenceElement();
+
+ virtual void endWriteSequenceElement();
+
+ virtual ::Ice::Int startReadSequence(const ::std::string&);
+
+ virtual void endReadSequence();
+
+ virtual void startReadSequenceElement();
+
+ virtual void endReadSequenceElement();
+
+ virtual void startWriteStruct(const ::std::string&);
+
+ virtual void endWriteStruct();
+
+ virtual void startReadStruct(const ::std::string&);
+
+ virtual void endReadStruct();
+
+ virtual void startWriteException(const ::std::string&);
+
+ virtual void endWriteException();
+
+ virtual void startReadException(const ::std::string&);
+
+ virtual void endReadException();
+
+ virtual void writeEnum(const ::std::string&, const ::Ice::StringSeq&, ::Ice::Int);
+
+ virtual ::Ice::Int readEnum(const ::std::string&, const ::Ice::StringSeq&);
+
+ virtual void writeByte(const ::std::string&, ::Ice::Byte);
+
+ virtual void writeByteSeq(const ::std::string&, const ::Ice::ByteSeq&);
+
+ virtual ::Ice::Byte readByte(const ::std::string&);
+
+ virtual ::Ice::ByteSeq readByteSeq(const ::std::string&);
+
+ virtual void writeBool(const ::std::string&, bool);
+
+ virtual void writeBoolSeq(const ::std::string&, const ::Ice::BoolSeq&);
+
+ virtual bool readBool(const ::std::string&);
+
+ virtual ::Ice::BoolSeq readBoolSeq(const ::std::string&);
+
+ virtual void writeShort(const ::std::string&, ::Ice::Short);
+
+ virtual void writeShortSeq(const ::std::string&, const ::Ice::ShortSeq&);
+
+ virtual ::Ice::Short readShort(const ::std::string&);
+
+ virtual ::Ice::ShortSeq readShortSeq(const ::std::string&);
+
+ virtual void writeInt(const ::std::string&, ::Ice::Int);
+
+ virtual void writeIntSeq(const ::std::string&, const ::Ice::IntSeq&);
+
+ virtual ::Ice::Int readInt(const ::std::string&);
+
+ virtual ::Ice::IntSeq readIntSeq(const ::std::string&);
+
+ virtual void writeLong(const ::std::string&, ::Ice::Long);
+
+ virtual void writeLongSeq(const ::std::string&, const ::Ice::LongSeq&);
+
+ virtual ::Ice::Long readLong(const ::std::string&);
+
+ virtual ::Ice::LongSeq readLongSeq(const ::std::string&);
+
+ virtual void writeFloat(const ::std::string&, ::Ice::Float);
+
+ virtual void writeFloatSeq(const ::std::string&, const ::Ice::FloatSeq&);
+
+ virtual ::Ice::Float readFloat(const ::std::string&);
+
+ virtual ::Ice::FloatSeq readFloatSeq(const ::std::string&);
+
+ virtual void writeDouble(const ::std::string&, ::Ice::Double);
+
+ virtual void writeDoubleSeq(const ::std::string&, const ::Ice::DoubleSeq&);
+
+ virtual ::Ice::Double readDouble(const ::std::string&);
+
+ virtual ::Ice::DoubleSeq readDoubleSeq(const ::std::string&);
+
+ virtual void writeString(const ::std::string&, const ::std::string&);
+
+ virtual void writeStringSeq(const ::std::string&, const ::Ice::StringSeq&);
+
+ virtual ::std::string readString(const ::std::string&);
+
+ virtual ::Ice::StringSeq readStringSeq(const ::std::string&);
+
+ virtual void writeProxy(const ::std::string&, const ::Ice::ObjectPrx&);
+
+ virtual ::Ice::ObjectPrx readProxy(const ::std::string&);
+
+ virtual void writeObject(const ::std::string&, const ::Ice::ObjectPtr&);
+
+ virtual ::Ice::ObjectPtr readObject(const ::std::string&, const ::std::string&, const ::Ice::ObjectFactoryPtr&);
+
+private:
+
+ void startWrite(const std::string&);
+ void endWrite();
+
+ void startRead(const std::string&);
+ void endRead();
+
+ void dumpUnwrittenObjects();
+ void writeObjectData(const ::std::string&, const ::std::string&, const ::Ice::ObjectPtr&);
+ void readAttributes(::std::string&, ::std::string&, ::std::string&);
+ ::Ice::Int readLength();
+
+ ::Ice::CommunicatorPtr _communicator;
+
+ //
+ // Name of the sequence element name
+ //
+ static const ::std::string seqElementName;
+
+ //
+ // For reading.
+ //
+ ::std::string _content;
+ StreamInputImpl* _input;
+
+ //
+ // For writing.
+ //
+
+ //
+ // XML Output stream.
+ //
+ ::IceUtil::XMLOutput _os;
+
+ //
+ // Current document level.
+ //
+ int _level;
+
+ //
+ // Next id for marshaling objects.
+ //
+ int _nextId;
+ struct ObjectInfo
+ {
+ ObjectInfo(const ::std::string& i, bool w) :
+ id(i), written(w) { }
+ ::std::string id; // The id of the associated object
+ bool written; // Has the object been written?
+ };
+ ::std::map<Ice::ObjectPtr, ObjectInfo> _objects;
+};
+
+} // End namespace IceXML
+
+#endif
diff --git a/cpp/include/Slice/CPlusPlusUtil.h b/cpp/include/Slice/CPlusPlusUtil.h index fff635b57a9..fdacc2bf8db 100644 --- a/cpp/include/Slice/CPlusPlusUtil.h +++ b/cpp/include/Slice/CPlusPlusUtil.h @@ -1,54 +1,54 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef C_PLUS_PLUS_UTIL_H -#define C_PLUS_PLUS_UTIL_H - -#include <Slice/Parser.h> -#include <IceUtil/OutputUtil.h> - -namespace Slice -{ - -struct ToIfdef -{ - SLICE_API char operator()(char); -}; - -SLICE_API std::string changeInclude(const std::string&, const std::vector<std::string>&); -SLICE_API void printHeader(::IceUtil::Output&); -SLICE_API void printVersionCheck(::IceUtil::Output&); -SLICE_API void printDllExportStuff(::IceUtil::Output&, const std::string&); - -SLICE_API std::string typeToString(const TypePtr&); -SLICE_API std::string returnTypeToString(const TypePtr&); -SLICE_API std::string inputTypeToString(const TypePtr&); -SLICE_API std::string outputTypeToString(const TypePtr&); - -SLICE_API void writeMarshalUnmarshalCode(::IceUtil::Output&, const TypePtr&, const std::string&, bool, - const std::string& = "", bool = true); -SLICE_API void writeMarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); -SLICE_API void writeUnmarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); -SLICE_API void writeAllocateCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); - -SLICE_API void writeGenericMarshalUnmarshalCode(::IceUtil::Output&, const TypePtr&, const std::string&, bool, - const std::string& = "", const std::string& = "", bool = true); - -SLICE_API void writeGenericMarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); -SLICE_API void writeGenericUnmarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&, - const TypePtr&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef C_PLUS_PLUS_UTIL_H
+#define C_PLUS_PLUS_UTIL_H
+
+#include <Slice/Parser.h>
+#include <IceUtil/OutputUtil.h>
+
+namespace Slice
+{
+
+struct ToIfdef
+{
+ SLICE_API char operator()(char);
+};
+
+SLICE_API std::string changeInclude(const std::string&, const std::vector<std::string>&);
+SLICE_API void printHeader(::IceUtil::Output&);
+SLICE_API void printVersionCheck(::IceUtil::Output&);
+SLICE_API void printDllExportStuff(::IceUtil::Output&, const std::string&);
+
+SLICE_API std::string typeToString(const TypePtr&);
+SLICE_API std::string returnTypeToString(const TypePtr&);
+SLICE_API std::string inputTypeToString(const TypePtr&);
+SLICE_API std::string outputTypeToString(const TypePtr&);
+
+SLICE_API void writeMarshalUnmarshalCode(::IceUtil::Output&, const TypePtr&, const std::string&, bool,
+ const std::string& = "", bool = true);
+SLICE_API void writeMarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&,
+ const TypePtr&);
+SLICE_API void writeUnmarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&,
+ const TypePtr&);
+SLICE_API void writeAllocateCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&,
+ const TypePtr&);
+
+SLICE_API void writeGenericMarshalUnmarshalCode(::IceUtil::Output&, const TypePtr&, const std::string&, bool,
+ const std::string& = "", const std::string& = "", bool = true);
+
+SLICE_API void writeGenericMarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&,
+ const TypePtr&);
+SLICE_API void writeGenericUnmarshalCode(::IceUtil::Output&, const std::list<std::pair<TypePtr, std::string> >&,
+ const TypePtr&);
+
+}
+
+#endif
diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h index fb7a56c2ed1..c35be0909be 100644 --- a/cpp/include/Slice/JavaUtil.h +++ b/cpp/include/Slice/JavaUtil.h @@ -1,112 +1,112 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef JAVA_UTIL_H -#define JAVA_UTIL_H - -#include <Slice/Parser.h> -#include <IceUtil/OutputUtil.h> - -namespace Slice -{ - -class SLICE_API JavaGenerator : public ::IceUtil::noncopyable -{ -public: - - virtual ~JavaGenerator(); - -protected: - - JavaGenerator(const std::string&, const std::string&); - - // - // Given the fully-scoped Java class name, create any intermediate - // package directories and open the class file - // - bool open(const std::string&); - void close(); - - ::IceUtil::Output& output() const; - - // - // Check a symbol against any of the Java keywords. If a - // match is found, return the symbol with a leading underscore. - // - std::string fixKwd(const std::string&) const; - - // - // Convert a scoped name into a Java class name. If an optional - // scope is provided, the scope will be removed from the result. - // - std::string getAbsolute(const std::string&, - const std::string& = std::string(), - const std::string& = std::string(), - const std::string& = std::string()) const; - - // - // Get the Java name for a type. If an optional scope is provided, - // the scope will be removed from the result if possible. - // - enum TypeMode - { - TypeModeIn, - TypeModeOut, - TypeModeMember, - TypeModeReturn - }; - std::string typeToString(const TypePtr&, TypeMode mode, - const std::string& = std::string(), - const std::list<std::string>& = std::list<std::string>()) const; - - // - // Generate code to marshal or unmarshal a type - // - void writeMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const TypePtr&, const std::string&, - bool, int&, bool = false, const std::list<std::string>& = std::list<std::string>()); - - // - // Generate code to marshal or unmarshal a sequence type - // - void writeSequenceMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const SequencePtr&, - const std::string&, bool, int&, bool, - const std::list<std::string>& = std::list<std::string>()); - - // - // Generate generic code to marshal or unmarshal a type - // - void writeGenericMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const TypePtr&, - const std::string&, const std::string&, bool, int&, bool = false, - const std::list<std::string>& = std::list<std::string>()); - - // - // Generate generic code to marshal or unmarshal a sequence type - // - void writeGenericSequenceMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const SequencePtr&, - const std::string&, const std::string&, bool, int&, bool, - const std::list<std::string>& = std::list<std::string>()); - -protected: - - static std::string findMetaData(const std::list<std::string>&); - -private: - - void printHeader(); - - std::string _dir; - std::string _package; - - ::IceUtil::Output* _out; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef JAVA_UTIL_H
+#define JAVA_UTIL_H
+
+#include <Slice/Parser.h>
+#include <IceUtil/OutputUtil.h>
+
+namespace Slice
+{
+
+class SLICE_API JavaGenerator : public ::IceUtil::noncopyable
+{
+public:
+
+ virtual ~JavaGenerator();
+
+protected:
+
+ JavaGenerator(const std::string&, const std::string&);
+
+ //
+ // Given the fully-scoped Java class name, create any intermediate
+ // package directories and open the class file
+ //
+ bool open(const std::string&);
+ void close();
+
+ ::IceUtil::Output& output() const;
+
+ //
+ // Check a symbol against any of the Java keywords. If a
+ // match is found, return the symbol with a leading underscore.
+ //
+ std::string fixKwd(const std::string&) const;
+
+ //
+ // Convert a scoped name into a Java class name. If an optional
+ // scope is provided, the scope will be removed from the result.
+ //
+ std::string getAbsolute(const std::string&,
+ const std::string& = std::string(),
+ const std::string& = std::string(),
+ const std::string& = std::string()) const;
+
+ //
+ // Get the Java name for a type. If an optional scope is provided,
+ // the scope will be removed from the result if possible.
+ //
+ enum TypeMode
+ {
+ TypeModeIn,
+ TypeModeOut,
+ TypeModeMember,
+ TypeModeReturn
+ };
+ std::string typeToString(const TypePtr&, TypeMode mode,
+ const std::string& = std::string(),
+ const std::list<std::string>& = std::list<std::string>()) const;
+
+ //
+ // Generate code to marshal or unmarshal a type
+ //
+ void writeMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const TypePtr&, const std::string&,
+ bool, int&, bool = false, const std::list<std::string>& = std::list<std::string>());
+
+ //
+ // Generate code to marshal or unmarshal a sequence type
+ //
+ void writeSequenceMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const SequencePtr&,
+ const std::string&, bool, int&, bool,
+ const std::list<std::string>& = std::list<std::string>());
+
+ //
+ // Generate generic code to marshal or unmarshal a type
+ //
+ void writeGenericMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const TypePtr&,
+ const std::string&, const std::string&, bool, int&, bool = false,
+ const std::list<std::string>& = std::list<std::string>());
+
+ //
+ // Generate generic code to marshal or unmarshal a sequence type
+ //
+ void writeGenericSequenceMarshalUnmarshalCode(::IceUtil::Output&, const std::string&, const SequencePtr&,
+ const std::string&, const std::string&, bool, int&, bool,
+ const std::list<std::string>& = std::list<std::string>());
+
+protected:
+
+ static std::string findMetaData(const std::list<std::string>&);
+
+private:
+
+ void printHeader();
+
+ std::string _dir;
+ std::string _package;
+
+ ::IceUtil::Output* _out;
+};
+
+}
+
+#endif
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index 5330e294706..568c05fd288 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -1,711 +1,711 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SLICE_PARSER_H -#define SLICE_PARSER_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Handle.h> -#include <string> -#include <vector> -#include <list> -#include <stack> -#include <map> -#include <set> - -#ifdef _WIN32 -# ifdef SLICE_API_EXPORTS -# define SLICE_API __declspec(dllexport) -# else -# define SLICE_API __declspec(dllimport) -# endif -#else -# define SLICE_API /**/ -#endif - -namespace Slice -{ - -class GrammarBase; -class SyntaxTreeBase; -class Type; -class Builtin; -class Contained; -class Container; -class Module; -class Constructed; -class ClassDecl; -class ClassDef; -class Proxy; -class Exception; -class Struct; -class Operation; -class DataMember; -class Sequence; -class Dictionary; -class Enum; -class Enumerator; -class Unit; - -typedef ::IceUtil::Handle<GrammarBase> GrammarBasePtr; -typedef ::IceUtil::Handle<SyntaxTreeBase> SyntaxTreeBasePtr; -typedef ::IceUtil::Handle<Type> TypePtr; -typedef ::IceUtil::Handle<Builtin> BuiltinPtr; -typedef ::IceUtil::Handle<Contained> ContainedPtr; -typedef ::IceUtil::Handle<Container> ContainerPtr; -typedef ::IceUtil::Handle<Module> ModulePtr; -typedef ::IceUtil::Handle<Constructed> ConstructedPtr; -typedef ::IceUtil::Handle<ClassDecl> ClassDeclPtr; -typedef ::IceUtil::Handle<ClassDef> ClassDefPtr; -typedef ::IceUtil::Handle<Proxy> ProxyPtr; -typedef ::IceUtil::Handle<Exception> ExceptionPtr; -typedef ::IceUtil::Handle<Struct> StructPtr; -typedef ::IceUtil::Handle<Operation> OperationPtr; -typedef ::IceUtil::Handle<DataMember> DataMemberPtr; -typedef ::IceUtil::Handle<Sequence> SequencePtr; -typedef ::IceUtil::Handle<Dictionary> DictionaryPtr; -typedef ::IceUtil::Handle<Enum> EnumPtr; -typedef ::IceUtil::Handle<Enumerator> EnumeratorPtr; -typedef ::IceUtil::Handle<Unit> UnitPtr; - -} - -// -// Stuff for flex and bison -// - -#define YYSTYPE Slice::GrammarBasePtr -#define YY_DECL int yylex(YYSTYPE* yylvalp) -YY_DECL; -int yyparse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) yyerror(a) - -namespace Slice -{ - -typedef std::list<TypePtr> TypeList; -typedef std::list<ExceptionPtr> ExceptionList; -typedef std::list<std::string> StringList; -typedef std::pair<TypePtr, std::string> TypeString; -typedef std::list<TypeString> TypeStringList; -typedef std::list<ContainedPtr> ContainedList; -typedef std::list<ModulePtr> ModuleList; -typedef std::list<ConstructedPtr> ConstructedList; -typedef std::list<ClassDefPtr> ClassList; -typedef std::list<ExceptionPtr> ExceptionList; -typedef std::list<StructPtr> StructList; -typedef std::list<SequencePtr> SequenceList; -typedef std::list<DictionaryPtr> DictionaryList; -typedef std::list<EnumPtr> EnumList; -typedef std::list<OperationPtr> OperationList; -typedef std::list<DataMemberPtr> DataMemberList; -typedef std::list<EnumeratorPtr> EnumeratorList; - -// ---------------------------------------------------------------------- -// ParserVisitor -// ---------------------------------------------------------------------- - -class SLICE_API ParserVisitor -{ -public: - - virtual ~ParserVisitor() { } - virtual bool visitUnitStart(const UnitPtr&) { return true; } - virtual void visitUnitEnd(const UnitPtr&) { } - virtual bool visitModuleStart(const ModulePtr&) { return true; } - virtual void visitModuleEnd(const ModulePtr&) { } - virtual void visitClassDecl(const ClassDeclPtr&) { } - virtual bool visitClassDefStart(const ClassDefPtr&) { return true; } - virtual void visitClassDefEnd(const ClassDefPtr&) { } - virtual bool visitExceptionStart(const ExceptionPtr&) { return true; } - virtual void visitExceptionEnd(const ExceptionPtr&) { } - virtual bool visitStructStart(const StructPtr&) { return true; } - virtual void visitStructEnd(const StructPtr&) { } - virtual void visitOperation(const OperationPtr&) { } - virtual void visitDataMember(const DataMemberPtr&) { } - virtual void visitSequence(const SequencePtr&) { } - virtual void visitDictionary(const DictionaryPtr&) { } - virtual void visitEnum(const EnumPtr&) { } -}; - -// ---------------------------------------------------------------------- -// GrammarBase -// ---------------------------------------------------------------------- - -class SLICE_API GrammarBase : public ::IceUtil::SimpleShared -{ -}; - -// ---------------------------------------------------------------------- -// SyntaxTreeBase -// ---------------------------------------------------------------------- - -class SLICE_API SyntaxTreeBase : public GrammarBase -{ -public: - - virtual void destroy(); - UnitPtr unit(); - virtual void visit(ParserVisitor*); - -protected: - - SyntaxTreeBase(const UnitPtr&); - - UnitPtr _unit; -}; - -// ---------------------------------------------------------------------- -// Type -// ---------------------------------------------------------------------- - -class SLICE_API Type : virtual public SyntaxTreeBase -{ -public: - -protected: - - Type(const UnitPtr&); -}; - -// ---------------------------------------------------------------------- -// Builtin -// ---------------------------------------------------------------------- - -class SLICE_API Builtin : virtual public Type -{ -public: - - enum Kind - { - KindByte, - KindBool, - KindShort, - KindInt, - KindLong, - KindFloat, - KindDouble, - KindString, - KindObject, - KindObjectProxy, - KindLocalObject - }; - Kind kind(); - -protected: - - Builtin(const UnitPtr&, Kind); - friend class SLICE_API Unit; - - Kind _kind; -}; - -// ---------------------------------------------------------------------- -// Contained -// ---------------------------------------------------------------------- - -class SLICE_API Contained : virtual public SyntaxTreeBase -{ -public: - - ContainerPtr container(); - std::string name(); - std::string scoped(); - std::string scope(); - std::string file(); - std::string comment(); - - int includeLevel(); - void updateIncludeLevel(); - - std::list<std::string> getMetaData(); - void setMetaData(const std::list<std::string>&); - - enum ContainedType - { - ContainedTypeSequence, - ContainedTypeDictionary, - ContainedTypeEnum, - ContainedTypeEnumerator, - ContainedTypeModule, - ContainedTypeClass, - ContainedTypeException, - ContainedTypeStruct, - ContainedTypeOperation, - ContainedTypeDataMember - }; - virtual ContainedType containedType() = 0; - - virtual bool uses(const ContainedPtr&) = 0; - - bool operator<(const Contained&) const; - bool operator==(const Contained&) const; - -protected: - - Contained(const ContainerPtr&, const std::string&); - friend class SLICE_API Container; - - ContainerPtr _container; - std::string _name; - std::string _scoped; - std::string _file; - std::string _comment; - int _includeLevel; - std::list<std::string> _metaData; -}; - -// ---------------------------------------------------------------------- -// Container -// ---------------------------------------------------------------------- - -class SLICE_API Container : virtual public SyntaxTreeBase -{ -public: - - virtual void destroy(); - ModulePtr createModule(const std::string&); - ClassDefPtr createClassDef(const std::string&, bool, const ClassList&, bool); - ClassDeclPtr createClassDecl(const std::string&, bool, bool); - ExceptionPtr createException(const std::string&, const ExceptionPtr&, bool); - StructPtr createStruct(const std::string&, bool); - SequencePtr createSequence(const std::string&, const TypePtr&, bool); - DictionaryPtr createDictionary(const std::string&, const TypePtr&, const TypePtr&, bool); - EnumPtr createEnum(const std::string&, bool); - EnumeratorPtr createEnumerator(const std::string&); - TypeList lookupType(const std::string&, bool = true); - TypeList lookupTypeNoBuiltin(const std::string&, bool = true); - ContainedList lookupContained(const std::string&, bool = true); - ExceptionPtr lookupException(const std::string&, bool = true); - ModuleList modules(); - ClassList classes(); - ExceptionList exceptions(); - StructList structs(); - SequenceList sequences(); - DictionaryList dictionaries(); - EnumList enums(); - bool hasNonLocalClassDecls(); - bool hasClassDecls(); - bool hasClassDefs(); - bool hasOtherConstructedOrExceptions(); // Exceptions or constructed types other than classes. - std::string thisScope(); - void mergeModules(); - void sort(); - void sortContents(); - virtual void visit(ParserVisitor*); - void containerRecDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. - -protected: - - Container(const UnitPtr&); - - bool checkInterfaceAndLocal(const std::string&, bool, bool, bool, bool, bool); - - ContainedList _contents; -}; - -// ---------------------------------------------------------------------- -// Module -// ---------------------------------------------------------------------- - -class SLICE_API Module : virtual public Container, virtual public Contained -{ -public: - - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - -protected: - - Module(const ContainerPtr&, const std::string&); - friend class SLICE_API Container; -}; - -// ---------------------------------------------------------------------- -// Constructed -// ---------------------------------------------------------------------- - -class SLICE_API Constructed : virtual public Type, virtual public Contained -{ -public: - - bool isLocal(); - ConstructedList dependencies(); - virtual void recDependencies(std::set<ConstructedPtr>&) = 0; // Internal operation, don't use directly. - -protected: - - Constructed(const ContainerPtr&, const std::string&, bool); - - bool _local; -}; - -// ---------------------------------------------------------------------- -// ClassDecl -// ---------------------------------------------------------------------- - -class SLICE_API ClassDecl : virtual public Constructed -{ -public: - - virtual void destroy(); - ClassDefPtr definition(); - bool isInterface(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. - -protected: - - ClassDecl(const ContainerPtr&, const std::string&, bool, bool); - friend class SLICE_API Container; - friend class SLICE_API ClassDef; - - ClassDefPtr _definition; - bool _interface; -}; - -// ---------------------------------------------------------------------- -// ClassDef -// ---------------------------------------------------------------------- - -// -// Note: For the purpose of this parser, a class definition is not -// considered to be a type, but a class declaration is. And each class -// definition has at least one class declaration (but not vice versa), -// so if you need the class as a "constructed type", use the -// declaration() operation to navigate to the class declaration. -// -class SLICE_API ClassDef : virtual public Container, virtual public Contained -{ -public: - - virtual void destroy(); - OperationPtr createOperation(const std::string&, const TypePtr&, const TypeStringList&, const TypeStringList&, - const ExceptionList&); - DataMemberPtr createDataMember(const std::string&, const TypePtr&); - ClassDeclPtr declaration(); - ClassList bases(); - ClassList allBases(); - OperationList operations(); - OperationList allOperations(); - DataMemberList dataMembers(); - bool isAbstract(); - bool isInterface(); - bool isLocal(); - bool hasDataMembers(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - -protected: - - ClassDef(const ContainerPtr&, const std::string&, bool, const ClassList&, bool); - friend class SLICE_API Container; - - ClassDeclPtr _declaration; - bool _interface; - bool _hasDataMembers; - ClassList _bases; - bool _local; -}; - -// ---------------------------------------------------------------------- -// Proxy -// ---------------------------------------------------------------------- - -class SLICE_API Proxy : virtual public Type -{ -public: - - ClassDeclPtr _class(); - - Proxy(const ClassDeclPtr&); - -protected: - - ClassDeclPtr __class; -}; - -// ---------------------------------------------------------------------- -// Exception -// ---------------------------------------------------------------------- - -// No inheritance from Constructed, as this is not a Type -class SLICE_API Exception : virtual public Container, virtual public Contained -{ -public: - - virtual void destroy(); - DataMemberPtr createDataMember(const std::string&, const TypePtr&); - DataMemberList dataMembers(); - ExceptionPtr base(); - ExceptionList allBases(); - bool isLocal(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - -protected: - - Exception(const ContainerPtr&, const std::string&, const ExceptionPtr&, bool); - friend class SLICE_API Container; - - ExceptionPtr _base; - bool _local; -}; - -// ---------------------------------------------------------------------- -// Struct -// ---------------------------------------------------------------------- - -class SLICE_API Struct : virtual public Container, virtual public Constructed -{ -public: - - DataMemberPtr createDataMember(const std::string&, const TypePtr&); - DataMemberList dataMembers(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. - -protected: - - Struct(const ContainerPtr&, const std::string&, bool); - friend class SLICE_API Container; -}; - -// ---------------------------------------------------------------------- -// Sequence -// ---------------------------------------------------------------------- - -class SLICE_API Sequence : virtual public Constructed -{ -public: - - TypePtr type(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. - -protected: - - Sequence(const ContainerPtr&, const std::string&, const TypePtr&, bool); - friend class SLICE_API Container; - - TypePtr _type; -}; - -// ---------------------------------------------------------------------- -// Dictionary -// ---------------------------------------------------------------------- - -class SLICE_API Dictionary : virtual public Constructed -{ -public: - - TypePtr keyType(); - TypePtr valueType(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. - -protected: - - Dictionary(const ContainerPtr&, const std::string&, const TypePtr&, const TypePtr&, bool); - friend class SLICE_API Container; - - TypePtr _keyType; - TypePtr _valueType; -}; - -// ---------------------------------------------------------------------- -// Enum -// ---------------------------------------------------------------------- - -class SLICE_API Enum : virtual public Constructed -{ -public: - - EnumeratorList getEnumerators(); - void setEnumerators(const EnumeratorList&); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly. - -protected: - - Enum(const ContainerPtr&, const std::string&, bool); - friend class SLICE_API Container; - - EnumeratorList _enumerators; -}; - -// ---------------------------------------------------------------------- -// Enumerator -// ---------------------------------------------------------------------- - -class SLICE_API Enumerator : virtual public Contained -{ -public: - - virtual bool uses(const ContainedPtr&); - virtual ContainedType containedType(); - -protected: - - Enumerator(const ContainerPtr&, const std::string&); - friend class SLICE_API Container; -}; - -// ---------------------------------------------------------------------- -// Operation -// ---------------------------------------------------------------------- - -class SLICE_API Operation : virtual public Contained -{ -public: - - TypePtr returnType(); - TypeStringList inputParameters(); - TypeStringList outputParameters(); - ExceptionList throws(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - -protected: - - Operation(const ContainerPtr&, const std::string&, const TypePtr&, const TypeStringList&, const TypeStringList&, - const ExceptionList&); - friend class SLICE_API ClassDef; - - TypePtr _returnType; - TypeStringList _inParams; - TypeStringList _outParams; - ExceptionList _throws; -}; - -// ---------------------------------------------------------------------- -// DataMember -// ---------------------------------------------------------------------- - -class SLICE_API DataMember : virtual public Contained -{ -public: - - TypePtr type(); - virtual ContainedType containedType(); - virtual bool uses(const ContainedPtr&); - virtual void visit(ParserVisitor*); - -protected: - - DataMember(const ContainerPtr&, const std::string&, const TypePtr&); - friend class SLICE_API ClassDef; - friend class SLICE_API Struct; - friend class SLICE_API Exception; - - TypePtr _type; -}; - -// ---------------------------------------------------------------------- -// Unit -// ---------------------------------------------------------------------- - -class SLICE_API Unit : virtual public Container -{ -public: - - static UnitPtr createUnit(bool, bool); - - bool ignRedefs(); - - void setComment(const std::string&); - std::string currentComment(); - std::string currentFile(); - - void nextLine(); - void scanPosition(const char*); - int currentIncludeLevel(); - - void error(const char*); - void error(const std::string&); - - void warning(const char*); - void warning(const std::string&); - - ContainerPtr currentContainer(); - void pushContainer(const ContainerPtr&); - void popContainer(); - - void addContent(const ContainedPtr&); - void removeContent(const ContainedPtr&); - ContainedList findContents(const std::string&); - ClassList findDerivedClasses(const ClassDefPtr&); - ExceptionList findDerivedExceptions(const ExceptionPtr&); - ContainedList findUsedBy(const ContainedPtr&); - - bool usesProxies(); - bool usesNonLocals(); - - StringList includeFiles(); - - int parse(FILE*, bool); - - virtual void destroy(); - virtual void visit(ParserVisitor*); - - BuiltinPtr builtin(Builtin::Kind); - -private: - - Unit(bool, bool); - - bool _ignRedefs; - bool _all; - int _errors; - std::string _currentComment; - int _currentLine; - int _currentIncludeLevel; - std::string _currentFile; - std::string _topLevelFile; - StringList _includeFiles; - std::stack<ContainerPtr> _containerStack; - std::map<Builtin::Kind, BuiltinPtr> _builtins; - std::map<std::string, ContainedList > _contentMap; -}; - -extern SLICE_API Unit* unit; // The current parser for bison/flex - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SLICE_PARSER_H
+#define SLICE_PARSER_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Handle.h>
+#include <string>
+#include <vector>
+#include <list>
+#include <stack>
+#include <map>
+#include <set>
+
+#ifdef _WIN32
+# ifdef SLICE_API_EXPORTS
+# define SLICE_API __declspec(dllexport)
+# else
+# define SLICE_API __declspec(dllimport)
+# endif
+#else
+# define SLICE_API /**/
+#endif
+
+namespace Slice
+{
+
+class GrammarBase;
+class SyntaxTreeBase;
+class Type;
+class Builtin;
+class Contained;
+class Container;
+class Module;
+class Constructed;
+class ClassDecl;
+class ClassDef;
+class Proxy;
+class Exception;
+class Struct;
+class Operation;
+class DataMember;
+class Sequence;
+class Dictionary;
+class Enum;
+class Enumerator;
+class Unit;
+
+typedef ::IceUtil::Handle<GrammarBase> GrammarBasePtr;
+typedef ::IceUtil::Handle<SyntaxTreeBase> SyntaxTreeBasePtr;
+typedef ::IceUtil::Handle<Type> TypePtr;
+typedef ::IceUtil::Handle<Builtin> BuiltinPtr;
+typedef ::IceUtil::Handle<Contained> ContainedPtr;
+typedef ::IceUtil::Handle<Container> ContainerPtr;
+typedef ::IceUtil::Handle<Module> ModulePtr;
+typedef ::IceUtil::Handle<Constructed> ConstructedPtr;
+typedef ::IceUtil::Handle<ClassDecl> ClassDeclPtr;
+typedef ::IceUtil::Handle<ClassDef> ClassDefPtr;
+typedef ::IceUtil::Handle<Proxy> ProxyPtr;
+typedef ::IceUtil::Handle<Exception> ExceptionPtr;
+typedef ::IceUtil::Handle<Struct> StructPtr;
+typedef ::IceUtil::Handle<Operation> OperationPtr;
+typedef ::IceUtil::Handle<DataMember> DataMemberPtr;
+typedef ::IceUtil::Handle<Sequence> SequencePtr;
+typedef ::IceUtil::Handle<Dictionary> DictionaryPtr;
+typedef ::IceUtil::Handle<Enum> EnumPtr;
+typedef ::IceUtil::Handle<Enumerator> EnumeratorPtr;
+typedef ::IceUtil::Handle<Unit> UnitPtr;
+
+}
+
+//
+// Stuff for flex and bison
+//
+
+#define YYSTYPE Slice::GrammarBasePtr
+#define YY_DECL int yylex(YYSTYPE* yylvalp)
+YY_DECL;
+int yyparse();
+
+//
+// I must set the initial stack depth to the maximum stack depth to
+// disable bison stack resizing. The bison stack resizing routines use
+// simple malloc/alloc/memcpy calls, which do not work for the
+// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
+// assignment operator, etc.
+//
+#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum.
+#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
+
+//
+// Newer bison versions allow to disable stack resizing by defining
+// yyoverflow.
+//
+#define yyoverflow(a, b, c, d, e, f) yyerror(a)
+
+namespace Slice
+{
+
+typedef std::list<TypePtr> TypeList;
+typedef std::list<ExceptionPtr> ExceptionList;
+typedef std::list<std::string> StringList;
+typedef std::pair<TypePtr, std::string> TypeString;
+typedef std::list<TypeString> TypeStringList;
+typedef std::list<ContainedPtr> ContainedList;
+typedef std::list<ModulePtr> ModuleList;
+typedef std::list<ConstructedPtr> ConstructedList;
+typedef std::list<ClassDefPtr> ClassList;
+typedef std::list<ExceptionPtr> ExceptionList;
+typedef std::list<StructPtr> StructList;
+typedef std::list<SequencePtr> SequenceList;
+typedef std::list<DictionaryPtr> DictionaryList;
+typedef std::list<EnumPtr> EnumList;
+typedef std::list<OperationPtr> OperationList;
+typedef std::list<DataMemberPtr> DataMemberList;
+typedef std::list<EnumeratorPtr> EnumeratorList;
+
+// ----------------------------------------------------------------------
+// ParserVisitor
+// ----------------------------------------------------------------------
+
+class SLICE_API ParserVisitor
+{
+public:
+
+ virtual ~ParserVisitor() { }
+ virtual bool visitUnitStart(const UnitPtr&) { return true; }
+ virtual void visitUnitEnd(const UnitPtr&) { }
+ virtual bool visitModuleStart(const ModulePtr&) { return true; }
+ virtual void visitModuleEnd(const ModulePtr&) { }
+ virtual void visitClassDecl(const ClassDeclPtr&) { }
+ virtual bool visitClassDefStart(const ClassDefPtr&) { return true; }
+ virtual void visitClassDefEnd(const ClassDefPtr&) { }
+ virtual bool visitExceptionStart(const ExceptionPtr&) { return true; }
+ virtual void visitExceptionEnd(const ExceptionPtr&) { }
+ virtual bool visitStructStart(const StructPtr&) { return true; }
+ virtual void visitStructEnd(const StructPtr&) { }
+ virtual void visitOperation(const OperationPtr&) { }
+ virtual void visitDataMember(const DataMemberPtr&) { }
+ virtual void visitSequence(const SequencePtr&) { }
+ virtual void visitDictionary(const DictionaryPtr&) { }
+ virtual void visitEnum(const EnumPtr&) { }
+};
+
+// ----------------------------------------------------------------------
+// GrammarBase
+// ----------------------------------------------------------------------
+
+class SLICE_API GrammarBase : public ::IceUtil::SimpleShared
+{
+};
+
+// ----------------------------------------------------------------------
+// SyntaxTreeBase
+// ----------------------------------------------------------------------
+
+class SLICE_API SyntaxTreeBase : public GrammarBase
+{
+public:
+
+ virtual void destroy();
+ UnitPtr unit();
+ virtual void visit(ParserVisitor*);
+
+protected:
+
+ SyntaxTreeBase(const UnitPtr&);
+
+ UnitPtr _unit;
+};
+
+// ----------------------------------------------------------------------
+// Type
+// ----------------------------------------------------------------------
+
+class SLICE_API Type : virtual public SyntaxTreeBase
+{
+public:
+
+protected:
+
+ Type(const UnitPtr&);
+};
+
+// ----------------------------------------------------------------------
+// Builtin
+// ----------------------------------------------------------------------
+
+class SLICE_API Builtin : virtual public Type
+{
+public:
+
+ enum Kind
+ {
+ KindByte,
+ KindBool,
+ KindShort,
+ KindInt,
+ KindLong,
+ KindFloat,
+ KindDouble,
+ KindString,
+ KindObject,
+ KindObjectProxy,
+ KindLocalObject
+ };
+ Kind kind();
+
+protected:
+
+ Builtin(const UnitPtr&, Kind);
+ friend class SLICE_API Unit;
+
+ Kind _kind;
+};
+
+// ----------------------------------------------------------------------
+// Contained
+// ----------------------------------------------------------------------
+
+class SLICE_API Contained : virtual public SyntaxTreeBase
+{
+public:
+
+ ContainerPtr container();
+ std::string name();
+ std::string scoped();
+ std::string scope();
+ std::string file();
+ std::string comment();
+
+ int includeLevel();
+ void updateIncludeLevel();
+
+ std::list<std::string> getMetaData();
+ void setMetaData(const std::list<std::string>&);
+
+ enum ContainedType
+ {
+ ContainedTypeSequence,
+ ContainedTypeDictionary,
+ ContainedTypeEnum,
+ ContainedTypeEnumerator,
+ ContainedTypeModule,
+ ContainedTypeClass,
+ ContainedTypeException,
+ ContainedTypeStruct,
+ ContainedTypeOperation,
+ ContainedTypeDataMember
+ };
+ virtual ContainedType containedType() = 0;
+
+ virtual bool uses(const ContainedPtr&) = 0;
+
+ bool operator<(const Contained&) const;
+ bool operator==(const Contained&) const;
+
+protected:
+
+ Contained(const ContainerPtr&, const std::string&);
+ friend class SLICE_API Container;
+
+ ContainerPtr _container;
+ std::string _name;
+ std::string _scoped;
+ std::string _file;
+ std::string _comment;
+ int _includeLevel;
+ std::list<std::string> _metaData;
+};
+
+// ----------------------------------------------------------------------
+// Container
+// ----------------------------------------------------------------------
+
+class SLICE_API Container : virtual public SyntaxTreeBase
+{
+public:
+
+ virtual void destroy();
+ ModulePtr createModule(const std::string&);
+ ClassDefPtr createClassDef(const std::string&, bool, const ClassList&, bool);
+ ClassDeclPtr createClassDecl(const std::string&, bool, bool);
+ ExceptionPtr createException(const std::string&, const ExceptionPtr&, bool);
+ StructPtr createStruct(const std::string&, bool);
+ SequencePtr createSequence(const std::string&, const TypePtr&, bool);
+ DictionaryPtr createDictionary(const std::string&, const TypePtr&, const TypePtr&, bool);
+ EnumPtr createEnum(const std::string&, bool);
+ EnumeratorPtr createEnumerator(const std::string&);
+ TypeList lookupType(const std::string&, bool = true);
+ TypeList lookupTypeNoBuiltin(const std::string&, bool = true);
+ ContainedList lookupContained(const std::string&, bool = true);
+ ExceptionPtr lookupException(const std::string&, bool = true);
+ ModuleList modules();
+ ClassList classes();
+ ExceptionList exceptions();
+ StructList structs();
+ SequenceList sequences();
+ DictionaryList dictionaries();
+ EnumList enums();
+ bool hasNonLocalClassDecls();
+ bool hasClassDecls();
+ bool hasClassDefs();
+ bool hasOtherConstructedOrExceptions(); // Exceptions or constructed types other than classes.
+ std::string thisScope();
+ void mergeModules();
+ void sort();
+ void sortContents();
+ virtual void visit(ParserVisitor*);
+ void containerRecDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly.
+
+protected:
+
+ Container(const UnitPtr&);
+
+ bool checkInterfaceAndLocal(const std::string&, bool, bool, bool, bool, bool);
+
+ ContainedList _contents;
+};
+
+// ----------------------------------------------------------------------
+// Module
+// ----------------------------------------------------------------------
+
+class SLICE_API Module : virtual public Container, virtual public Contained
+{
+public:
+
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+
+protected:
+
+ Module(const ContainerPtr&, const std::string&);
+ friend class SLICE_API Container;
+};
+
+// ----------------------------------------------------------------------
+// Constructed
+// ----------------------------------------------------------------------
+
+class SLICE_API Constructed : virtual public Type, virtual public Contained
+{
+public:
+
+ bool isLocal();
+ ConstructedList dependencies();
+ virtual void recDependencies(std::set<ConstructedPtr>&) = 0; // Internal operation, don't use directly.
+
+protected:
+
+ Constructed(const ContainerPtr&, const std::string&, bool);
+
+ bool _local;
+};
+
+// ----------------------------------------------------------------------
+// ClassDecl
+// ----------------------------------------------------------------------
+
+class SLICE_API ClassDecl : virtual public Constructed
+{
+public:
+
+ virtual void destroy();
+ ClassDefPtr definition();
+ bool isInterface();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+ virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly.
+
+protected:
+
+ ClassDecl(const ContainerPtr&, const std::string&, bool, bool);
+ friend class SLICE_API Container;
+ friend class SLICE_API ClassDef;
+
+ ClassDefPtr _definition;
+ bool _interface;
+};
+
+// ----------------------------------------------------------------------
+// ClassDef
+// ----------------------------------------------------------------------
+
+//
+// Note: For the purpose of this parser, a class definition is not
+// considered to be a type, but a class declaration is. And each class
+// definition has at least one class declaration (but not vice versa),
+// so if you need the class as a "constructed type", use the
+// declaration() operation to navigate to the class declaration.
+//
+class SLICE_API ClassDef : virtual public Container, virtual public Contained
+{
+public:
+
+ virtual void destroy();
+ OperationPtr createOperation(const std::string&, const TypePtr&, const TypeStringList&, const TypeStringList&,
+ const ExceptionList&);
+ DataMemberPtr createDataMember(const std::string&, const TypePtr&);
+ ClassDeclPtr declaration();
+ ClassList bases();
+ ClassList allBases();
+ OperationList operations();
+ OperationList allOperations();
+ DataMemberList dataMembers();
+ bool isAbstract();
+ bool isInterface();
+ bool isLocal();
+ bool hasDataMembers();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+
+protected:
+
+ ClassDef(const ContainerPtr&, const std::string&, bool, const ClassList&, bool);
+ friend class SLICE_API Container;
+
+ ClassDeclPtr _declaration;
+ bool _interface;
+ bool _hasDataMembers;
+ ClassList _bases;
+ bool _local;
+};
+
+// ----------------------------------------------------------------------
+// Proxy
+// ----------------------------------------------------------------------
+
+class SLICE_API Proxy : virtual public Type
+{
+public:
+
+ ClassDeclPtr _class();
+
+ Proxy(const ClassDeclPtr&);
+
+protected:
+
+ ClassDeclPtr __class;
+};
+
+// ----------------------------------------------------------------------
+// Exception
+// ----------------------------------------------------------------------
+
+// No inheritance from Constructed, as this is not a Type
+class SLICE_API Exception : virtual public Container, virtual public Contained
+{
+public:
+
+ virtual void destroy();
+ DataMemberPtr createDataMember(const std::string&, const TypePtr&);
+ DataMemberList dataMembers();
+ ExceptionPtr base();
+ ExceptionList allBases();
+ bool isLocal();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+
+protected:
+
+ Exception(const ContainerPtr&, const std::string&, const ExceptionPtr&, bool);
+ friend class SLICE_API Container;
+
+ ExceptionPtr _base;
+ bool _local;
+};
+
+// ----------------------------------------------------------------------
+// Struct
+// ----------------------------------------------------------------------
+
+class SLICE_API Struct : virtual public Container, virtual public Constructed
+{
+public:
+
+ DataMemberPtr createDataMember(const std::string&, const TypePtr&);
+ DataMemberList dataMembers();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+ virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly.
+
+protected:
+
+ Struct(const ContainerPtr&, const std::string&, bool);
+ friend class SLICE_API Container;
+};
+
+// ----------------------------------------------------------------------
+// Sequence
+// ----------------------------------------------------------------------
+
+class SLICE_API Sequence : virtual public Constructed
+{
+public:
+
+ TypePtr type();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+ virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly.
+
+protected:
+
+ Sequence(const ContainerPtr&, const std::string&, const TypePtr&, bool);
+ friend class SLICE_API Container;
+
+ TypePtr _type;
+};
+
+// ----------------------------------------------------------------------
+// Dictionary
+// ----------------------------------------------------------------------
+
+class SLICE_API Dictionary : virtual public Constructed
+{
+public:
+
+ TypePtr keyType();
+ TypePtr valueType();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+ virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly.
+
+protected:
+
+ Dictionary(const ContainerPtr&, const std::string&, const TypePtr&, const TypePtr&, bool);
+ friend class SLICE_API Container;
+
+ TypePtr _keyType;
+ TypePtr _valueType;
+};
+
+// ----------------------------------------------------------------------
+// Enum
+// ----------------------------------------------------------------------
+
+class SLICE_API Enum : virtual public Constructed
+{
+public:
+
+ EnumeratorList getEnumerators();
+ void setEnumerators(const EnumeratorList&);
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+ virtual void recDependencies(std::set<ConstructedPtr>&); // Internal operation, don't use directly.
+
+protected:
+
+ Enum(const ContainerPtr&, const std::string&, bool);
+ friend class SLICE_API Container;
+
+ EnumeratorList _enumerators;
+};
+
+// ----------------------------------------------------------------------
+// Enumerator
+// ----------------------------------------------------------------------
+
+class SLICE_API Enumerator : virtual public Contained
+{
+public:
+
+ virtual bool uses(const ContainedPtr&);
+ virtual ContainedType containedType();
+
+protected:
+
+ Enumerator(const ContainerPtr&, const std::string&);
+ friend class SLICE_API Container;
+};
+
+// ----------------------------------------------------------------------
+// Operation
+// ----------------------------------------------------------------------
+
+class SLICE_API Operation : virtual public Contained
+{
+public:
+
+ TypePtr returnType();
+ TypeStringList inputParameters();
+ TypeStringList outputParameters();
+ ExceptionList throws();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+
+protected:
+
+ Operation(const ContainerPtr&, const std::string&, const TypePtr&, const TypeStringList&, const TypeStringList&,
+ const ExceptionList&);
+ friend class SLICE_API ClassDef;
+
+ TypePtr _returnType;
+ TypeStringList _inParams;
+ TypeStringList _outParams;
+ ExceptionList _throws;
+};
+
+// ----------------------------------------------------------------------
+// DataMember
+// ----------------------------------------------------------------------
+
+class SLICE_API DataMember : virtual public Contained
+{
+public:
+
+ TypePtr type();
+ virtual ContainedType containedType();
+ virtual bool uses(const ContainedPtr&);
+ virtual void visit(ParserVisitor*);
+
+protected:
+
+ DataMember(const ContainerPtr&, const std::string&, const TypePtr&);
+ friend class SLICE_API ClassDef;
+ friend class SLICE_API Struct;
+ friend class SLICE_API Exception;
+
+ TypePtr _type;
+};
+
+// ----------------------------------------------------------------------
+// Unit
+// ----------------------------------------------------------------------
+
+class SLICE_API Unit : virtual public Container
+{
+public:
+
+ static UnitPtr createUnit(bool, bool);
+
+ bool ignRedefs();
+
+ void setComment(const std::string&);
+ std::string currentComment();
+ std::string currentFile();
+
+ void nextLine();
+ void scanPosition(const char*);
+ int currentIncludeLevel();
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void warning(const char*);
+ void warning(const std::string&);
+
+ ContainerPtr currentContainer();
+ void pushContainer(const ContainerPtr&);
+ void popContainer();
+
+ void addContent(const ContainedPtr&);
+ void removeContent(const ContainedPtr&);
+ ContainedList findContents(const std::string&);
+ ClassList findDerivedClasses(const ClassDefPtr&);
+ ExceptionList findDerivedExceptions(const ExceptionPtr&);
+ ContainedList findUsedBy(const ContainedPtr&);
+
+ bool usesProxies();
+ bool usesNonLocals();
+
+ StringList includeFiles();
+
+ int parse(FILE*, bool);
+
+ virtual void destroy();
+ virtual void visit(ParserVisitor*);
+
+ BuiltinPtr builtin(Builtin::Kind);
+
+private:
+
+ Unit(bool, bool);
+
+ bool _ignRedefs;
+ bool _all;
+ int _errors;
+ std::string _currentComment;
+ int _currentLine;
+ int _currentIncludeLevel;
+ std::string _currentFile;
+ std::string _topLevelFile;
+ StringList _includeFiles;
+ std::stack<ContainerPtr> _containerStack;
+ std::map<Builtin::Kind, BuiltinPtr> _builtins;
+ std::map<std::string, ContainedList > _contentMap;
+};
+
+extern SLICE_API Unit* unit; // The current parser for bison/flex
+
+}
+
+#endif
diff --git a/cpp/src/Freeze/Application.cpp b/cpp/src/Freeze/Application.cpp index c3088794a2b..807cd9c0449 100644 --- a/cpp/src/Freeze/Application.cpp +++ b/cpp/src/Freeze/Application.cpp @@ -53,7 +53,7 @@ Freeze::Application::run(int argc, char* argv[]) status = EXIT_FAILURE; } - if (dbEnv) + if(dbEnv) { try { diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index 9e4b725b936..702814c3fd2 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -28,7 +28,7 @@ using namespace Freeze; void Freeze::checkBerkeleyDBReturn(int ret, const string& prefix, const string& op) { - if (ret == 0) + if(ret == 0) { return; // Everything ok } @@ -36,7 +36,7 @@ Freeze::checkBerkeleyDBReturn(int ret, const string& prefix, const string& op) ostringstream s; s << prefix << op << ": " << db_strerror(ret); - switch (ret) + switch(ret) { case DB_LOCK_DEADLOCK: { @@ -71,7 +71,7 @@ Freeze::DBEnvironmentI::DBEnvironmentI(const CommunicatorPtr& communicator, cons _errorPrefix = "Freeze::DBEnvironment(\"" + _name + "\"): "; _trace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.DB"); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "opening database environment \"" << _name << "\""; @@ -91,7 +91,7 @@ Freeze::DBEnvironmentI::DBEnvironmentI(const CommunicatorPtr& communicator, cons Freeze::DBEnvironmentI::~DBEnvironmentI() { - if (_dbEnv) + if(_dbEnv) { Warning out(_communicator->getLogger()); out << _errorPrefix << "\"" << _name << "\" has not been closed"; @@ -117,7 +117,7 @@ Freeze::DBEnvironmentI::openDB(const string& name, bool create) { IceUtil::RecMutex::Lock sync(*this); - if (!_dbEnv) + if(!_dbEnv) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -127,7 +127,7 @@ Freeze::DBEnvironmentI::openDB(const string& name, bool create) } map<string, DBPtr>::iterator p = _dbMap.find(name); - if (p != _dbMap.end()) + if(p != _dbMap.end()) { return p->second; } @@ -146,7 +146,7 @@ Freeze::DBEnvironmentI::openDB(const string& name, bool create) // errors. // p = _dbMap.find(name); - if (p != _dbMap.end()) + if(p != _dbMap.end()) { _dbMap.erase(p); } @@ -168,7 +168,7 @@ Freeze::DBEnvironmentI::close() { IceUtil::RecMutex::Lock sync(*this); - if (!_dbEnv) + if(!_dbEnv) { return; } @@ -179,7 +179,7 @@ Freeze::DBEnvironmentI::close() db->close(); } - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "closing database environment \"" << _name << "\""; @@ -241,7 +241,7 @@ Freeze::DBTransactionI::DBTransactionI(const CommunicatorPtr& communicator, ::DB _errorPrefix = "Freeze::DBTransaction(\"" + _name + "\"): "; _trace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.DB"); - if (_trace >= 2) + if(_trace >= 2) { Trace out(_communicator->getLogger(), "DB"); out << "starting transaction for environment \"" << _name << "\""; @@ -252,7 +252,7 @@ Freeze::DBTransactionI::DBTransactionI(const CommunicatorPtr& communicator, ::DB Freeze::DBTransactionI::~DBTransactionI() { - if (_tid) + if(_tid) { Warning out(_communicator->getLogger()); out << _errorPrefix << "transaction has not been committed or aborted"; @@ -264,7 +264,7 @@ Freeze::DBTransactionI::commit() { IceUtil::Mutex::Lock sync(*this); - if (!_tid) + if(!_tid) { ostringstream s; s << _errorPrefix << "transaction has already been committed or aborted"; @@ -273,7 +273,7 @@ Freeze::DBTransactionI::commit() throw ex; } - if (_trace >= 2) + if(_trace >= 2) { Trace out(_communicator->getLogger(), "DB"); out << "committing transaction for environment \"" << _name << "\""; @@ -289,7 +289,7 @@ Freeze::DBTransactionI::abort() { IceUtil::Mutex::Lock sync(*this); - if (!_tid) + if(!_tid) { ostringstream s; s << _errorPrefix << "transaction has already been committed or aborted"; @@ -298,7 +298,7 @@ Freeze::DBTransactionI::abort() throw ex; } - if (_trace >= 2) + if(_trace >= 2) { Trace out(_communicator->getLogger(), "DB"); out << "aborting transaction for environment \"" << _name << "\" due to deadlock"; @@ -318,7 +318,7 @@ DBCursorI::DBCursorI(const ::Ice::CommunicatorPtr& communicator, const std::stri _errorPrefix = "Freeze::DBCursor(\"" + _name += "\"): "; _trace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.DB"); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "creating cursor for \"" << _name << "\""; @@ -327,7 +327,7 @@ DBCursorI::DBCursorI(const ::Ice::CommunicatorPtr& communicator, const std::stri DBCursorI::~DBCursorI() { - if (_cursor != 0) + if(_cursor != 0) { Warning out(_communicator->getLogger()); out << _errorPrefix << "\"" << _name << "\" has not been closed"; @@ -346,7 +346,7 @@ DBCursorI::curr(Key& key, Value& value) { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -359,7 +359,7 @@ DBCursorI::curr(Key& key, Value& value) memset(&dbKey, 0, sizeof(dbKey)); memset(&dbData, 0, sizeof(dbData)); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "reading current value from database \"" << _name << "\""; @@ -379,7 +379,7 @@ DBCursorI::set(const Value& value) { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -394,7 +394,7 @@ DBCursorI::set(const Value& value) dbData.data = const_cast<void*>(static_cast<const void*>(&value[0])); dbData.size = value.size(); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "setting current value in database \"" << _name << "\""; @@ -411,7 +411,7 @@ DBCursorI::next() { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -430,7 +430,7 @@ DBCursorI::next() memset(&dbData, 0, sizeof(dbData)); dbData.flags = DB_DBT_PARTIAL; - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "moving to next value in database \"" << _name << "\""; @@ -452,7 +452,7 @@ DBCursorI::prev() { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -471,7 +471,7 @@ DBCursorI::prev() memset(&dbData, 0, sizeof(dbData)); dbData.flags = DB_DBT_PARTIAL; - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "moving to previous value in database \"" << _name << "\""; @@ -493,7 +493,7 @@ DBCursorI::del() { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -502,7 +502,7 @@ DBCursorI::del() throw ex; } - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "removing the current element in database \"" << _name << "\""; @@ -516,7 +516,7 @@ DBCursorI::clone() { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -535,12 +535,12 @@ DBCursorI::close() { IceUtil::Mutex::Lock sync(*this); - if (!_cursor) + if(!_cursor) { return; } - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "closing cursor \"" << _name << "\""; @@ -561,7 +561,7 @@ Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& d _errorPrefix = "Freeze::DB(\"" + _name + "\"): "; _trace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.DB"); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "opening database \"" << _name << "\" in environment \"" << _dbEnvObj->getName() << "\""; @@ -576,7 +576,7 @@ Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& d Freeze::DBI::~DBI() { - if (_db) + if(_db) { Warning out(_communicator->getLogger()); out << _errorPrefix << "\"" << _name << "\" has not been closed"; @@ -602,7 +602,7 @@ Freeze::DBI::getNumberOfRecords() { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -626,7 +626,7 @@ Freeze::DBI::getCursor() { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -671,7 +671,7 @@ Freeze::DBI::getCursorAtKey(const Key& key) { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -722,7 +722,7 @@ Freeze::DBI::put(const Key& key, const Value& value) { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -739,7 +739,7 @@ Freeze::DBI::put(const Key& key, const Value& value) dbData.data = const_cast<void*>(static_cast<const void*>(&value[0])); dbData.size = value.size(); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "writing value in database \"" << _name << "\""; @@ -753,7 +753,7 @@ Freeze::DBI::contains(const Key& key) { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -771,14 +771,14 @@ Freeze::DBI::contains(const Key& key) memset(&dbData, 0, sizeof(dbData)); dbData.flags = DB_DBT_PARTIAL; - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "checking key in database \"" << _name << "\""; } int rc = _db->get(_db, 0, &dbKey, &dbData, 0); - if (rc == DB_NOTFOUND) + if(rc == DB_NOTFOUND) { return false; } @@ -792,7 +792,7 @@ Freeze::DBI::get(const Key& key) { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -807,7 +807,7 @@ Freeze::DBI::get(const Key& key) dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); dbKey.size = key.size(); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "reading value from database \"" << _name << "\""; @@ -823,7 +823,7 @@ Freeze::DBI::del(const Key& key) { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -837,7 +837,7 @@ Freeze::DBI::del(const Key& key) dbKey.data = const_cast<void*>(static_cast<const void*>(&key[0])); dbKey.size = key.size(); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "deleting value from database \"" << _name << "\""; @@ -851,7 +851,7 @@ Freeze::DBI::clear() { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; @@ -869,12 +869,12 @@ Freeze::DBI::close() { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { return; } - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "closing database \"" << _name << "\""; @@ -892,12 +892,12 @@ Freeze::DBI::remove() { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { return; } - if (_trace >= 1) + if(_trace >= 1) { Trace out(_communicator->getLogger(), "DB"); out << "removing database \"" << _name << "\""; @@ -929,7 +929,7 @@ Freeze::DBI::createEvictor(EvictorPersistenceMode persistenceMode) { IceUtil::Mutex::Lock sync(*this); - if (!_db) + if(!_db) { ostringstream s; s << _errorPrefix << "\"" << _name << "\" has been closed"; diff --git a/cpp/src/Freeze/DBI.h b/cpp/src/Freeze/DBI.h index 448a7dfa680..7014a7f623a 100644 --- a/cpp/src/Freeze/DBI.h +++ b/cpp/src/Freeze/DBI.h @@ -1,157 +1,157 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FREEZE_DB_I_H -#define FREEZE_DB_I_H - -#include <IceUtil/IceUtil.h> -#include <Ice/Ice.h> -#include <Freeze/DB.h> -#include <db.h> - -namespace Freeze -{ - -// -// Check a Berkeley DB return result, and throw an apropriate -// exception. -// -void checkBerkeleyDBReturn(int ret, const std::string&, const std::string&); - -class DBEnvironmentI; -typedef IceUtil::Handle<DBEnvironmentI> DBEnvironmentIPtr; - -class DBEnvironmentI : public DBEnvironment, public IceUtil::RecMutex -{ -public: - - DBEnvironmentI(const ::Ice::CommunicatorPtr&, const std::string&); - virtual ~DBEnvironmentI(); - - virtual std::string getName(); - virtual ::Ice::CommunicatorPtr getCommunicator(); - - virtual DBPtr openDB(const std::string&, bool); - - virtual DBTransactionPtr startTransaction(); - - virtual void close(); - -private: - - // DBI needs access to add, remove & eraseDB - friend class DBI; - void add(const std::string&, const DBPtr&); - void remove(const std::string&); - void eraseDB(const std::string&); - - ::Ice::CommunicatorPtr _communicator; - int _trace; - - ::DB_ENV* _dbEnv; - - std::string _name; - std::string _errorPrefix; - - std::map<std::string, DBPtr> _dbMap; -}; - -class DBTransactionI : public DBTransaction, public IceUtil::Mutex -{ -public: - - DBTransactionI(const ::Ice::CommunicatorPtr&, ::DB_ENV*, const std::string&); - virtual ~DBTransactionI(); - - virtual void commit(); - virtual void abort(); - -private: - - ::Ice::CommunicatorPtr _communicator; - int _trace; - - ::DB_TXN* _tid; - - std::string _name; - std::string _errorPrefix; -}; - -class DBCursorI : public DBCursor, public IceUtil::Mutex -{ -public: - - DBCursorI(const ::Ice::CommunicatorPtr&, const std::string&, DBC*); - ~DBCursorI(); - - virtual ::Ice::CommunicatorPtr getCommunicator(); - - virtual void curr(Key& key, Value& value); - virtual void set(const Value& value); - virtual bool next(); - virtual bool prev(); - virtual void del(); - - virtual DBCursorPtr clone(); - virtual void close(); - -private: - - ::Ice::CommunicatorPtr _communicator; - int _trace; - - std::string _name; - std::string _errorPrefix; - - DBC* _cursor; -}; - -class DBI : public DB, public IceUtil::Mutex -{ -public: - - DBI(const ::Ice::CommunicatorPtr&, const DBEnvironmentIPtr&, ::DB*, const std::string&, bool); - virtual ~DBI(); - - virtual std::string getName(); - virtual ::Ice::CommunicatorPtr getCommunicator(); - - virtual ::Ice::Long getNumberOfRecords(); - - virtual DBCursorPtr getCursor(); - virtual DBCursorPtr getCursorAtKey(const Key&); - - virtual void put(const Key&, const Value&); - virtual bool contains(const Key&); - virtual Value get(const Key&); - virtual void del(const Key&); - - virtual void clear(); - - virtual void close(); - virtual void remove(); - - virtual EvictorPtr createEvictor(EvictorPersistenceMode); - -private: - - ::Ice::CommunicatorPtr _communicator; - int _trace; - - DBEnvironmentIPtr _dbEnvObj; - ::DB* _db; - - std::string _name; - std::string _errorPrefix; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FREEZE_DB_I_H
+#define FREEZE_DB_I_H
+
+#include <IceUtil/IceUtil.h>
+#include <Ice/Ice.h>
+#include <Freeze/DB.h>
+#include <db.h>
+
+namespace Freeze
+{
+
+//
+// Check a Berkeley DB return result, and throw an apropriate
+// exception.
+//
+void checkBerkeleyDBReturn(int ret, const std::string&, const std::string&);
+
+class DBEnvironmentI;
+typedef IceUtil::Handle<DBEnvironmentI> DBEnvironmentIPtr;
+
+class DBEnvironmentI : public DBEnvironment, public IceUtil::RecMutex
+{
+public:
+
+ DBEnvironmentI(const ::Ice::CommunicatorPtr&, const std::string&);
+ virtual ~DBEnvironmentI();
+
+ virtual std::string getName();
+ virtual ::Ice::CommunicatorPtr getCommunicator();
+
+ virtual DBPtr openDB(const std::string&, bool);
+
+ virtual DBTransactionPtr startTransaction();
+
+ virtual void close();
+
+private:
+
+ // DBI needs access to add, remove & eraseDB
+ friend class DBI;
+ void add(const std::string&, const DBPtr&);
+ void remove(const std::string&);
+ void eraseDB(const std::string&);
+
+ ::Ice::CommunicatorPtr _communicator;
+ int _trace;
+
+ ::DB_ENV* _dbEnv;
+
+ std::string _name;
+ std::string _errorPrefix;
+
+ std::map<std::string, DBPtr> _dbMap;
+};
+
+class DBTransactionI : public DBTransaction, public IceUtil::Mutex
+{
+public:
+
+ DBTransactionI(const ::Ice::CommunicatorPtr&, ::DB_ENV*, const std::string&);
+ virtual ~DBTransactionI();
+
+ virtual void commit();
+ virtual void abort();
+
+private:
+
+ ::Ice::CommunicatorPtr _communicator;
+ int _trace;
+
+ ::DB_TXN* _tid;
+
+ std::string _name;
+ std::string _errorPrefix;
+};
+
+class DBCursorI : public DBCursor, public IceUtil::Mutex
+{
+public:
+
+ DBCursorI(const ::Ice::CommunicatorPtr&, const std::string&, DBC*);
+ ~DBCursorI();
+
+ virtual ::Ice::CommunicatorPtr getCommunicator();
+
+ virtual void curr(Key& key, Value& value);
+ virtual void set(const Value& value);
+ virtual bool next();
+ virtual bool prev();
+ virtual void del();
+
+ virtual DBCursorPtr clone();
+ virtual void close();
+
+private:
+
+ ::Ice::CommunicatorPtr _communicator;
+ int _trace;
+
+ std::string _name;
+ std::string _errorPrefix;
+
+ DBC* _cursor;
+};
+
+class DBI : public DB, public IceUtil::Mutex
+{
+public:
+
+ DBI(const ::Ice::CommunicatorPtr&, const DBEnvironmentIPtr&, ::DB*, const std::string&, bool);
+ virtual ~DBI();
+
+ virtual std::string getName();
+ virtual ::Ice::CommunicatorPtr getCommunicator();
+
+ virtual ::Ice::Long getNumberOfRecords();
+
+ virtual DBCursorPtr getCursor();
+ virtual DBCursorPtr getCursorAtKey(const Key&);
+
+ virtual void put(const Key&, const Value&);
+ virtual bool contains(const Key&);
+ virtual Value get(const Key&);
+ virtual void del(const Key&);
+
+ virtual void clear();
+
+ virtual void close();
+ virtual void remove();
+
+ virtual EvictorPtr createEvictor(EvictorPersistenceMode);
+
+private:
+
+ ::Ice::CommunicatorPtr _communicator;
+ int _trace;
+
+ DBEnvironmentIPtr _dbEnvObj;
+ ::DB* _db;
+
+ std::string _name;
+ std::string _errorPrefix;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index ea4d8e3376f..c641682b780 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -50,7 +50,7 @@ Freeze::EvictorI::EvictorI(const DBPtr& db, EvictorPersistenceMode persistenceMo Freeze::EvictorI::~EvictorI() { - if (!_deactivated) + if(!_deactivated) { Warning out(_db->getCommunicator()->getLogger()); out << "evictor has not been deactivated"; @@ -62,7 +62,7 @@ Freeze::EvictorI::getDB() { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -75,7 +75,7 @@ Freeze::EvictorI::setSize(Int evictorSize) { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -83,7 +83,7 @@ Freeze::EvictorI::setSize(Int evictorSize) // // Ignore requests to set the evictor size to values smaller than zero. // - if (evictorSize < 0) + if(evictorSize < 0) { return; } @@ -104,7 +104,7 @@ Freeze::EvictorI::getSize() { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -117,7 +117,7 @@ Freeze::EvictorI::createObject(const Identity& ident, const ObjectPtr& servant) { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -128,7 +128,7 @@ Freeze::EvictorI::createObject(const Identity& ident, const ObjectPtr& servant) _dict.insert(make_pair(ident, servant)); add(ident, servant); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_db->getCommunicator()->getLogger(), "Evictor"); out << "created \"" << ident << "\""; @@ -145,7 +145,7 @@ Freeze::EvictorI::destroyObject(const Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -156,7 +156,7 @@ Freeze::EvictorI::destroyObject(const Identity& ident) _dict.erase(ident); remove(ident); - if (_trace >= 1) + if(_trace >= 1) { Trace out(_db->getCommunicator()->getLogger(), "Evictor"); out << "destroyed \"" << ident << "\""; @@ -168,7 +168,7 @@ Freeze::EvictorI::installServantInitializer(const ServantInitializerPtr& initial { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -181,7 +181,7 @@ Freeze::EvictorI::getIterator() { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -194,7 +194,7 @@ Freeze::EvictorI::hasObject(const Ice::Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (_deactivated) + if(_deactivated) { throw EvictorDeactivatedException(__FILE__, __LINE__); } @@ -218,9 +218,9 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current EvictorElementPtr element; map<Identity, EvictorElementPtr>::iterator p = _evictorMap.find(current.identity); - if (p != _evictorMap.end()) + if(p != _evictorMap.end()) { - if (_trace >= 2) + if(_trace >= 2) { Trace out(_db->getCommunicator()->getLogger(), "Evictor"); out << "found \"" << current.identity << "\" in the queue"; @@ -237,7 +237,7 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current } else { - if (_trace >= 2) + if(_trace >= 2) { Trace out(_db->getCommunicator()->getLogger(), "Evictor"); out << "couldn't find \"" << current.identity << "\" in the queue\n" @@ -249,7 +249,7 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current // Servant for it. // IdentityObjectDict::iterator p = _dict.find(current.identity); - if (p == _dict.end()) + if(p == _dict.end()) { // // The Ice Object with the given identity does not exist, @@ -267,7 +267,7 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const Current& current // // If an initializer is installed, call it now. // - if (_initializer) + if(_initializer) { _initializer->initialize(adapter, current.identity, servant); } @@ -317,9 +317,9 @@ Freeze::EvictorI::finished(const ObjectAdapterPtr&, const Current& current, // If we are in SaveAfterMutatingOperation mode, we must save the // Ice Object if this was a mutating call. // - if (_persistenceMode == SaveAfterMutatingOperation) + if(_persistenceMode == SaveAfterMutatingOperation) { - if (!current.nonmutating) + if(!current.nonmutating) { _dict.insert(make_pair(current.identity, servant)); } @@ -336,11 +336,11 @@ Freeze::EvictorI::deactivate() { IceUtil::Mutex::Lock sync(*this); - if (!_deactivated) + if(!_deactivated) { _deactivated = true; - if (_trace >= 1) + if(_trace >= 1) { Trace out(_db->getCommunicator()->getLogger(), "Evictor"); out << "deactivating, saving unsaved Ice Objects to the database"; @@ -364,7 +364,7 @@ Freeze::EvictorI::evict() // With most STL implementations, _evictorMap.size() is faster // than _evictorList.size(). // - while (_evictorMap.size() > _evictorSize) + while(_evictorMap.size() > _evictorSize) { // // Get the last unused element from the evictor queue. @@ -374,7 +374,7 @@ Freeze::EvictorI::evict() { q = _evictorMap.find(*p); assert(q != _evictorMap.end()); - if (q->second->usageCount == 0) + if(q->second->usageCount == 0) { break; // Fine, Servant is not in use. } @@ -394,7 +394,7 @@ Freeze::EvictorI::evict() // If we are in SaveUponEviction mode, we must save the Ice // Object that is about to be evicted to persistent store. // - if (_persistenceMode == SaveUponEviction) + if(_persistenceMode == SaveUponEviction) { _dict.insert(make_pair(ident, element->servant)); } @@ -406,7 +406,7 @@ Freeze::EvictorI::evict() _evictorMap.erase(q); ++p; - if (_trace >= 2) + if(_trace >= 2) { Trace out(_db->getCommunicator()->getLogger(), "Evictor"); out << "evicted \"" << ident << "\" from the queue\n" @@ -419,7 +419,7 @@ Freeze::EvictorI::evict() // evict, set _db to zero to break cyclic object // dependencies. // - if (_deactivated && _evictorMap.empty()) + if(_deactivated && _evictorMap.empty()) { assert(_evictorList.empty()); assert(_evictorSize == 0); @@ -434,7 +434,7 @@ Freeze::EvictorI::add(const Identity& ident, const ObjectPtr& servant) // Ignore the request if the Ice Object is already in the queue. // map<Identity, EvictorElementPtr>::const_iterator p = _evictorMap.find(ident); - if (p != _evictorMap.end()) + if(p != _evictorMap.end()) { return p->second; } @@ -458,7 +458,7 @@ Freeze::EvictorI::remove(const Identity& ident) // If the Ice Object is currently in the evictor, remove it. // map<Identity, EvictorElementPtr>::iterator p = _evictorMap.find(ident); - if (p != _evictorMap.end()) + if(p != _evictorMap.end()) { _evictorList.erase(p->second->position); _evictorMap.erase(p); @@ -492,7 +492,7 @@ Freeze::EvictorIteratorI::hasNext() Ice::Identity Freeze::EvictorIteratorI::next() { - if (_curr == _end) + if(_curr == _end) { throw Freeze::NoSuchElementException(__FILE__, __LINE__); } diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h index 5c7a7304b2f..f113579dad5 100644 --- a/cpp/src/Freeze/EvictorI.h +++ b/cpp/src/Freeze/EvictorI.h @@ -1,76 +1,76 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FREEZE_EVICTOR_I_H -#define FREEZE_EVICTOR_I_H - -#include <IceUtil/IceUtil.h> -#include <Ice/Ice.h> -#include <Freeze/Evictor.h> -#include <Freeze/IdentityObjectDict.h> - -#include <list> - -namespace Freeze -{ - -class EvictorI : public Evictor, public IceUtil::Mutex -{ -public: - - EvictorI(const Freeze::DBPtr&, EvictorPersistenceMode); - virtual ~EvictorI(); - - virtual DBPtr getDB(); - - virtual void setSize(Ice::Int); - virtual Ice::Int getSize(); - - virtual void createObject(const Ice::Identity&, const Ice::ObjectPtr&); - virtual void destroyObject(const Ice::Identity&); - - virtual void installServantInitializer(const ServantInitializerPtr&); - virtual EvictorIteratorPtr getIterator(); - virtual bool hasObject(const Ice::Identity&); - - virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const Ice::Current&, Ice::LocalObjectPtr&); - virtual void finished(const Ice::ObjectAdapterPtr&, const Ice::Current&, - const Ice::ObjectPtr&, const Ice::LocalObjectPtr&); - virtual void deactivate(); - -private: - - struct EvictorElement : public Ice::LocalObject - { - Ice::ObjectPtr servant; - std::list<Ice::Identity>::iterator position; - int usageCount; - }; - typedef IceUtil::Handle<EvictorElement> EvictorElementPtr; - - void evict(); - EvictorElementPtr add(const Ice::Identity&, const Ice::ObjectPtr&); - void remove(const Ice::Identity&); - - std::map<Ice::Identity, EvictorElementPtr> _evictorMap; - std::list<Ice::Identity> _evictorList; - std::map<Ice::Identity, EvictorElementPtr>::size_type _evictorSize; - - bool _deactivated; - IdentityObjectDict _dict; - Freeze::DBPtr _db; - EvictorPersistenceMode _persistenceMode; - ServantInitializerPtr _initializer; - int _trace; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FREEZE_EVICTOR_I_H
+#define FREEZE_EVICTOR_I_H
+
+#include <IceUtil/IceUtil.h>
+#include <Ice/Ice.h>
+#include <Freeze/Evictor.h>
+#include <Freeze/IdentityObjectDict.h>
+
+#include <list>
+
+namespace Freeze
+{
+
+class EvictorI : public Evictor, public IceUtil::Mutex
+{
+public:
+
+ EvictorI(const Freeze::DBPtr&, EvictorPersistenceMode);
+ virtual ~EvictorI();
+
+ virtual DBPtr getDB();
+
+ virtual void setSize(Ice::Int);
+ virtual Ice::Int getSize();
+
+ virtual void createObject(const Ice::Identity&, const Ice::ObjectPtr&);
+ virtual void destroyObject(const Ice::Identity&);
+
+ virtual void installServantInitializer(const ServantInitializerPtr&);
+ virtual EvictorIteratorPtr getIterator();
+ virtual bool hasObject(const Ice::Identity&);
+
+ virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const Ice::Current&, Ice::LocalObjectPtr&);
+ virtual void finished(const Ice::ObjectAdapterPtr&, const Ice::Current&,
+ const Ice::ObjectPtr&, const Ice::LocalObjectPtr&);
+ virtual void deactivate();
+
+private:
+
+ struct EvictorElement : public Ice::LocalObject
+ {
+ Ice::ObjectPtr servant;
+ std::list<Ice::Identity>::iterator position;
+ int usageCount;
+ };
+ typedef IceUtil::Handle<EvictorElement> EvictorElementPtr;
+
+ void evict();
+ EvictorElementPtr add(const Ice::Identity&, const Ice::ObjectPtr&);
+ void remove(const Ice::Identity&);
+
+ std::map<Ice::Identity, EvictorElementPtr> _evictorMap;
+ std::list<Ice::Identity> _evictorList;
+ std::map<Ice::Identity, EvictorElementPtr>::size_type _evictorSize;
+
+ bool _deactivated;
+ IdentityObjectDict _dict;
+ Freeze::DBPtr _db;
+ EvictorPersistenceMode _persistenceMode;
+ ServantInitializerPtr _initializer;
+ int _trace;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Glacier/Blobject.cpp b/cpp/src/Glacier/Blobject.cpp index ca3c123dbe1..413a5088af4 100644 --- a/cpp/src/Glacier/Blobject.cpp +++ b/cpp/src/Glacier/Blobject.cpp @@ -39,7 +39,7 @@ Glacier::Blobject::destroy() { IceUtil::Mutex::Lock lock(_missiveQueueMutex); - if (_missiveQueue) + if(_missiveQueue) { _missiveQueue->destroy(); _missiveQueueControl.join(); @@ -57,17 +57,17 @@ Glacier::Blobject::invoke(ObjectPrx& proxy, const vector<Byte>& inParams, vector { MissiveQueuePtr missiveQueue = modifyProxy(proxy, current); - if (missiveQueue) // Batch routing? + if(missiveQueue) // Batch routing? { missiveQueue->add(new Missive(proxy, inParams, current, _forwardContext)); return true; } else // Regular routing. { - if (_traceLevel >= 2) + if(_traceLevel >= 2) { Trace out(_logger, "Glacier"); - if (reverse()) + if(reverse()) { out << "reverse "; } @@ -77,7 +77,7 @@ Glacier::Blobject::invoke(ObjectPrx& proxy, const vector<Byte>& inParams, vector << "nonmutating = " << (current.nonmutating ? "true" : "false"); } - if (_forwardContext) + if(_forwardContext) { return proxy->ice_invoke(current.operation, current.nonmutating, inParams, outParams, current.context); } @@ -89,10 +89,10 @@ Glacier::Blobject::invoke(ObjectPrx& proxy, const vector<Byte>& inParams, vector } catch (const Exception& ex) { - if (_traceLevel >= 1) + if(_traceLevel >= 1) { Trace out(_logger, "Glacier"); - if (reverse()) + if(reverse()) { out << "reverse "; } @@ -109,19 +109,19 @@ Glacier::Blobject::invoke(ObjectPrx& proxy, const vector<Byte>& inParams, vector MissiveQueuePtr Glacier::Blobject::modifyProxy(ObjectPrx& proxy, const Current& current) { - if (!current.facet.empty()) + if(!current.facet.empty()) { proxy = proxy->ice_newFacet(current.facet); } MissiveQueuePtr missiveQueue; Context::const_iterator p = current.context.find("_fwd"); - if (p != current.context.end()) + if(p != current.context.end()) { - for (unsigned int i = 0; i < p->second.length(); ++i) + for(unsigned int i = 0; i < p->second.length(); ++i) { char option = p->second[i]; - switch (option) + switch(option) { case 't': { @@ -184,7 +184,7 @@ Glacier::Blobject::getMissiveQueue() // Lazy missive queue initialization. // IceUtil::Mutex::Lock lock(_missiveQueueMutex); - if (!_missiveQueue) + if(!_missiveQueue) { _missiveQueue = new MissiveQueue(_communicator, _traceLevel, reverse(), _batchSleepTime); _missiveQueueControl = _missiveQueue->start(); diff --git a/cpp/src/Glacier/Blobject.h b/cpp/src/Glacier/Blobject.h index 3c362e771c0..ae550769290 100644 --- a/cpp/src/Glacier/Blobject.h +++ b/cpp/src/Glacier/Blobject.h @@ -1,53 +1,53 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef BLOBJECT_H -#define BLOBJECT_H - -#include <Ice/Ice.h> -#include <Glacier/Missive.h> - -namespace Glacier -{ - -class Blobject : public Ice::Blobject -{ -public: - - Blobject(const Ice::CommunicatorPtr&); - virtual ~Blobject(); - - virtual bool reverse() = 0; - - void destroy(); - bool invoke(Ice::ObjectPrx&, const std::vector<Ice::Byte>&, std::vector<Ice::Byte>&, const Ice::Current&); - MissiveQueuePtr modifyProxy(Ice::ObjectPrx&, const Ice::Current&); - -protected: - - Ice::CommunicatorPtr _communicator; - Ice::LoggerPtr _logger; - - int _traceLevel; - bool _forwardContext; - IceUtil::Time _batchSleepTime; - -private: - - MissiveQueuePtr getMissiveQueue(); - - MissiveQueuePtr _missiveQueue; - IceUtil::ThreadControl _missiveQueueControl; - IceUtil::Mutex _missiveQueueMutex; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef BLOBJECT_H
+#define BLOBJECT_H
+
+#include <Ice/Ice.h>
+#include <Glacier/Missive.h>
+
+namespace Glacier
+{
+
+class Blobject : public Ice::Blobject
+{
+public:
+
+ Blobject(const Ice::CommunicatorPtr&);
+ virtual ~Blobject();
+
+ virtual bool reverse() = 0;
+
+ void destroy();
+ bool invoke(Ice::ObjectPrx&, const std::vector<Ice::Byte>&, std::vector<Ice::Byte>&, const Ice::Current&);
+ MissiveQueuePtr modifyProxy(Ice::ObjectPrx&, const Ice::Current&);
+
+protected:
+
+ Ice::CommunicatorPtr _communicator;
+ Ice::LoggerPtr _logger;
+
+ int _traceLevel;
+ bool _forwardContext;
+ IceUtil::Time _batchSleepTime;
+
+private:
+
+ MissiveQueuePtr getMissiveQueue();
+
+ MissiveQueuePtr _missiveQueue;
+ IceUtil::ThreadControl _missiveQueueControl;
+ IceUtil::Mutex _missiveQueueMutex;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Glacier/ClientBlobject.cpp b/cpp/src/Glacier/ClientBlobject.cpp index 4fca8a9d50a..e582b4e73c9 100644 --- a/cpp/src/Glacier/ClientBlobject.cpp +++ b/cpp/src/Glacier/ClientBlobject.cpp @@ -31,7 +31,7 @@ Glacier::ClientBlobject::ClientBlobject(const CommunicatorPtr& communicator, const string ws = " \t"; string::size_type current = allowCategories.find_first_not_of(ws, 0); - while (current != string::npos) + while(current != string::npos) { string::size_type pos = allowCategories.find_first_of(ws, current); string::size_type len = (pos == string::npos) ? string::npos : pos - current; @@ -68,11 +68,11 @@ Glacier::ClientBlobject::ice_invoke(const vector<Byte>& inParams, vector<Byte>& // // If there is an _allowCategories set then enforce it. // - if (!_allowCategories.empty()) + if(!_allowCategories.empty()) { - if (!binary_search(_allowCategories.begin(), _allowCategories.end(), current.identity.category)) + if(!binary_search(_allowCategories.begin(), _allowCategories.end(), current.identity.category)) { - if (_traceLevel >= 1) + if(_traceLevel >= 1) { Trace out(_logger, "Glacier"); out << "rejecting request\n"; @@ -85,7 +85,7 @@ Glacier::ClientBlobject::ice_invoke(const vector<Byte>& inParams, vector<Byte>& } ObjectPrx proxy = _routingTable->get(current.identity); - if (!proxy) + if(!proxy) { ObjectNotExistException ex(__FILE__, __LINE__); ex.identity = current.identity; diff --git a/cpp/src/Glacier/ClientBlobject.h b/cpp/src/Glacier/ClientBlobject.h index cb866f6a4ac..77d68adf86a 100644 --- a/cpp/src/Glacier/ClientBlobject.h +++ b/cpp/src/Glacier/ClientBlobject.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef CLIENT_BLOBJECT_H -#define CLIENT_BLOBJECT_H - -#include <Ice/RoutingTableF.h> -#include <Glacier/Blobject.h> - -namespace Glacier -{ - -class ClientBlobject : public Glacier::Blobject -{ -public: - - ClientBlobject(const Ice::CommunicatorPtr&, const IceInternal::RoutingTablePtr&, const std::string&); - - virtual bool reverse(); - - void destroy(); - virtual bool ice_invoke(const std::vector<Ice::Byte>&, std::vector<Ice::Byte>&, const Ice::Current&); - -private: - - IceInternal::RoutingTablePtr _routingTable; - std::vector<std::string> _allowCategories; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef CLIENT_BLOBJECT_H
+#define CLIENT_BLOBJECT_H
+
+#include <Ice/RoutingTableF.h>
+#include <Glacier/Blobject.h>
+
+namespace Glacier
+{
+
+class ClientBlobject : public Glacier::Blobject
+{
+public:
+
+ ClientBlobject(const Ice::CommunicatorPtr&, const IceInternal::RoutingTablePtr&, const std::string&);
+
+ virtual bool reverse();
+
+ void destroy();
+ virtual bool ice_invoke(const std::vector<Ice::Byte>&, std::vector<Ice::Byte>&, const Ice::Current&);
+
+private:
+
+ IceInternal::RoutingTablePtr _routingTable;
+ std::vector<std::string> _allowCategories;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Glacier/GlacierRouter.cpp b/cpp/src/Glacier/GlacierRouter.cpp index 6f885d3c792..73fca122679 100644 --- a/cpp/src/Glacier/GlacierRouter.cpp +++ b/cpp/src/Glacier/GlacierRouter.cpp @@ -72,13 +72,13 @@ void Glacier::ServantLocator::deactivate() { ClientBlobject* clientBlobject = dynamic_cast<ClientBlobject*>(_blobject.get()); - if (clientBlobject) + if(clientBlobject) { clientBlobject->destroy(); } ServerBlobject* serverBlobject = dynamic_cast<ServerBlobject*>(_blobject.get()); - if (serverBlobject) + if(serverBlobject) { serverBlobject->destroy(); } @@ -100,14 +100,14 @@ Glacier::RouterApp::usage() int Glacier::RouterApp::run(int argc, char* argv[]) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; @@ -128,7 +128,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) // // Only do this if we've been configured for SSL. // - if (!clientConfig.empty() && !serverConfig.empty()) + if(!clientConfig.empty() && !serverConfig.empty()) { IceSSL::ContextType contextType = IceSSL::ClientServer; @@ -147,7 +147,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) // If we have been told only to only accept a single certificate. string clientCertBase64 = properties->getProperty("Glacier.Router.AcceptCert"); - if (!clientCertBase64.empty()) + if(!clientCertBase64.empty()) { // Install a Certificate Verifier that only accepts indicated certificate. Ice::ByteSeq clientCert = IceUtil::Base64::decode(clientCertBase64); @@ -168,7 +168,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) // const char* clientEndpointsProperty = "Glacier.Router.Client.Endpoints"; string clientEndpoints = properties->getProperty(clientEndpointsProperty); - if (clientEndpoints.empty()) + if(clientEndpoints.empty()) { cerr << appName() << ": property `" << clientEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -182,7 +182,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) const char* serverEndpointsProperty = "Glacier.Router.Server.Endpoints"; string serverEndpoints = properties->getProperty(serverEndpointsProperty); ObjectAdapterPtr serverAdapter; - if (!serverEndpoints.empty()) + if(!serverEndpoints.empty()) { serverAdapter = communicator()->createObjectAdapterFromProperty("Server", serverEndpointsProperty); } @@ -196,7 +196,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) ObjectPtr clientBlobject = new ClientBlobject(communicator(), routingTable, allowCategories); Ice::ServantLocatorPtr clientServantLocator = new Glacier::ServantLocator(clientBlobject); clientAdapter->addServantLocator(clientServantLocator, ""); - if (serverAdapter) + if(serverAdapter) { ObjectPtr serverBlobject = new ServerBlobject(clientAdapter); Ice::ServantLocatorPtr serverServantLocator = new Glacier::ServantLocator(serverBlobject); @@ -208,7 +208,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) // const char* routerEndpointsProperty = "Glacier.Router.Endpoints"; string routerEndpoints = properties->getProperty(routerEndpointsProperty); - if (routerEndpoints.empty()) + if(routerEndpoints.empty()) { cerr << appName() << ": property `" << routerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -221,7 +221,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) string sessionManager = properties->getProperty(sessionManagerProperty); SessionManagerPrx sessionManagerPrx; - if (!sessionManager.empty()) + if(!sessionManager.empty()) { sessionManagerPrx = SessionManagerPrx::checkedCast(communicator()->stringToProxy(sessionManager)); } @@ -240,13 +240,13 @@ Glacier::RouterApp::run(int argc, char* argv[]) // specified in the properties, if so requested. // string outputFd = properties->getProperty("Glacier.Router.PrintProxyOnFd"); - if (!outputFd.empty()) + if(!outputFd.empty()) { int fd = atoi(outputFd.c_str()); string ref = communicator()->proxyToString(routerAdapter->createProxy(stringToIdentity(routerIdentity))); ref += "\n"; string::size_type sz = static_cast<string::size_type>(write(fd, ref.c_str(), ref.length())); - if (sz != ref.length()) + if(sz != ref.length()) { cerr << appName() << ": cannot write stringified router proxy to filedescriptor " << fd << ": " << strerror(errno) << endl; @@ -270,7 +270,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) // shutdownOnInterrupt(); clientAdapter->activate(); - if (serverAdapter) + if(serverAdapter) { serverAdapter->activate(); } diff --git a/cpp/src/Glacier/GlacierStarter.cpp b/cpp/src/Glacier/GlacierStarter.cpp index 693cac79140..7a713364556 100644 --- a/cpp/src/Glacier/GlacierStarter.cpp +++ b/cpp/src/Glacier/GlacierStarter.cpp @@ -48,14 +48,14 @@ Glacier::RouterApp::usage() int Glacier::RouterApp::run(int argc, char* argv[]) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; @@ -75,7 +75,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) // const char* endpointsProperty = "Glacier.Starter.Endpoints"; string endpoints = properties->getProperty(endpointsProperty); - if (endpoints.empty()) + if(endpoints.empty()) { cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -88,10 +88,10 @@ Glacier::RouterApp::run(int argc, char* argv[]) // string verifierProperty = properties->getProperty("Glacier.Starter.PasswordVerifier"); PasswordVerifierPrx verifier; - if (!verifierProperty.empty()) + if(!verifierProperty.empty()) { verifier = PasswordVerifierPrx::checkedCast(communicator()->stringToProxy(verifierProperty)); - if (!verifier) + if(!verifier) { cerr << appName() << ": password verifier `" << verifierProperty << "' is invalid" << endl; return EXIT_FAILURE; @@ -102,7 +102,7 @@ Glacier::RouterApp::run(int argc, char* argv[]) string passwordsProperty = properties->getPropertyWithDefault("Glacier.Starter.CryptPasswords", "passwords"); ifstream passwordFile(passwordsProperty.c_str()); - if (!passwordFile) + if(!passwordFile) { cerr << appName() << ": cannot open `" << passwordsProperty << "' for reading: " << strerror(errno) << endl; @@ -115,14 +115,14 @@ Glacier::RouterApp::run(int argc, char* argv[]) { string userId; passwordFile >> userId; - if (!passwordFile) + if(!passwordFile) { break; } string password; passwordFile >> password; - if (!passwordFile) + if(!passwordFile) { break; } diff --git a/cpp/src/Glacier/Missive.cpp b/cpp/src/Glacier/Missive.cpp index 4daa3165ab2..bdc46f1ec2f 100644 --- a/cpp/src/Glacier/Missive.cpp +++ b/cpp/src/Glacier/Missive.cpp @@ -22,7 +22,7 @@ Glacier::Missive::Missive(const ObjectPrx& proxy, const vector<Byte>& inParams, _forwardContext(forwardContext) { Context::const_iterator p = current.context.find("_ovrd"); - if (p != current.context.end()) + if(p != current.context.end()) { _override = p->second; } @@ -32,7 +32,7 @@ void Glacier::Missive::invoke() { std::vector<Byte> dummy; - if (_forwardContext) + if(_forwardContext) { _proxy->ice_invoke(_current.operation, _current.nonmutating, _inParams, dummy, _current.context); } @@ -45,7 +45,7 @@ Glacier::Missive::invoke() bool Glacier::Missive::override(const MissivePtr& other) { - if (_override.empty() || other->_override.empty()) + if(_override.empty() || other->_override.empty()) { return false; } @@ -105,14 +105,14 @@ Glacier::MissiveQueue::add(const MissivePtr& missive) assert(!_destroy); - if (_missives.empty()) + if(_missives.empty()) { notify(); } - for (std::vector<MissivePtr>::iterator p = _missives.begin(); p != _missives.end(); ++p) + for(std::vector<MissivePtr>::iterator p = _missives.begin(); p != _missives.end(); ++p) { - if (missive->override(*p)) + if(missive->override(*p)) { *p = missive; // Replace old missive if this is an override. return; @@ -125,36 +125,36 @@ Glacier::MissiveQueue::add(const MissivePtr& missive) void Glacier::MissiveQueue::run() { - while (true) + while(true) { vector<ObjectPrx> proxies; { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); - while (!_destroy && _missives.empty()) + while(!_destroy && _missives.empty()) { wait(); } - if (_destroy) + if(_destroy) { return; } proxies.reserve(_missives.size()); vector<MissivePtr>::const_iterator p; - for (p = _missives.begin(); p != _missives.end(); ++p) + for(p = _missives.begin(); p != _missives.end(); ++p) { try { const ObjectPrx& proxy = (*p)->getProxy(); const Current& current = (*p)->getCurrent(); - if (_traceLevel >= 2) + if(_traceLevel >= 2) { Trace out(_logger, "Glacier"); - if (_reverse) + if(_reverse) { out << "reverse "; } @@ -169,10 +169,10 @@ Glacier::MissiveQueue::run() } catch (const Ice::Exception& ex) { - if (_traceLevel >= 1) + if(_traceLevel >= 1) { Trace out(_logger, "Glacier"); - if (_reverse) + if(_reverse) { out << "reverse "; } @@ -197,7 +197,7 @@ Glacier::MissiveQueue::run() // sort(proxies.begin(), proxies.end()); // proxies.erase(unique(proxies.begin(), proxies.end()), proxies.end()); vector<ObjectPrx>::const_iterator p; - for (p = proxies.begin(); p != proxies.end(); ++p) + for(p = proxies.begin(); p != proxies.end(); ++p) { (*p)->ice_flush(); } @@ -206,7 +206,7 @@ Glacier::MissiveQueue::run() // In order to avoid flooding the missive receivers, we add // a delay between sending missives. // - if (_sleepTime > IceUtil::Time()) + if(_sleepTime > IceUtil::Time()) { IceUtil::ThreadControl::sleep(_sleepTime); } @@ -215,10 +215,10 @@ Glacier::MissiveQueue::run() { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); - if (_traceLevel >= 1) + if(_traceLevel >= 1) { Trace out(_logger, "Glacier"); - if (_reverse) + if(_reverse) { out << "reverse "; } diff --git a/cpp/src/Glacier/Missive.h b/cpp/src/Glacier/Missive.h index 96ec51c5762..534dee19f4f 100644 --- a/cpp/src/Glacier/Missive.h +++ b/cpp/src/Glacier/Missive.h @@ -1,74 +1,74 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef MISSIVE_H -#define MISSIVE_H - -#include <Ice/Ice.h> -#include <IceUtil/Thread.h> -#include <IceUtil/Monitor.h> - -namespace Glacier -{ - -class Missive; -typedef IceUtil::Handle<Missive> MissivePtr; - -class Missive : virtual public IceUtil::Shared -{ -public: - - Missive(const Ice::ObjectPrx&, const std::vector<Ice::Byte>&, const Ice::Current&, bool); - - void invoke(); - bool override(const MissivePtr&); - const Ice::ObjectPrx& getProxy() const; - const Ice::Current& getCurrent() const; - -private: - - Ice::ObjectPrx _proxy; - std::vector<Ice::Byte> _inParams; - Ice::Current _current; - bool _forwardContext; - std::string _override; -}; - -class MissiveQueue; -typedef IceUtil::Handle<MissiveQueue> MissiveQueuePtr; - -class MissiveQueue : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - MissiveQueue(const Ice::CommunicatorPtr&, int, bool, const IceUtil::Time&); - virtual ~MissiveQueue(); - - void destroy(); - void add(const MissivePtr&); - - virtual void run(); - -private: - - Ice::CommunicatorPtr _communicator; - Ice::LoggerPtr _logger; - int _traceLevel; - bool _reverse; - IceUtil::Time _sleepTime; - - std::vector<MissivePtr> _missives; - bool _destroy; -}; - -}; - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef MISSIVE_H
+#define MISSIVE_H
+
+#include <Ice/Ice.h>
+#include <IceUtil/Thread.h>
+#include <IceUtil/Monitor.h>
+
+namespace Glacier
+{
+
+class Missive;
+typedef IceUtil::Handle<Missive> MissivePtr;
+
+class Missive : virtual public IceUtil::Shared
+{
+public:
+
+ Missive(const Ice::ObjectPrx&, const std::vector<Ice::Byte>&, const Ice::Current&, bool);
+
+ void invoke();
+ bool override(const MissivePtr&);
+ const Ice::ObjectPrx& getProxy() const;
+ const Ice::Current& getCurrent() const;
+
+private:
+
+ Ice::ObjectPrx _proxy;
+ std::vector<Ice::Byte> _inParams;
+ Ice::Current _current;
+ bool _forwardContext;
+ std::string _override;
+};
+
+class MissiveQueue;
+typedef IceUtil::Handle<MissiveQueue> MissiveQueuePtr;
+
+class MissiveQueue : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex>
+{
+public:
+
+ MissiveQueue(const Ice::CommunicatorPtr&, int, bool, const IceUtil::Time&);
+ virtual ~MissiveQueue();
+
+ void destroy();
+ void add(const MissivePtr&);
+
+ virtual void run();
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+ Ice::LoggerPtr _logger;
+ int _traceLevel;
+ bool _reverse;
+ IceUtil::Time _sleepTime;
+
+ std::vector<MissivePtr> _missives;
+ bool _destroy;
+};
+
+};
+
+#endif
+
diff --git a/cpp/src/Glacier/RouterI.cpp b/cpp/src/Glacier/RouterI.cpp index 751a298eb89..ed3373cbdf1 100644 --- a/cpp/src/Glacier/RouterI.cpp +++ b/cpp/src/Glacier/RouterI.cpp @@ -51,7 +51,7 @@ Glacier::RouterI::destroy() _serverAdapter = 0; _logger = 0; _routingTable = 0; - for (vector<SessionPrx>::const_iterator p = _sessions.begin(); p != _sessions.end(); ++p) + for(vector<SessionPrx>::const_iterator p = _sessions.begin(); p != _sessions.end(); ++p) { try { @@ -78,7 +78,7 @@ Glacier::RouterI::getServerProxy(const Current&) { assert(_clientAdapter); // Destroyed? - if (_serverAdapter) + if(_serverAdapter) { return _serverAdapter->createProxy(stringToIdentity("dummy")); } @@ -93,7 +93,7 @@ Glacier::RouterI::addProxy(const ObjectPrx& proxy, const Current&) { assert(_clientAdapter); // Destroyed? - if (_routingTableTraceLevel) + if(_routingTableTraceLevel) { Trace out(_logger, "Glacier"); out << "adding proxy to routing table:\n" << _clientAdapter->getCommunicator()->proxyToString(proxy); @@ -117,7 +117,7 @@ Glacier::RouterI::createSession(const Current&) assert(_clientAdapter); // Destroyed? IceUtil::Mutex::Lock lock(_sessionMutex); - if (!_sessionManager) + if(!_sessionManager) { throw NoSessionManagerException(); } diff --git a/cpp/src/Glacier/RouterI.h b/cpp/src/Glacier/RouterI.h index 03a3aaee906..8dc57381f4a 100644 --- a/cpp/src/Glacier/RouterI.h +++ b/cpp/src/Glacier/RouterI.h @@ -1,55 +1,55 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GLACIER_ROUTER_I_H -#define GLACIER_ROUTER_I_H - -#include <Ice/RoutingTableF.h> -#include <Ice/Ice.h> -#include <Glacier/Router.h> -#include <Glacier/SessionManagerF.h> - -namespace Glacier -{ - -class RouterI : public Router -{ -public: - - RouterI(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const ::IceInternal::RoutingTablePtr&, - const SessionManagerPrx&, const std::string&); - - virtual ~RouterI(); - - void destroy(); - - virtual Ice::ObjectPrx getClientProxy(const Ice::Current&); - virtual Ice::ObjectPrx getServerProxy(const Ice::Current&); - virtual void addProxy(const Ice::ObjectPrx&, const Ice::Current&); - virtual void shutdown(const Ice::Current&); - virtual SessionPrx createSession(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _clientAdapter; - Ice::ObjectAdapterPtr _serverAdapter; - Ice::LoggerPtr _logger; - ::IceInternal::RoutingTablePtr _routingTable; - int _routingTableTraceLevel; - - IceUtil::Mutex _sessionMutex; - SessionManagerPrx _sessionManager; - std::vector<SessionPrx> _sessions; - std::string _userId; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GLACIER_ROUTER_I_H
+#define GLACIER_ROUTER_I_H
+
+#include <Ice/RoutingTableF.h>
+#include <Ice/Ice.h>
+#include <Glacier/Router.h>
+#include <Glacier/SessionManagerF.h>
+
+namespace Glacier
+{
+
+class RouterI : public Router
+{
+public:
+
+ RouterI(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const ::IceInternal::RoutingTablePtr&,
+ const SessionManagerPrx&, const std::string&);
+
+ virtual ~RouterI();
+
+ void destroy();
+
+ virtual Ice::ObjectPrx getClientProxy(const Ice::Current&);
+ virtual Ice::ObjectPrx getServerProxy(const Ice::Current&);
+ virtual void addProxy(const Ice::ObjectPrx&, const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+ virtual SessionPrx createSession(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _clientAdapter;
+ Ice::ObjectAdapterPtr _serverAdapter;
+ Ice::LoggerPtr _logger;
+ ::IceInternal::RoutingTablePtr _routingTable;
+ int _routingTableTraceLevel;
+
+ IceUtil::Mutex _sessionMutex;
+ SessionManagerPrx _sessionManager;
+ std::vector<SessionPrx> _sessions;
+ std::string _userId;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Glacier/ServerBlobject.h b/cpp/src/Glacier/ServerBlobject.h index d28ac9e9515..41d71726547 100644 --- a/cpp/src/Glacier/ServerBlobject.h +++ b/cpp/src/Glacier/ServerBlobject.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SERVER_BLOBJECT_H -#define SERVER_BLOBJECT_H - -#include <Glacier/Blobject.h> - -namespace Glacier -{ - -class ServerBlobject : public Glacier::Blobject -{ -public: - - ServerBlobject(const Ice::ObjectAdapterPtr&); - - virtual bool reverse(); - - void destroy(); - virtual bool ice_invoke(const std::vector<Ice::Byte>&, std::vector<Ice::Byte>&, const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _clientAdapter; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SERVER_BLOBJECT_H
+#define SERVER_BLOBJECT_H
+
+#include <Glacier/Blobject.h>
+
+namespace Glacier
+{
+
+class ServerBlobject : public Glacier::Blobject
+{
+public:
+
+ ServerBlobject(const Ice::ObjectAdapterPtr&);
+
+ virtual bool reverse();
+
+ void destroy();
+ virtual bool ice_invoke(const std::vector<Ice::Byte>&, std::vector<Ice::Byte>&, const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _clientAdapter;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Glacier/StarterI.cpp b/cpp/src/Glacier/StarterI.cpp index 1763e844336..ea85a1e3de5 100644 --- a/cpp/src/Glacier/StarterI.cpp +++ b/cpp/src/Glacier/StarterI.cpp @@ -75,7 +75,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt { assert(_communicator); // Destroyed? - if (!_verifier->checkPassword(userId, password)) + if(!_verifier->checkPassword(userId, password)) { throw InvalidPasswordException(); } @@ -103,7 +103,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt string routerCertificateBase64; string clientCertificateBase64; - if (sslConfigured) + if(sslConfigured) { // // Create a certificate for the client and the router. @@ -130,14 +130,14 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt try { - if (pipe(fds) != 0) + if(pipe(fds) != 0) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); throw ex; } pid = fork(); - if (pid == -1) + if(pid == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -151,7 +151,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt ex.ice_throw(); } - if (pid == 0) // Child process. + if(pid == 0) // Child process. { // // Close all filedescriptors, except for standard input, @@ -159,9 +159,9 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt // of the newly created pipe. // int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX)); - for (int fd = 3; fd < maxFd; ++fd) + for(int fd = 3; fd < maxFd; ++fd) { - if (fd != fds[1]) + if(fd != fds[1]) { close(fd); } @@ -178,7 +178,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt // be seen with `ps'. Keys and certificate should rather be // passed through a pipe? (ML will take care of this...) // - if (sslConfigured) + if(sslConfigured) { args.push_back("--IceSSL.Server.Overrides.RSA.PrivateKey=" + routerPrivateKeyBase64); args.push_back("--IceSSL.Server.Overrides.RSA.Certificate=" + routerCertificateBase64); @@ -189,7 +189,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt args.push_back("--Glacier.Router.UserId=" + userId); - if (!_properties->getProperty("Glacier.Starter.AddUserToAllowCategories").empty()) + if(!_properties->getProperty("Glacier.Starter.AddUserToAllowCategories").empty()) { args.push_back("--Glacier.Router.AllowCategories=" + _properties->getProperty("Glacier.Router.AllowCategories") + " " + userId); @@ -199,22 +199,22 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt s << "--Glacier.Router.PrintProxyOnFd=" << fds[1]; args.push_back(s.str()); string overwrite = _properties->getProperty("Glacier.Starter.PropertiesOverwrite"); - if (!overwrite.empty()) + if(!overwrite.empty()) { string::size_type end = 0; - while (end != string::npos) + while(end != string::npos) { static const string delim = " \t\r\n"; string::size_type beg = overwrite.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } end = overwrite.find_first_of(delim, beg); string arg; - if (end == string::npos) + if(end == string::npos) { arg = overwrite.substr(beg); } @@ -222,7 +222,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt { arg = overwrite.substr(beg, end - beg); } - if (arg.find("--") != 0) + if(arg.find("--") != 0) { arg = "--" + arg; } @@ -232,7 +232,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt /* StringSeq::iterator seqElem = args.begin(); - while (seqElem != args.end()) + while(seqElem != args.end()) { cerr << *seqElem << endl; seqElem++; @@ -246,7 +246,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt char** argv = static_cast<char**>(malloc((argc + 1) * sizeof(char*))); StringSeq::iterator p; int i; - for (p = args.begin(), i = 1; p != args.end(); ++p, ++i) + for(p = args.begin(), i = 1; p != args.end(); ++p, ++i) { assert(i < argc); argv[i] = strdup(p->c_str()); @@ -258,7 +258,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt // // Try to start the router. // - if (execvp(argv[0], argv) == -1) + if(execvp(argv[0], argv) == -1) { // // Send any errors to the parent process, using the write @@ -285,7 +285,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt // int flags = fcntl(fds[0], F_GETFL); flags |= O_NONBLOCK; - if (fcntl(fds[0], F_SETFL, flags) == -1) + if(fcntl(fds[0], F_SETFL, flags) == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -298,16 +298,16 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt FD_SET(fds[0], &fdSet); struct timeval tv; tv.tv_sec = _properties->getPropertyAsIntWithDefault("Glacier.Starter.StartupTimeout", 10); - if (tv.tv_sec < 1) + if(tv.tv_sec < 1) { tv.tv_sec = 1; // One second is minimum. } tv.tv_usec = 0; int ret = ::select(fds[0] + 1, &fdSet, 0, 0, &tv); - if (ret == -1) + if(ret == -1) { - if (errno == EINTR) + if(errno == EINTR) { goto repeatSelect; } @@ -317,7 +317,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt throw ex; } - if (ret == 0) // Timeout. + if(ret == 0) // Timeout. { CannotStartRouterException ex; ex.reason = "timeout while starting `" + path + "'"; @@ -338,7 +338,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt throw ex; } - if (sz == 0) // EOF? + if(sz == 0) // EOF? { CannotStartRouterException ex; ex.reason = "got EOF from `" + path + "'"; @@ -347,14 +347,14 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt buf[sz] = '\0'; // Terminate the string we got back. - if (strncmp(buf, uuid.c_str(), uuid.length()) == 0) + if(strncmp(buf, uuid.c_str(), uuid.length()) == 0) { // // We got the stringified router proxy. // RouterPrx router = RouterPrx::uncheckedCast(_communicator->stringToProxy(buf)); - if (_traceLevel >= 2) + if(_traceLevel >= 2) { Trace out(_logger, "Glacier"); out << "started new router:\n" << _communicator->proxyToString(router); @@ -374,7 +374,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt } catch(const CannotStartRouterException& ex) { - if (_traceLevel >= 1) + if(_traceLevel >= 1) { Trace out(_logger, "Glacier"); out << "router starter exception:\n" << ex << ":\n" << ex.reason; @@ -404,12 +404,12 @@ Glacier::CryptPasswordVerifierI::checkPassword(const string& userId, const strin { map<string, string>::const_iterator p = _passwords.find(userId); - if (p == _passwords.end()) + if(p == _passwords.end()) { return false; } - if (p->second.size() != 13) // Crypt passwords are 13 characters long. + if(p->second.size() != 13) // Crypt passwords are 13 characters long. { return false; } diff --git a/cpp/src/Glacier/StarterI.h b/cpp/src/Glacier/StarterI.h index 41ba2958f2a..1642d911604 100644 --- a/cpp/src/Glacier/StarterI.h +++ b/cpp/src/Glacier/StarterI.h @@ -1,66 +1,66 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GLACIER_GLACIER_I_H -#define GLACIER_GLACIER_I_H - -#include <Ice/Ice.h> -#include <IceSSL/RSACertificateGen.h> -#include <Glacier/Starter.h> - -namespace Glacier -{ - -using IceSSL::OpenSSL::RSACertificateGenContext; -using IceSSL::OpenSSL::RSACertificateGen; - -class StarterI : public Starter -{ -public: - - StarterI(const Ice::CommunicatorPtr&, const PasswordVerifierPrx&); - - void destroy(); - - RouterPrx startRouter(const std::string&, - const std::string&, - Ice::ByteSeq&, - Ice::ByteSeq&, - Ice::ByteSeq&, - const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; - Ice::LoggerPtr _logger; - Ice::PropertiesPtr _properties; - PasswordVerifierPrx _verifier; - int _traceLevel; - RSACertificateGenContext _certContext; - RSACertificateGen _certificateGenerator; -}; - -class CryptPasswordVerifierI : public PasswordVerifier, public IceUtil::Mutex -{ -public: - - CryptPasswordVerifierI(const std::map<std::string, std::string>&); - - virtual bool checkPassword(const std::string&, const std::string&, const Ice::Current&); - virtual void destroy(const Ice::Current&); - -private: - - const std::map<std::string, std::string> _passwords; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GLACIER_GLACIER_I_H
+#define GLACIER_GLACIER_I_H
+
+#include <Ice/Ice.h>
+#include <IceSSL/RSACertificateGen.h>
+#include <Glacier/Starter.h>
+
+namespace Glacier
+{
+
+using IceSSL::OpenSSL::RSACertificateGenContext;
+using IceSSL::OpenSSL::RSACertificateGen;
+
+class StarterI : public Starter
+{
+public:
+
+ StarterI(const Ice::CommunicatorPtr&, const PasswordVerifierPrx&);
+
+ void destroy();
+
+ RouterPrx startRouter(const std::string&,
+ const std::string&,
+ Ice::ByteSeq&,
+ Ice::ByteSeq&,
+ Ice::ByteSeq&,
+ const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+ Ice::LoggerPtr _logger;
+ Ice::PropertiesPtr _properties;
+ PasswordVerifierPrx _verifier;
+ int _traceLevel;
+ RSACertificateGenContext _certContext;
+ RSACertificateGen _certificateGenerator;
+};
+
+class CryptPasswordVerifierI : public PasswordVerifier, public IceUtil::Mutex
+{
+public:
+
+ CryptPasswordVerifierI(const std::map<std::string, std::string>&);
+
+ virtual bool checkPassword(const std::string&, const std::string&, const Ice::Current&);
+ virtual void destroy(const Ice::Current&);
+
+private:
+
+ const std::map<std::string, std::string> _passwords;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Acceptor.h b/cpp/src/Ice/Acceptor.h index d690608903a..de2513c749b 100644 --- a/cpp/src/Ice/Acceptor.h +++ b/cpp/src/Ice/Acceptor.h @@ -1,38 +1,38 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ACCEPTOR_H -#define ICE_ACCEPTOR_H - -#include <IceUtil/Shared.h> -#include <Ice/AcceptorF.h> -#include <Ice/TransceiverF.h> - -#ifndef _WIN32 -# define SOCKET int -#endif - -namespace IceInternal -{ - -class ICE_PROTOCOL_API Acceptor : public ::IceUtil::Shared -{ -public: - - virtual SOCKET fd() = 0; - virtual void close() = 0; - virtual void listen() = 0; - virtual TransceiverPtr accept(int) = 0; - virtual std::string toString() const = 0; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ACCEPTOR_H
+#define ICE_ACCEPTOR_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/AcceptorF.h>
+#include <Ice/TransceiverF.h>
+
+#ifndef _WIN32
+# define SOCKET int
+#endif
+
+namespace IceInternal
+{
+
+class ICE_PROTOCOL_API Acceptor : public ::IceUtil::Shared
+{
+public:
+
+ virtual SOCKET fd() = 0;
+ virtual void close() = 0;
+ virtual void listen() = 0;
+ virtual TransceiverPtr accept(int) = 0;
+ virtual std::string toString() const = 0;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/AcceptorF.h b/cpp/src/Ice/AcceptorF.h index b8eb80288d4..a5358606309 100644 --- a/cpp/src/Ice/AcceptorF.h +++ b/cpp/src/Ice/AcceptorF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ACCEPTOR_F_H -#define ICE_ACCEPTOR_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Acceptor; -ICE_PROTOCOL_API void incRef(Acceptor*); -ICE_PROTOCOL_API void decRef(Acceptor*); -typedef Handle<Acceptor> AcceptorPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ACCEPTOR_F_H
+#define ICE_ACCEPTOR_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Acceptor;
+ICE_PROTOCOL_API void incRef(Acceptor*);
+ICE_PROTOCOL_API void decRef(Acceptor*);
+typedef Handle<Acceptor> AcceptorPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp index 7d58a235725..a67707669a4 100644 --- a/cpp/src/Ice/Application.cpp +++ b/cpp/src/Ice/Application.cpp @@ -30,7 +30,7 @@ Ice::Application::~Application() int Ice::Application::main(int argc, char* argv[], const char* configFile) { - if (_communicator) + if(_communicator) { cerr << argv[0] << ": only one instance of the Application class can be used" << endl; return EXIT_FAILURE; @@ -42,7 +42,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile) try { - if (configFile) + if(configFile) { PropertiesPtr properties = createProperties(argc, argv); properties->load(configFile); @@ -65,7 +65,7 @@ Ice::Application::main(int argc, char* argv[], const char* configFile) status = EXIT_FAILURE; } - if (_communicator) + if(_communicator) { try { diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index a960f1d27d8..123178503b6 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -52,7 +52,7 @@ IceInternal::BasicStream::swap(BasicStream& other) void IceInternal::BasicStream::resize(int total) { - if (total > 1024 * 1024) // TODO: configurable + if(total > 1024 * 1024) // TODO: configurable { throw MemoryLimitException(__FILE__, __LINE__); } @@ -62,7 +62,7 @@ IceInternal::BasicStream::resize(int total) void IceInternal::BasicStream::reserve(int total) { - if (total > 1024 * 1024) // TODO: configurable + if(total > 1024 * 1024) // TODO: configurable { throw MemoryLimitException(__FILE__, __LINE__); } @@ -85,7 +85,7 @@ IceInternal::BasicStream::endWriteEncaps() assert(_currentWriteEncaps); int start = _currentWriteEncaps->start; _writeEncapsStack.pop_back(); - if (_writeEncapsStack.empty()) + if(_writeEncapsStack.empty()) { _currentWriteEncaps = 0; } @@ -107,7 +107,7 @@ IceInternal::BasicStream::startReadEncaps() { Byte encoding; read(encoding); - if (encoding != 0) + if(encoding != 0) { throw UnsupportedEncodingException(__FILE__, __LINE__); } @@ -120,7 +120,7 @@ IceInternal::BasicStream::startReadEncaps() // readSize()/writeSize(), it could be 1 or 5 bytes. // read(sz); - if (sz < 0) + if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } @@ -136,7 +136,7 @@ IceInternal::BasicStream::endReadEncaps() assert(_currentReadEncaps); int start = _currentReadEncaps->start; _readEncapsStack.pop_back(); - if (_readEncapsStack.empty()) + if(_readEncapsStack.empty()) { _currentReadEncaps = 0; } @@ -147,12 +147,12 @@ IceInternal::BasicStream::endReadEncaps() i = b.begin() + start - sizeof(Int); Int sz; read(sz); - if (sz < 0) + if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } i += sz; - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -167,12 +167,12 @@ IceInternal::BasicStream::checkReadEncaps() i = b.begin() + start - sizeof(Int); Int sz; read(sz); - if (sz < 0) + if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } i = save; - if (sz != i - (b.begin() + start)) + if(sz != i - (b.begin() + start)) { throw EncapsulationException(__FILE__, __LINE__); } @@ -187,7 +187,7 @@ IceInternal::BasicStream::getReadEncapsSize() i = b.begin() + start - sizeof(Int); Int sz; read(sz); - if (sz < 0) + if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } @@ -200,18 +200,18 @@ IceInternal::BasicStream::skipEncaps() { Byte encoding; read(encoding); - if (encoding != 0) + if(encoding != 0) { throw UnsupportedEncodingException(__FILE__, __LINE__); } Int sz; read(sz); - if (sz < 0) + if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } i += sz; - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -220,7 +220,7 @@ IceInternal::BasicStream::skipEncaps() void IceInternal::BasicStream::writeSize(Int v) { - if (v > 127) + if(v > 127) { write(Byte(-1)); write(v); @@ -236,10 +236,10 @@ IceInternal::BasicStream::readSize(Ice::Int& v) { Byte b; read(b); - if (b < 0) + if(b < 0) { read(v); - if (v < 0) + if(v < 0) { throw NegativeSizeException(__FILE__, __LINE__); } @@ -263,7 +263,7 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz) { Container::iterator begin = i; i += sz; - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -284,7 +284,7 @@ IceInternal::BasicStream::write(const vector<Byte>& v) void IceInternal::BasicStream::read(Byte& v) { - if (i >= b.end()) + if(i >= b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -298,7 +298,7 @@ IceInternal::BasicStream::read(vector<Byte>& v) readSize(sz); Container::iterator begin = i; i += sz; - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -319,7 +319,7 @@ IceInternal::BasicStream::write(const vector<bool>& v) void IceInternal::BasicStream::read(bool& v) { - if (i >= b.end()) + if(i >= b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -333,7 +333,7 @@ IceInternal::BasicStream::read(vector<bool>& v) readSize(sz); Container::iterator begin = i; i += sz; - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -359,13 +359,13 @@ IceInternal::BasicStream::write(const vector<Short>& v) { Int sz = v.size(); writeSize(sz); - if (sz > 0) + if(sz > 0) { int pos = b.size(); resize(pos + sz * sizeof(Short)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Short), b.begin() + pos); p += sizeof(Short); @@ -382,7 +382,7 @@ IceInternal::BasicStream::read(Short& v) { Container::iterator begin = i; i += sizeof(Short); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -400,15 +400,15 @@ IceInternal::BasicStream::read(vector<Short>& v) readSize(sz); Container::iterator begin = i; i += sz * sizeof(Short); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); - if (sz > 0) + if(sz > 0) { #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Short), reinterpret_cast<Byte*>(&v[j])); begin += sizeof(Short); @@ -437,13 +437,13 @@ IceInternal::BasicStream::write(const vector<Int>& v) { Int sz = v.size(); writeSize(sz); - if (sz > 0) + if(sz > 0) { int pos = b.size(); resize(pos + sz * sizeof(Int)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Int), b.begin() + pos); p += sizeof(Int); @@ -460,7 +460,7 @@ IceInternal::BasicStream::read(Int& v) { Container::iterator begin = i; i += sizeof(Int); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -478,15 +478,15 @@ IceInternal::BasicStream::read(vector<Int>& v) readSize(sz); Container::iterator begin = i; i += sz * sizeof(Int); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); - if (sz > 0) + if(sz > 0) { #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Int), reinterpret_cast<Byte*>(&v[j])); begin += sizeof(Int); @@ -515,13 +515,13 @@ IceInternal::BasicStream::write(const vector<Long>& v) { Int sz = v.size(); writeSize(sz); - if (sz > 0) + if(sz > 0) { int pos = b.size(); resize(pos + sz * sizeof(Long)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Long), b.begin() + pos); p += sizeof(Long); @@ -538,7 +538,7 @@ IceInternal::BasicStream::read(Long& v) { Container::iterator begin = i; i += sizeof(Long); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -556,15 +556,15 @@ IceInternal::BasicStream::read(vector<Long>& v) readSize(sz); Container::iterator begin = i; i += sz * sizeof(Long); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); - if (sz > 0) + if(sz > 0) { #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Long), reinterpret_cast<Byte*>(&v[j])); begin += sizeof(Long); @@ -593,13 +593,13 @@ IceInternal::BasicStream::write(const vector<Float>& v) { Int sz = v.size(); writeSize(sz); - if (sz > 0) + if(sz > 0) { int pos = b.size(); resize(pos + sz * sizeof(Float)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Float), b.begin() + pos); p += sizeof(Float); @@ -616,7 +616,7 @@ IceInternal::BasicStream::read(Float& v) { Container::iterator begin = i; i += sizeof(Float); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -634,15 +634,15 @@ IceInternal::BasicStream::read(vector<Float>& v) readSize(sz); Container::iterator begin = i; i += sz * sizeof(Float); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); - if (sz > 0) + if(sz > 0) { #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Float), reinterpret_cast<Byte*>(&v[j])); begin += sizeof(Float); @@ -671,13 +671,13 @@ IceInternal::BasicStream::write(const vector<Double>& v) { Int sz = v.size(); writeSize(sz); - if (sz > 0) + if(sz > 0) { int pos = b.size(); resize(pos + sz * sizeof(Double)); const Byte* p = reinterpret_cast<const Byte*>(&v[0]); #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(p, p + sizeof(Double), b.begin() + pos); p += sizeof(Double); @@ -694,7 +694,7 @@ IceInternal::BasicStream::read(Double& v) { Container::iterator begin = i; i += sizeof(Double); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -712,15 +712,15 @@ IceInternal::BasicStream::read(vector<Double>& v) readSize(sz); Container::iterator begin = i; i += sz * sizeof(Double); - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } v.resize(sz); - if (sz > 0) + if(sz > 0) { #ifdef ICE_UTIL_BIGENDIAN - for (int j = 0 ; j < sz ; ++j) + for(int j = 0 ; j < sz ; ++j) { reverse_copy(begin, begin + sizeof(Double), reinterpret_cast<Byte*>(&v[j])); begin += sizeof(Double); @@ -736,7 +736,7 @@ IceInternal::BasicStream::write(const string& v) { Int len = v.size(); writeSize(len); - if (len > 0) + if(len > 0) { int pos = b.size(); resize(pos + len); @@ -749,7 +749,7 @@ IceInternal::BasicStream::write(const vector<string>& v) { writeSize(Int(v.size())); vector<string>::const_iterator p; - for (p = v.begin(); p != v.end(); ++p) + for(p = v.begin(); p != v.end(); ++p) { write(*p); } @@ -761,7 +761,7 @@ IceInternal::BasicStream::read(string& v) Int len; readSize(len); - if (len <= 0) + if(len <= 0) { v.erase(); } @@ -769,7 +769,7 @@ IceInternal::BasicStream::read(string& v) { Container::iterator begin = i; i += len; - if (i > b.end()) + if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } @@ -785,7 +785,7 @@ IceInternal::BasicStream::read(vector<string>& v) readSize(sz); // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot be // checked whether sz is a reasonable value - while (sz--) + while(sz--) { string s; read(s); @@ -808,14 +808,14 @@ IceInternal::BasicStream::read(ObjectPrx& v) void IceInternal::BasicStream::write(const ObjectPtr& v) { - if (!_currentWriteEncaps) // Lazy initialization + if(!_currentWriteEncaps) // Lazy initialization { _writeEncapsStack.resize(1); _currentWriteEncaps = &_writeEncapsStack.back(); } map<ObjectPtr, Int>::const_iterator p = _currentWriteEncaps->objectsWritten.find(v.get()); - if (p != _currentWriteEncaps->objectsWritten.end()) + if(p != _currentWriteEncaps->objectsWritten.end()) { write(p->second); } @@ -823,7 +823,7 @@ IceInternal::BasicStream::write(const ObjectPtr& v) { write(Int(-1)); - if (v) + if(v) { Int num = _currentWriteEncaps->objectsWritten.size(); _currentWriteEncaps->objectsWritten[v.get()] = num; @@ -841,7 +841,7 @@ IceInternal::BasicStream::write(const ObjectPtr& v) void IceInternal::BasicStream::read(const string& signatureType, const ObjectFactoryPtr& factory, ObjectPtr& v) { - if (!_currentReadEncaps) // Lazy initialization + if(!_currentReadEncaps) // Lazy initialization { _readEncapsStack.resize(1); _currentReadEncaps = &_readEncapsStack.back(); @@ -850,9 +850,9 @@ IceInternal::BasicStream::read(const string& signatureType, const ObjectFactoryP Int pos; read(pos); - if (pos >= 0) + if(pos >= 0) { - if (static_cast<vector<ObjectPtr>::size_type>(pos) >= _currentReadEncaps->objectsRead.size()) + if(static_cast<vector<ObjectPtr>::size_type>(pos) >= _currentReadEncaps->objectsRead.size()) { throw IllegalIndirectionException(__FILE__, __LINE__); } @@ -864,31 +864,31 @@ IceInternal::BasicStream::read(const string& signatureType, const ObjectFactoryP string id; read(id); - if (id.empty()) + if(id.empty()) { v = 0; return; } - else if (id == iceObject) + else if(id == iceObject) { v = new ::Ice::Object; } else { ObjectFactoryPtr userFactory = _instance->servantFactoryManager()->find(id); - if (userFactory) + if(userFactory) { v = userFactory->create(id); } - if (!v && id == signatureType) + if(!v && id == signatureType) { assert(factory); v = factory->create(id); assert(v); } - if (!v) + if(!v) { throw NoObjectFactoryException(__FILE__, __LINE__); } @@ -912,7 +912,7 @@ IceInternal::BasicStream::throwException(const string* throwsBegin, const string read(id); UserExceptionFactoryPtr factory = _instance->userExceptionFactoryManager()->find(id); - if (factory) + if(factory) { try { @@ -921,9 +921,9 @@ IceInternal::BasicStream::throwException(const string* throwsBegin, const string catch (UserException& ex) { static const string userException("::Ice::UserException"); - for (const string* p = ex.__getExceptionIds(); *p != userException != 0; ++p) + for(const string* p = ex.__getExceptionIds(); *p != userException != 0; ++p) { - if (binary_search(throwsBegin, throwsEnd, string(*p))) + if(binary_search(throwsBegin, throwsEnd, string(*p))) { ex.__read(this); ex.ice_throw(); @@ -935,7 +935,7 @@ IceInternal::BasicStream::throwException(const string* throwsBegin, const string } pair<const string*, const string*> p = equal_range(throwsBegin, throwsEnd, id); - if (p.first != p.second) + if(p.first != p.second) { return p.first - throwsBegin; } diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 8a8249f8f2a..03777f69253 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -29,7 +29,7 @@ Ice::CommunicatorI::destroy() { RecMutex::Lock sync(*this); - if (_instance) + if(_instance) { _instance->objectAdapterFactory()->shutdown(); _instance->destroy(); @@ -43,7 +43,7 @@ Ice::CommunicatorI::shutdown() // // No mutex locking here! This operation must be signal-safe. // - if (_serverThreadPool) + if(_serverThreadPool) { _serverThreadPool->initiateShutdown(); } @@ -56,7 +56,7 @@ Ice::CommunicatorI::waitForShutdown() // No mutex locking here, otherwise the communicator is blocked // while waiting for shutdown. // - if (_serverThreadPool) + if(_serverThreadPool) { _serverThreadPool->waitUntilFinished(); } @@ -66,7 +66,7 @@ ObjectPrx Ice::CommunicatorI::stringToProxy(const string& s) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -77,7 +77,7 @@ string Ice::CommunicatorI::proxyToString(const ObjectPrx& proxy) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -88,7 +88,7 @@ ObjectAdapterPtr Ice::CommunicatorI::createObjectAdapter(const string& name) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -96,12 +96,12 @@ Ice::CommunicatorI::createObjectAdapter(const string& name) ObjectAdapterPtr adapter = createObjectAdapterFromProperty(name, "Ice.Adapter." + name + ".Endpoints"); string router = _instance->properties()->getProperty("Ice.Adapter." + name + ".Router"); - if (!router.empty()) + if(!router.empty()) { adapter->addRouter(RouterPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(router))); } - if (!_serverThreadPool) // Lazy initialization of _serverThreadPool. + if(!_serverThreadPool) // Lazy initialization of _serverThreadPool. { _serverThreadPool = _instance->serverThreadPool(); } @@ -113,7 +113,7 @@ ObjectAdapterPtr Ice::CommunicatorI::createObjectAdapterFromProperty(const string& name, const string& property) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -127,14 +127,14 @@ ObjectAdapterPtr Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const string& endpts) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } ObjectAdapterPtr adapter = _instance->objectAdapterFactory()->createObjectAdapter(name, endpts); - if (!_serverThreadPool) // Lazy initialization of _serverThreadPool. + if(!_serverThreadPool) // Lazy initialization of _serverThreadPool. { _serverThreadPool = _instance->serverThreadPool(); } @@ -146,7 +146,7 @@ void Ice::CommunicatorI::addObjectFactory(const ObjectFactoryPtr& factory, const string& id) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -157,7 +157,7 @@ void Ice::CommunicatorI::removeObjectFactory(const string& id) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -168,7 +168,7 @@ ObjectFactoryPtr Ice::CommunicatorI::findObjectFactory(const string& id) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -179,7 +179,7 @@ void Ice::CommunicatorI::addUserExceptionFactory(const UserExceptionFactoryPtr& factory, const string& id) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -190,7 +190,7 @@ void Ice::CommunicatorI::removeUserExceptionFactory(const string& id) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -201,7 +201,7 @@ UserExceptionFactoryPtr Ice::CommunicatorI::findUserExceptionFactory(const string& id) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -212,7 +212,7 @@ PropertiesPtr Ice::CommunicatorI::getProperties() { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -223,7 +223,7 @@ LoggerPtr Ice::CommunicatorI::getLogger() { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -234,7 +234,7 @@ void Ice::CommunicatorI::setLogger(const LoggerPtr& logger) { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -251,7 +251,7 @@ PluginManagerPtr Ice::CommunicatorI::getPluginManager() { RecMutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -275,7 +275,7 @@ Ice::CommunicatorI::CommunicatorI(int& argc, char* argv[], const PropertiesPtr& Ice::CommunicatorI::~CommunicatorI() { - if (_instance) + if(_instance) { Warning out(_instance->logger()); out << "communicator has not been destroyed"; diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index 7e78e07efab..51a585cafe3 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -1,84 +1,84 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_COMMUNICATOR_I_H -#define ICE_COMMUNICATOR_I_H - -#include <IceUtil/RecMutex.h> - -#include <Ice/ThreadPoolF.h> -#include <Ice/Initialize.h> -#include <Ice/Communicator.h> - -namespace Ice -{ - -class CommunicatorI : public Communicator, public ::IceUtil::RecMutex -{ -public: - - virtual void destroy(); - virtual void shutdown(); - virtual void waitForShutdown(); - - virtual ObjectPrx stringToProxy(const std::string&); - virtual std::string proxyToString(const ObjectPrx&); - - virtual ObjectAdapterPtr createObjectAdapter(const std::string&); - virtual ObjectAdapterPtr createObjectAdapterFromProperty(const std::string&, const std::string&); - virtual ObjectAdapterPtr createObjectAdapterWithEndpoints(const std::string&, const std::string&); - - virtual void addObjectFactory(const ObjectFactoryPtr&, const std::string&); - virtual void removeObjectFactory(const std::string&); - virtual ObjectFactoryPtr findObjectFactory(const std::string&); - - virtual void addUserExceptionFactory(const UserExceptionFactoryPtr&, const std::string&); - virtual void removeUserExceptionFactory(const std::string&); - virtual UserExceptionFactoryPtr findUserExceptionFactory(const std::string&); - - virtual PropertiesPtr getProperties(); - - virtual LoggerPtr getLogger(); - virtual void setLogger(const LoggerPtr&); - - virtual void setDefaultRouter(const RouterPrx&); - - virtual PluginManagerPtr getPluginManager(); - -private: - - CommunicatorI(int&, char*[], const PropertiesPtr&); - virtual ~CommunicatorI(); - - // - // Certain initialization tasks need to be completed after the - // constructor. - // - void finishSetup(int&, char*[]); - - friend ICE_API CommunicatorPtr initialize(int&, char*[], Int); - friend ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int); - friend ICE_API ::IceInternal::InstancePtr IceInternal::getInstance(const ::Ice::CommunicatorPtr&); - - ::IceInternal::InstancePtr _instance; - - // - // We need _serverThreadPool directly in CommunicatorI. That's - // because the shutdown() operation is signal-safe, and thus must - // not access any mutex locks or _instance. It may only access - // _serverThreadPool->initiateShutdown(), which is signal-safe as - // well. - // - ::IceInternal::ThreadPoolPtr _serverThreadPool; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_COMMUNICATOR_I_H
+#define ICE_COMMUNICATOR_I_H
+
+#include <IceUtil/RecMutex.h>
+
+#include <Ice/ThreadPoolF.h>
+#include <Ice/Initialize.h>
+#include <Ice/Communicator.h>
+
+namespace Ice
+{
+
+class CommunicatorI : public Communicator, public ::IceUtil::RecMutex
+{
+public:
+
+ virtual void destroy();
+ virtual void shutdown();
+ virtual void waitForShutdown();
+
+ virtual ObjectPrx stringToProxy(const std::string&);
+ virtual std::string proxyToString(const ObjectPrx&);
+
+ virtual ObjectAdapterPtr createObjectAdapter(const std::string&);
+ virtual ObjectAdapterPtr createObjectAdapterFromProperty(const std::string&, const std::string&);
+ virtual ObjectAdapterPtr createObjectAdapterWithEndpoints(const std::string&, const std::string&);
+
+ virtual void addObjectFactory(const ObjectFactoryPtr&, const std::string&);
+ virtual void removeObjectFactory(const std::string&);
+ virtual ObjectFactoryPtr findObjectFactory(const std::string&);
+
+ virtual void addUserExceptionFactory(const UserExceptionFactoryPtr&, const std::string&);
+ virtual void removeUserExceptionFactory(const std::string&);
+ virtual UserExceptionFactoryPtr findUserExceptionFactory(const std::string&);
+
+ virtual PropertiesPtr getProperties();
+
+ virtual LoggerPtr getLogger();
+ virtual void setLogger(const LoggerPtr&);
+
+ virtual void setDefaultRouter(const RouterPrx&);
+
+ virtual PluginManagerPtr getPluginManager();
+
+private:
+
+ CommunicatorI(int&, char*[], const PropertiesPtr&);
+ virtual ~CommunicatorI();
+
+ //
+ // Certain initialization tasks need to be completed after the
+ // constructor.
+ //
+ void finishSetup(int&, char*[]);
+
+ friend ICE_API CommunicatorPtr initialize(int&, char*[], Int);
+ friend ICE_API CommunicatorPtr initializeWithProperties(int&, char*[], const PropertiesPtr&, Int);
+ friend ICE_API ::IceInternal::InstancePtr IceInternal::getInstance(const ::Ice::CommunicatorPtr&);
+
+ ::IceInternal::InstancePtr _instance;
+
+ //
+ // We need _serverThreadPool directly in CommunicatorI. That's
+ // because the shutdown() operation is signal-safe, and thus must
+ // not access any mutex locks or _instance. It may only access
+ // _serverThreadPool->initiateShutdown(), which is signal-safe as
+ // well.
+ //
+ ::IceInternal::ThreadPoolPtr _serverThreadPool;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index dbebc358240..60efc551c80 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -66,7 +66,7 @@ IceInternal::Connection::decProxyUsageCount() IceUtil::RecMutex::Lock sync(*this); assert(_proxyUsageCount > 0); --_proxyUsageCount; - if (_proxyUsageCount == 0 && !_adapter) + if(_proxyUsageCount == 0 && !_adapter) { assert(_requests.empty()); setState(StateClosing, CloseConnectionException(__FILE__, __LINE__)); @@ -89,7 +89,7 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool comp) { IceUtil::RecMutex::Lock sync(*this); - if (_exception.get()) + if(_exception.get()) { _exception->ice_throw(); } @@ -104,10 +104,10 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool comp) // // Fill in the request ID. // - if (!_endpoint->datagram() && !oneway) + if(!_endpoint->datagram() && !oneway) { requestId = _nextRequestId++; - if (requestId <= 0) + if(requestId <= 0) { _nextRequestId = 1; requestId = _nextRequestId++; @@ -117,19 +117,19 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool comp) copy(p, p + sizeof(Int), os->b.begin() + headerSize); } - if (os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. + if(os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { comp = false; } else { - if (_defaultsAndOverrides->overrideComppress) + if(_defaultsAndOverrides->overrideComppress) { comp = _defaultsAndOverrides->overrideComppressValue; } } - if (comp) + if(comp) { // // Change message type. @@ -178,7 +178,7 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool comp) // Only add to the request map if there was no exception, and if // the operation is not oneway. // - if (!_endpoint->datagram() && !oneway) + if(!_endpoint->datagram() && !oneway) { _requestsHint = _requests.insert(_requests.end(), make_pair(requestId, out)); } @@ -189,7 +189,7 @@ IceInternal::Connection::prepareBatchRequest(Outgoing* out) { lock(); - if (_exception.get()) + if(_exception.get()) { unlock(); _exception->ice_throw(); @@ -201,7 +201,7 @@ IceInternal::Connection::prepareBatchRequest(Outgoing* out) // is called. // - if (_batchStream.b.empty()) + if(_batchStream.b.empty()) { _batchStream.write(protocolVersion); _batchStream.write(encodingVersion); @@ -219,7 +219,7 @@ IceInternal::Connection::prepareBatchRequest(Outgoing* out) void IceInternal::Connection::finishBatchRequest(Outgoing* out) { - if (_exception.get()) + if(_exception.get()) { unlock(); _exception->ice_throw(); @@ -242,7 +242,7 @@ IceInternal::Connection::flushBatchRequest(bool comp) { IceUtil::RecMutex::Lock sync(*this); - if (_exception.get()) + if(_exception.get()) { _exception->ice_throw(); } @@ -257,19 +257,19 @@ IceInternal::Connection::flushBatchRequest(bool comp) _batchStream.i = _batchStream.b.begin(); - if (_batchStream.b.size() < 100) // Don't compress if message size is smaller than 100 bytes. + if(_batchStream.b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { comp = false; } else { - if (_defaultsAndOverrides->overrideComppress) + if(_defaultsAndOverrides->overrideComppress) { comp = _defaultsAndOverrides->overrideComppressValue; } } - if (comp) + if(comp) { // // Change message type. @@ -346,9 +346,9 @@ IceInternal::Connection::setAdapter(const ObjectAdapterPtr& adapter) // mode. However, we only change subscription if we're in active // mode, and thus ignore closing mode here.k // - if (_state == StateActive) + if(_state == StateActive) { - if (adapter && !_adapter) + if(adapter && !_adapter) { // // Client is now server. @@ -356,7 +356,7 @@ IceInternal::Connection::setAdapter(const ObjectAdapterPtr& adapter) unregisterWithPool(); } - if (!adapter && _adapter) + if(!adapter && _adapter) { // // Server is now client. @@ -399,7 +399,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa threadPool->promoteFollower(); - if (_state == StateClosed) + if(_state == StateClosed) { IceUtil::ThreadControl::yield(); return; @@ -416,7 +416,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa // // Uncompress if necessary. // - if (messageType == compressedRequestMsg || + if(messageType == compressedRequestMsg || messageType == compressedRequestBatchMsg || messageType == compressedReplyMsg) { @@ -428,11 +428,11 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa stream.i = stream.b.begin() + headerSize; - switch (messageType) + switch(messageType) { case requestMsg: { - if (_state == StateClosing) + if(_state == StateClosing) { traceRequest("received request during closing\n" "(ignored by server, client will retry)", @@ -448,7 +448,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa case compressedRequestMsg: { - if (_state == StateClosing) + if(_state == StateClosing) { traceRequest("received compressed request during closing\n" "(ignored by server, client will retry)", @@ -464,7 +464,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa case requestBatchMsg: { - if (_state == StateClosing) + if(_state == StateClosing) { traceBatchRequest("received batch request during closing\n" "(ignored by server, client will retry)", @@ -481,7 +481,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa case compressedRequestBatchMsg: { - if (_state == StateClosing) + if(_state == StateClosing) { traceBatchRequest("received compressed batch request during closing\n" "(ignored by server, client will retry)", @@ -499,7 +499,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa case replyMsg: case compressedReplyMsg: { - if (messageType == compressedReplyMsg) + if(messageType == compressedReplyMsg) { traceReply("received compressed reply", stream, _logger, _traceLevels); } @@ -513,27 +513,27 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa map<Int, Outgoing*>::iterator p = _requests.end(); - if (_requestsHint != _requests.end()) + if(_requestsHint != _requests.end()) { - if (_requestsHint->first == requestId) + if(_requestsHint->first == requestId) { p = _requestsHint; } } - if (p == _requests.end()) + if(p == _requests.end()) { p = _requests.find(requestId); } - if (p == _requests.end()) + if(p == _requests.end()) { throw UnknownRequestIdException(__FILE__, __LINE__); } p->second->finished(stream); - if (p == _requestsHint) + if(p == _requestsHint) { _requests.erase(p++); _requestsHint = p; @@ -549,9 +549,9 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa case closeConnectionMsg: { traceHeader("received close connection", stream, _logger, _traceLevels); - if (_endpoint->datagram()) + if(_endpoint->datagram()) { - if (_warn) + if(_warn) { Warning out(_logger); out << "ignoring close connection message for datagram connection:\n" @@ -586,7 +586,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa // Method invocation must be done outside the thread // synchronization, so that nested callbacks are possible. // - if (invoke) + if(invoke) { Incoming in(_instance, _adapter); BasicStream* is = in.is(); @@ -597,11 +597,11 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa try { - if (!batch) + if(!batch) { Int requestId; is->read(requestId); - if (!_endpoint->datagram() && requestId != 0) // 0 means oneway. + if(!_endpoint->datagram() && requestId != 0) // 0 means oneway. { response = true; ++_responseCount; @@ -622,7 +622,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa catch (const LocalException& ex) { IceUtil::RecMutex::Lock sync(*this); - if (_warn) + if(_warn) { Warning out(_logger); out << "connection exception:\n" << ex << '\n' << _transceiver->toString(); @@ -631,7 +631,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa catch (const UserException& ex) { IceUtil::RecMutex::Lock sync(*this); - if (_warn) + if(_warn) { Warning out(_logger); out << "unknown user exception:\n" << ex << '\n' << _transceiver->toString(); @@ -640,14 +640,14 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa catch (...) { IceUtil::RecMutex::Lock sync(*this); - if (_warn) + if(_warn) { Warning out(_logger); out << "unknown exception"; } } } - while (batch && is->i < is->b.end()); + while(batch && is->i < is->b.end()); } catch (const LocalException& ex) { @@ -656,31 +656,31 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa return; } - if (response) + if(response) { IceUtil::RecMutex::Lock sync(*this); try { - if (_state == StateClosed) + if(_state == StateClosed) { return; } - if (os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. + if(os->b.size() < 100) // Don't compress if message size is smaller than 100 bytes. { comp = false; } else { - if (_defaultsAndOverrides->overrideComppress) + if(_defaultsAndOverrides->overrideComppress) { comp = _defaultsAndOverrides->overrideComppressValue; } } - if (comp) + if(comp) { // // Change message type. @@ -721,7 +721,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa --_responseCount; - if (_state == StateClosing && _responseCount == 0 && !_endpoint->datagram()) + if(_state == StateClosing && _responseCount == 0 && !_endpoint->datagram()) { closeConnection(); } @@ -742,11 +742,11 @@ IceInternal::Connection::finished(const ThreadPoolPtr& threadPool) threadPool->promoteFollower(); - if (_state == StateActive || _state == StateClosing) + if(_state == StateActive || _state == StateClosing) { registerWithPool(); } - else if (_state == StateClosed) + else if(_state == StateClosed) { _transceiver->close(); } @@ -818,7 +818,7 @@ IceInternal::Connection::destroy(DestructionReason reason) { RecMutex::Lock sync(*this); - switch (reason) + switch(reason) { case ObjectAdapterDeactivated: { @@ -837,21 +837,21 @@ IceInternal::Connection::destroy(DestructionReason reason) void IceInternal::Connection::setState(State state, const LocalException& ex) { - if (_state == state) // Don't switch twice. + if(_state == state) // Don't switch twice. { return; } - if (!_exception.get()) + if(!_exception.get()) { _exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex.ice_clone())); - if (_warn) + if(_warn) { // // Don't warn about certain expected exceptions. // - if (!(dynamic_cast<const CloseConnectionException*>(&ex) || + if(!(dynamic_cast<const CloseConnectionException*>(&ex) || dynamic_cast<const CommunicatorDestroyedException*>(&ex) || dynamic_cast<const ObjectAdapterDeactivatedException*>(&ex) || (dynamic_cast<const ConnectionLostException*>(&ex) && _state == StateClosing))) @@ -862,7 +862,7 @@ IceInternal::Connection::setState(State state, const LocalException& ex) } } - for (std::map< ::Ice::Int, Outgoing*>::iterator p = _requests.begin(); p != _requests.end(); ++p) + for(std::map< ::Ice::Int, Outgoing*>::iterator p = _requests.begin(); p != _requests.end(); ++p) { p->second->finished(*_exception.get()); } @@ -879,21 +879,21 @@ IceInternal::Connection::setState(State state) // We don't want to send close connection messages if the endpoint // only supports oneway transmission from client to server. // - if (_endpoint->datagram() && state == StateClosing) + if(_endpoint->datagram() && state == StateClosing) { state = StateClosed; } - if (_state == state) // Don't switch twice. + if(_state == state) // Don't switch twice. { return; } - switch (state) + switch(state) { case StateActive: { - if (_state != StateHolding) // Can only switch from holding to active. + if(_state != StateHolding) // Can only switch from holding to active. { return; } @@ -903,7 +903,7 @@ IceInternal::Connection::setState(State state) case StateHolding: { - if (_state != StateActive) // Can only switch from active to holding. + if(_state != StateActive) // Can only switch from active to holding. { return; } @@ -913,11 +913,11 @@ IceInternal::Connection::setState(State state) case StateClosing: { - if (_state == StateClosed) // Can't change back from closed. + if(_state == StateClosed) // Can't change back from closed. { return; } - if (_state == StateHolding) + if(_state == StateHolding) { // // We need to continue to read data in closing state. @@ -929,7 +929,7 @@ IceInternal::Connection::setState(State state) case StateClosed: { - if (_state == StateHolding) + if(_state == StateHolding) { // // If we come from holding state, we first need to @@ -945,7 +945,7 @@ IceInternal::Connection::setState(State state) _state = state; - if (_state == StateClosing && _responseCount == 0 && !_endpoint->datagram()) + if(_state == StateClosing && _responseCount == 0 && !_endpoint->datagram()) { try { @@ -975,11 +975,11 @@ IceInternal::Connection::closeConnection() void IceInternal::Connection::registerWithPool() { - if (!_registeredWithPool) + if(!_registeredWithPool) { - if (_adapter) + if(_adapter) { - if (!_serverThreadPool) + if(!_serverThreadPool) { _serverThreadPool = _instance->serverThreadPool(); assert(_serverThreadPool); @@ -988,7 +988,7 @@ IceInternal::Connection::registerWithPool() } else { - if (!_clientThreadPool) + if(!_clientThreadPool) { _clientThreadPool = _instance->clientThreadPool(); assert(_clientThreadPool); @@ -1003,9 +1003,9 @@ IceInternal::Connection::registerWithPool() void IceInternal::Connection::unregisterWithPool() { - if (_registeredWithPool) + if(_registeredWithPool) { - if (_adapter) + if(_adapter) { assert(_serverThreadPool); _serverThreadPool->unregister(_transceiver->fd()); @@ -1034,7 +1034,7 @@ IceInternal::Connection::compress(BasicStream& uncompressed, BasicStream& compre int bzError = BZ2_bzBuffToBuffCompress(&compressed.b[0] + headerSize + sizeof(Int), &compressedLen, &uncompressed.b[0] + headerSize, uncompressedLen, 1, 0, 0); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { throw CompressionException(__FILE__, __LINE__); } @@ -1069,7 +1069,7 @@ IceInternal::Connection::uncompress(BasicStream& compressed, BasicStream& uncomp Int uncompressedSize; compressed.i = compressed.b.begin() + headerSize; compressed.read(uncompressedSize); - if (uncompressedSize <= headerSize) + if(uncompressedSize <= headerSize) { throw IllegalMessageSizeException(__FILE__, __LINE__); } @@ -1082,7 +1082,7 @@ IceInternal::Connection::uncompress(BasicStream& compressed, BasicStream& uncomp &compressed.b[0] + headerSize + sizeof(Int), compressedLen, 0, 0); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { throw CompressionException(__FILE__, __LINE__); } diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h index 0128cd029f8..010745d0dc1 100644 --- a/cpp/src/Ice/Connection.h +++ b/cpp/src/Ice/Connection.h @@ -1,121 +1,121 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONNECTION_H -#define ICE_CONNECTION_H - -#include <IceUtil/RecMutex.h> - -#include <Ice/ConnectionF.h> -#include <Ice/ConnectionFactoryF.h> -#include <Ice/InstanceF.h> -#include <Ice/TransceiverF.h> -#include <Ice/ObjectAdapterF.h> -#include <Ice/EndpointF.h> -#include <Ice/ThreadPoolF.h> -#include <Ice/LoggerF.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/DefaultsAndOverridesF.h> -#include <Ice/EventHandler.h> - -namespace Ice -{ - -class LocalException; - -} - -namespace IceInternal -{ - -class Outgoing; - -class Connection : public EventHandler, public ::IceUtil::RecMutex -{ -public: - - bool destroyed() const; - void hold(); - void activate(); - void incProxyUsageCount(); - void decProxyUsageCount(); - void prepareRequest(Outgoing*); - void sendRequest(Outgoing*, bool, bool); - void removeRequest(Outgoing*); - void prepareBatchRequest(Outgoing*); - void finishBatchRequest(Outgoing*); - void abortBatchRequest(); - void flushBatchRequest(bool); - int timeout() const; - EndpointPtr endpoint() const; - void setAdapter(const ::Ice::ObjectAdapterPtr&); - ::Ice::ObjectAdapterPtr getAdapter() const; - - // - // Operations from EventHandler - // - virtual bool readable() const; - virtual void read(BasicStream&); - virtual void message(BasicStream&, const ThreadPoolPtr&); - virtual void finished(const ThreadPoolPtr&); - virtual void exception(const ::Ice::LocalException&); - -private: - - Connection(const InstancePtr&, const TransceiverPtr&, const EndpointPtr&, const ::Ice::ObjectAdapterPtr&); - virtual ~Connection(); - enum DestructionReason - { - ObjectAdapterDeactivated, - CommunicatorDestroyed - }; - void destroy(DestructionReason); - friend class IncomingConnectionFactory; - friend class OutgoingConnectionFactory; - - enum State - { - StateActive, - StateHolding, - StateClosing, - StateClosed - }; - - void setState(State, const ::Ice::LocalException&); - void setState(State); - void closeConnection(); - void registerWithPool(); - void unregisterWithPool(); - void compress(BasicStream&, BasicStream&); - void uncompress(BasicStream&, BasicStream&); - - TransceiverPtr _transceiver; - EndpointPtr _endpoint; - ::Ice::ObjectAdapterPtr _adapter; - ::Ice::LoggerPtr _logger; - TraceLevelsPtr _traceLevels; - DefaultsAndOverridesPtr _defaultsAndOverrides; - ThreadPoolPtr _clientThreadPool; - ThreadPoolPtr _serverThreadPool; - ::Ice::Int _nextRequestId; - std::map< ::Ice::Int, Outgoing*> _requests; - std::map< ::Ice::Int, Outgoing*>::iterator _requestsHint; - std::auto_ptr< ::Ice::LocalException> _exception; - BasicStream _batchStream; - int _responseCount; - int _proxyUsageCount; - State _state; - bool _warn; - bool _registeredWithPool; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONNECTION_H
+#define ICE_CONNECTION_H
+
+#include <IceUtil/RecMutex.h>
+
+#include <Ice/ConnectionF.h>
+#include <Ice/ConnectionFactoryF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/TransceiverF.h>
+#include <Ice/ObjectAdapterF.h>
+#include <Ice/EndpointF.h>
+#include <Ice/ThreadPoolF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/DefaultsAndOverridesF.h>
+#include <Ice/EventHandler.h>
+
+namespace Ice
+{
+
+class LocalException;
+
+}
+
+namespace IceInternal
+{
+
+class Outgoing;
+
+class Connection : public EventHandler, public ::IceUtil::RecMutex
+{
+public:
+
+ bool destroyed() const;
+ void hold();
+ void activate();
+ void incProxyUsageCount();
+ void decProxyUsageCount();
+ void prepareRequest(Outgoing*);
+ void sendRequest(Outgoing*, bool, bool);
+ void removeRequest(Outgoing*);
+ void prepareBatchRequest(Outgoing*);
+ void finishBatchRequest(Outgoing*);
+ void abortBatchRequest();
+ void flushBatchRequest(bool);
+ int timeout() const;
+ EndpointPtr endpoint() const;
+ void setAdapter(const ::Ice::ObjectAdapterPtr&);
+ ::Ice::ObjectAdapterPtr getAdapter() const;
+
+ //
+ // Operations from EventHandler
+ //
+ virtual bool readable() const;
+ virtual void read(BasicStream&);
+ virtual void message(BasicStream&, const ThreadPoolPtr&);
+ virtual void finished(const ThreadPoolPtr&);
+ virtual void exception(const ::Ice::LocalException&);
+
+private:
+
+ Connection(const InstancePtr&, const TransceiverPtr&, const EndpointPtr&, const ::Ice::ObjectAdapterPtr&);
+ virtual ~Connection();
+ enum DestructionReason
+ {
+ ObjectAdapterDeactivated,
+ CommunicatorDestroyed
+ };
+ void destroy(DestructionReason);
+ friend class IncomingConnectionFactory;
+ friend class OutgoingConnectionFactory;
+
+ enum State
+ {
+ StateActive,
+ StateHolding,
+ StateClosing,
+ StateClosed
+ };
+
+ void setState(State, const ::Ice::LocalException&);
+ void setState(State);
+ void closeConnection();
+ void registerWithPool();
+ void unregisterWithPool();
+ void compress(BasicStream&, BasicStream&);
+ void uncompress(BasicStream&, BasicStream&);
+
+ TransceiverPtr _transceiver;
+ EndpointPtr _endpoint;
+ ::Ice::ObjectAdapterPtr _adapter;
+ ::Ice::LoggerPtr _logger;
+ TraceLevelsPtr _traceLevels;
+ DefaultsAndOverridesPtr _defaultsAndOverrides;
+ ThreadPoolPtr _clientThreadPool;
+ ThreadPoolPtr _serverThreadPool;
+ ::Ice::Int _nextRequestId;
+ std::map< ::Ice::Int, Outgoing*> _requests;
+ std::map< ::Ice::Int, Outgoing*>::iterator _requestsHint;
+ std::auto_ptr< ::Ice::LocalException> _exception;
+ BasicStream _batchStream;
+ int _responseCount;
+ int _proxyUsageCount;
+ State _state;
+ bool _warn;
+ bool _registeredWithPool;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index bd28f451dde..b8ad2339a69 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -41,7 +41,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -52,9 +52,9 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi // Reap destroyed connections. // std::map<EndpointPtr, ConnectionPtr>::iterator p = _connections.begin(); - while (p != _connections.end()) + while(p != _connections.end()) { - if (p->second->destroyed()) + if(p->second->destroyed()) { _connections.erase(p++); } @@ -69,16 +69,16 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi // DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); vector<EndpointPtr>::const_iterator q; - for (q = endpoints.begin(); q != endpoints.end(); ++q) + for(q = endpoints.begin(); q != endpoints.end(); ++q) { EndpointPtr endpoint = *q; - if (defaultsAndOverrides->overrideTimeout) + if(defaultsAndOverrides->overrideTimeout) { endpoint = endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } map<EndpointPtr, ConnectionPtr>::const_iterator r = _connections.find(endpoint); - if (r != _connections.end()) + if(r != _connections.end()) { return r->second; } @@ -93,10 +93,10 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi ConnectionPtr connection; auto_ptr<LocalException> exception; q = endpoints.begin(); - while (q != endpoints.end()) + while(q != endpoints.end()) { EndpointPtr endpoint = *q; - if (defaultsAndOverrides->overrideTimeout) + if(defaultsAndOverrides->overrideTimeout) { endpoint = endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } @@ -104,7 +104,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi try { TransceiverPtr transceiver = endpoint->clientTransceiver(); - if (!transceiver) + if(!transceiver) { ConnectorPtr connector = endpoint->connector(); assert(connector); @@ -131,11 +131,11 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi ++q; - if (traceLevels->retry >= 2) + if(traceLevels->retry >= 2) { Trace out(logger, traceLevels->retryCat); out << "connection to endpoint failed"; - if (q != endpoints.end()) + if(q != endpoints.end()) { out << ", trying next endpoint\n"; } @@ -147,7 +147,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpoi } } - if (!connection) + if(!connection) { assert(exception.get()); exception->ice_throw(); @@ -161,13 +161,13 @@ IceInternal::OutgoingConnectionFactory::setRouter(const RouterPrx& router) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } RouterInfoPtr routerInfo = _instance->routerManager()->get(router); - if (routerInfo) + if(routerInfo) { // // Search for connections to the router's client proxy @@ -179,16 +179,16 @@ IceInternal::OutgoingConnectionFactory::setRouter(const RouterPrx& router) ObjectAdapterPtr adapter = routerInfo->getAdapter(); DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); vector<EndpointPtr>::const_iterator p; - for (p = proxy->__reference()->endpoints.begin(); p != proxy->__reference()->endpoints.end(); ++p) + for(p = proxy->__reference()->endpoints.begin(); p != proxy->__reference()->endpoints.end(); ++p) { EndpointPtr endpoint = *p; - if (defaultsAndOverrides->overrideTimeout) + if(defaultsAndOverrides->overrideTimeout) { endpoint = endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } map<EndpointPtr, ConnectionPtr>::const_iterator q = _connections.find(endpoint); - if (q != _connections.end()) + if(q != _connections.end()) { q->second->setAdapter(adapter); } @@ -201,14 +201,14 @@ IceInternal::OutgoingConnectionFactory::removeAdapter(const ObjectAdapterPtr& ad { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } - for (map<EndpointPtr, ConnectionPtr>::const_iterator p = _connections.begin(); p != _connections.end(); ++p) + for(map<EndpointPtr, ConnectionPtr>::const_iterator p = _connections.begin(); p != _connections.end(); ++p) { - if (p->second->getAdapter() == adapter) + if(p->second->getAdapter() == adapter) { p->second->setAdapter(0); } @@ -230,7 +230,7 @@ IceInternal::OutgoingConnectionFactory::destroy() { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { return; } @@ -273,7 +273,7 @@ IceInternal::IncomingConnectionFactory::endpoint() const bool IceInternal::IncomingConnectionFactory::equivalent(const EndpointPtr& endp) const { - if (_transceiver) + if(_transceiver) { return endp->equivalent(_transceiver); } @@ -316,7 +316,7 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt threadPool->promoteFollower(); - if (_state != StateActive) + if(_state != StateActive) { IceUtil::ThreadControl::yield(); return; @@ -349,7 +349,7 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt } catch (const LocalException& ex) { - if (_warn) + if(_warn) { Warning out(_instance->logger()); out << "connection exception:\n" << ex << '\n' << _acceptor->toString(); @@ -365,11 +365,11 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool threadPool->promoteFollower(); - if (_state == StateActive) + if(_state == StateActive) { registerWithPool(); } - else if (_state == StateClosed) + else if(_state == StateClosed) { try { @@ -377,7 +377,7 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool // Clear listen() backlog properly by accepting all queued // connections, and then shutting them down. // - while (true) + while(true) { try { @@ -393,7 +393,7 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool } catch (const LocalException& ex) { - if (_warn) + if(_warn) { Warning out(_instance->logger()); out << "connection exception:\n" << ex << '\n' << _acceptor->toString(); @@ -441,7 +441,7 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance _registeredWithPool(false) { DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); - if (defaultsAndOverrides->overrideTimeout) + if(defaultsAndOverrides->overrideTimeout) { _endpoint = _endpoint->timeout(defaultsAndOverrides->overrideTimeoutValue); } @@ -451,7 +451,7 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance try { _transceiver = _endpoint->serverTransceiver(_endpoint); - if (_transceiver) + if(_transceiver) { ConnectionPtr connection = new Connection(_instance, _transceiver, _endpoint, _adapter); _connections.push_back(connection); @@ -488,7 +488,7 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished() { ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - while (_adapter) + while(_adapter) { wait(); } @@ -497,16 +497,16 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished() void IceInternal::IncomingConnectionFactory::setState(State state) { - if (_state == state) // Don't switch twice. + if(_state == state) // Don't switch twice. { return; } - switch (state) + switch(state) { case StateActive: { - if (_state != StateHolding) // Can only switch from holding to active. + if(_state != StateHolding) // Can only switch from holding to active. { return; } @@ -517,7 +517,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) case StateHolding: { - if (_state != StateActive) // Can only switch from active to holding + if(_state != StateActive) // Can only switch from active to holding { return; } @@ -532,7 +532,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) // If we come from holding state, we first need to // register again before we unregister. // - if (_state == StateHolding) + if(_state == StateHolding) { registerWithPool(); } @@ -558,11 +558,11 @@ IceInternal::IncomingConnectionFactory::setState(State state) void IceInternal::IncomingConnectionFactory::registerWithPool() { - if (_acceptor) + if(_acceptor) { - if (!_registeredWithPool) + if(!_registeredWithPool) { - if (!_serverThreadPool) + if(!_serverThreadPool) { _serverThreadPool = _instance->serverThreadPool(); assert(_serverThreadPool); @@ -576,9 +576,9 @@ IceInternal::IncomingConnectionFactory::registerWithPool() void IceInternal::IncomingConnectionFactory::unregisterWithPool() { - if (_acceptor) + if(_acceptor) { - if (_registeredWithPool) + if(_registeredWithPool) { assert(_serverThreadPool); _serverThreadPool->unregister(_acceptor->fd()); diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 15fadcf3ca8..b09862fdd61 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -1,108 +1,108 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONNECTION_FACTORY_H -#define ICE_CONNECTION_FACTORY_H - -#include <IceUtil/RecMutex.h> -#include <Ice/ConnectionFactoryF.h> -#include <Ice/ConnectionF.h> -#include <Ice/InstanceF.h> -#include <Ice/ObjectAdapterF.h> -#include <Ice/EndpointF.h> -#include <Ice/AcceptorF.h> -#include <Ice/TransceiverF.h> -#include <Ice/RouterF.h> -#include <Ice/EventHandler.h> -#include <list> - -namespace Ice -{ - -class LocalException; -class ObjectAdapterI; - -} - -namespace IceInternal -{ - -class OutgoingConnectionFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - ConnectionPtr create(const std::vector<EndpointPtr>&); - void setRouter(const ::Ice::RouterPrx&); - void removeAdapter(const ::Ice::ObjectAdapterPtr&); - -private: - - OutgoingConnectionFactory(const InstancePtr&); - virtual ~OutgoingConnectionFactory(); - void destroy(); - friend class Instance; - - InstancePtr _instance; - std::map<EndpointPtr, ConnectionPtr> _connections; -}; - -class IncomingConnectionFactory : public EventHandler, public ::IceUtil::Monitor< ::IceUtil::Mutex> -{ -public: - - void hold(); - void activate(); - - EndpointPtr endpoint() const; - bool equivalent(const EndpointPtr&) const; - std::list<ConnectionPtr> connections() const; - - // - // Operations from EventHandler - // - virtual bool readable() const; - virtual void read(BasicStream&); - virtual void message(BasicStream&, const ThreadPoolPtr&); - virtual void finished(const ThreadPoolPtr&); - virtual void exception(const ::Ice::LocalException&); - -private: - - IncomingConnectionFactory(const InstancePtr&, const EndpointPtr&, const ::Ice::ObjectAdapterPtr&); - virtual ~IncomingConnectionFactory(); - void destroy(); - void waitUntilFinished(); - friend class ::Ice::ObjectAdapterI; - - enum State - { - StateActive, - StateHolding, - StateClosed - }; - - void setState(State); - void registerWithPool(); - void unregisterWithPool(); - - EndpointPtr _endpoint; - ::Ice::ObjectAdapterPtr _adapter; - AcceptorPtr _acceptor; - TransceiverPtr _transceiver; - ThreadPoolPtr _serverThreadPool; - std::list<ConnectionPtr> _connections; - State _state; - bool _warn; - bool _registeredWithPool; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONNECTION_FACTORY_H
+#define ICE_CONNECTION_FACTORY_H
+
+#include <IceUtil/RecMutex.h>
+#include <Ice/ConnectionFactoryF.h>
+#include <Ice/ConnectionF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/ObjectAdapterF.h>
+#include <Ice/EndpointF.h>
+#include <Ice/AcceptorF.h>
+#include <Ice/TransceiverF.h>
+#include <Ice/RouterF.h>
+#include <Ice/EventHandler.h>
+#include <list>
+
+namespace Ice
+{
+
+class LocalException;
+class ObjectAdapterI;
+
+}
+
+namespace IceInternal
+{
+
+class OutgoingConnectionFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ ConnectionPtr create(const std::vector<EndpointPtr>&);
+ void setRouter(const ::Ice::RouterPrx&);
+ void removeAdapter(const ::Ice::ObjectAdapterPtr&);
+
+private:
+
+ OutgoingConnectionFactory(const InstancePtr&);
+ virtual ~OutgoingConnectionFactory();
+ void destroy();
+ friend class Instance;
+
+ InstancePtr _instance;
+ std::map<EndpointPtr, ConnectionPtr> _connections;
+};
+
+class IncomingConnectionFactory : public EventHandler, public ::IceUtil::Monitor< ::IceUtil::Mutex>
+{
+public:
+
+ void hold();
+ void activate();
+
+ EndpointPtr endpoint() const;
+ bool equivalent(const EndpointPtr&) const;
+ std::list<ConnectionPtr> connections() const;
+
+ //
+ // Operations from EventHandler
+ //
+ virtual bool readable() const;
+ virtual void read(BasicStream&);
+ virtual void message(BasicStream&, const ThreadPoolPtr&);
+ virtual void finished(const ThreadPoolPtr&);
+ virtual void exception(const ::Ice::LocalException&);
+
+private:
+
+ IncomingConnectionFactory(const InstancePtr&, const EndpointPtr&, const ::Ice::ObjectAdapterPtr&);
+ virtual ~IncomingConnectionFactory();
+ void destroy();
+ void waitUntilFinished();
+ friend class ::Ice::ObjectAdapterI;
+
+ enum State
+ {
+ StateActive,
+ StateHolding,
+ StateClosed
+ };
+
+ void setState(State);
+ void registerWithPool();
+ void unregisterWithPool();
+
+ EndpointPtr _endpoint;
+ ::Ice::ObjectAdapterPtr _adapter;
+ AcceptorPtr _acceptor;
+ TransceiverPtr _transceiver;
+ ThreadPoolPtr _serverThreadPool;
+ std::list<ConnectionPtr> _connections;
+ State _state;
+ bool _warn;
+ bool _registeredWithPool;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Connector.h b/cpp/src/Ice/Connector.h index 8a07584d761..93ac46c09ac 100644 --- a/cpp/src/Ice/Connector.h +++ b/cpp/src/Ice/Connector.h @@ -1,31 +1,31 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONNECTOR_H -#define ICE_CONNECTOR_H - -#include <IceUtil/Shared.h> -#include <Ice/ConnectorF.h> -#include <Ice/TransceiverF.h> - -namespace IceInternal -{ - -class ICE_PROTOCOL_API Connector : public ::IceUtil::Shared -{ -public: - - virtual TransceiverPtr connect(int) = 0; - virtual std::string toString() const = 0; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONNECTOR_H
+#define ICE_CONNECTOR_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/ConnectorF.h>
+#include <Ice/TransceiverF.h>
+
+namespace IceInternal
+{
+
+class ICE_PROTOCOL_API Connector : public ::IceUtil::Shared
+{
+public:
+
+ virtual TransceiverPtr connect(int) = 0;
+ virtual std::string toString() const = 0;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ConnectorF.h b/cpp/src/Ice/ConnectorF.h index 532a2ad0339..5e682ec543d 100644 --- a/cpp/src/Ice/ConnectorF.h +++ b/cpp/src/Ice/ConnectorF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_CONNECTOR_F_H -#define ICE_CONNECTOR_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Connector; -ICE_PROTOCOL_API void incRef(Connector*); -ICE_PROTOCOL_API void decRef(Connector*); -typedef Handle<Connector> ConnectorPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_CONNECTOR_F_H
+#define ICE_CONNECTOR_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Connector;
+ICE_PROTOCOL_API void incRef(Connector*);
+ICE_PROTOCOL_API void decRef(Connector*);
+typedef Handle<Connector> ConnectorPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp index 66ffa96bab0..f04d9f2cb87 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.cpp +++ b/cpp/src/Ice/DefaultsAndOverrides.cpp @@ -28,7 +28,7 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro const_cast<string&>(defaultProtocol) = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp"); const_cast<string&>(defaultHost) = properties->getProperty("Ice.Default.Host"); - if (defaultHost.empty()) + if(defaultHost.empty()) { const_cast<string&>(defaultHost) = getLocalHost(true); } @@ -38,14 +38,14 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro string value; value = properties->getProperty("Ice.Override.Timeout"); - if (!value.empty()) + if(!value.empty()) { const_cast<bool&>(overrideTimeout) = true; const_cast<Int&>(overrideTimeoutValue) = atoi(value.c_str()); } value = properties->getProperty("Ice.Override.Compress"); - if (!value.empty()) + if(!value.empty()) { const_cast<bool&>(overrideComppress) = true; const_cast<bool&>(overrideComppressValue) = atoi(value.c_str()); diff --git a/cpp/src/Ice/DefaultsAndOverrides.h b/cpp/src/Ice/DefaultsAndOverrides.h index 38e39c8e2a0..7f865083e24 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.h +++ b/cpp/src/Ice/DefaultsAndOverrides.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DEFAULTS_AND_OVERRIDES_H -#define ICE_DEFAULTS_AND_OVERRIDES_H - -#include <IceUtil/Shared.h> -#include <Ice/DefaultsAndOverridesF.h> -#include <Ice/PropertiesF.h> - -namespace IceInternal -{ - -class DefaultsAndOverrides : public ::IceUtil::Shared -{ -public: - - DefaultsAndOverrides(const ::Ice::PropertiesPtr&); - - std::string defaultHost; - std::string defaultProtocol; - std::string defaultRouter; - - bool overrideTimeout; - Ice::Int overrideTimeoutValue; - bool overrideComppress; - bool overrideComppressValue; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DEFAULTS_AND_OVERRIDES_H
+#define ICE_DEFAULTS_AND_OVERRIDES_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/DefaultsAndOverridesF.h>
+#include <Ice/PropertiesF.h>
+
+namespace IceInternal
+{
+
+class DefaultsAndOverrides : public ::IceUtil::Shared
+{
+public:
+
+ DefaultsAndOverrides(const ::Ice::PropertiesPtr&);
+
+ std::string defaultHost;
+ std::string defaultProtocol;
+ std::string defaultRouter;
+
+ bool overrideTimeout;
+ Ice::Int overrideTimeoutValue;
+ bool overrideComppress;
+ bool overrideComppressValue;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/DefaultsAndOverridesF.h b/cpp/src/Ice/DefaultsAndOverridesF.h index 0772a93ee72..bd5029e83e7 100644 --- a/cpp/src/Ice/DefaultsAndOverridesF.h +++ b/cpp/src/Ice/DefaultsAndOverridesF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DEFAULTS_AND_OVERRIDES_F_H -#define ICE_DEFAULTS_AND_OVERRIDES_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class DefaultsAndOverrides; -void incRef(DefaultsAndOverrides*); -void decRef(DefaultsAndOverrides*); -typedef Handle<DefaultsAndOverrides> DefaultsAndOverridesPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DEFAULTS_AND_OVERRIDES_F_H
+#define ICE_DEFAULTS_AND_OVERRIDES_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class DefaultsAndOverrides;
+void incRef(DefaultsAndOverrides*);
+void decRef(DefaultsAndOverrides*);
+typedef Handle<DefaultsAndOverrides> DefaultsAndOverridesPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp index 3e3416f4c6e..87f48b10516 100644 --- a/cpp/src/Ice/Direct.cpp +++ b/cpp/src/Ice/Direct.cpp @@ -27,28 +27,28 @@ IceInternal::Direct::Direct(const ObjectAdapterPtr& adapter, const Current& curr { _servant = _adapter->identityToServant(_current.identity); - if (!_servant && !_current.identity.category.empty()) + if(!_servant && !_current.identity.category.empty()) { _locator = _adapter->findServantLocator(_current.identity.category); - if (_locator) + if(_locator) { _servant = _locator->locate(_adapter, _current, _cookie); } } - if (!_servant) + if(!_servant) { _locator = _adapter->findServantLocator(""); - if (_locator) + if(_locator) { _servant = _locator->locate(_adapter, _current, _cookie); } } - if (_servant && !_current.facet.empty()) + if(_servant && !_current.facet.empty()) { _facetServant = _servant->ice_findFacet(_current.facet); - if (!_facetServant) + if(!_facetServant) { FacetNotExistException ex(__FILE__, __LINE__); ex.facet = _current.facet; @@ -58,7 +58,7 @@ IceInternal::Direct::Direct(const ObjectAdapterPtr& adapter, const Current& curr } catch(...) { - if (_locator && _servant) + if(_locator && _servant) { _locator->finished(_adapter, _current, _servant, _cookie); } @@ -75,7 +75,7 @@ IceInternal::Direct::Direct(const ObjectAdapterPtr& adapter, const Current& curr IceInternal::Direct::~Direct() { - if (_locator && _servant) + if(_locator && _servant) { _locator->finished(_adapter, _current, _servant, _cookie); } @@ -84,7 +84,7 @@ IceInternal::Direct::~Direct() const ObjectPtr& IceInternal::Direct::facetServant() { - if (_facetServant) + if(_facetServant) { return _facetServant; } diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index e713ea2e5f0..79312c8cfbe 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -43,7 +43,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint) { string::size_type colon = entryPoint.rfind(':'); string::size_type comma = entryPoint.find(','); - if (colon == string::npos || colon == entryPoint.size() - 1 || + if(colon == string::npos || colon == entryPoint.size() - 1 || (comma != string::npos && (comma > colon || comma == colon - 1))) { _err = "invalid entry point format `" + entryPoint + "'"; @@ -52,7 +52,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint) string libSpec = entryPoint.substr(0, colon); string funcName = entryPoint.substr(colon + 1); string libName, version, debug; - if (comma == string::npos) + if(comma == string::npos) { libName = libSpec; version = ICE_STRING_VERSION; @@ -67,9 +67,9 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint) #ifdef _WIN32 lib = libName; - for (string::size_type n = 0; n < version.size(); n++) + for(string::size_type n = 0; n < version.size(); n++) { - if (version[n] != '.') // Remove periods + if(version[n] != '.') // Remove periods { lib += version[n]; } @@ -82,7 +82,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint) lib = "lib" + libName + ".so." + version; #endif - if (!load(lib)) + if(!load(lib)) { return 0; } @@ -97,13 +97,13 @@ IceInternal::DynamicLibrary::load(const string& lib) _hnd = LoadLibrary(lib.c_str()); #else _hnd = dlopen(lib.c_str(), RTLD_NOW); - if (_hnd == 0) + if(_hnd == 0) { // // Remember the most recent error in _err. // const char* err = dlerror(); - if (err) + if(err) { _err = err; } @@ -120,13 +120,13 @@ IceInternal::DynamicLibrary::getSymbol(const string& name) return GetProcAddress(_hnd, name.c_str()); #else symbol_type result = dlsym(_hnd, name.c_str()); - if (result == 0) + if(result == 0) { // // Remember the most recent error in _err. // const char* err = dlerror(); - if (err) + if(err) { _err = err; } diff --git a/cpp/src/Ice/Endpoint.h b/cpp/src/Ice/Endpoint.h index d667f956064..d66ce19a54f 100644 --- a/cpp/src/Ice/Endpoint.h +++ b/cpp/src/Ice/Endpoint.h @@ -1,120 +1,120 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ENDPOINT_H -#define ICE_ENDPOINT_H - -#include <IceUtil/Shared.h> -#include <Ice/EndpointF.h> -#include <Ice/InstanceF.h> -#include <Ice/TransceiverF.h> -#include <Ice/ConnectorF.h> -#include <Ice/AcceptorF.h> - -namespace IceInternal -{ - -class BasicStream; - -class ICE_PROTOCOL_API Endpoint : public ::IceUtil::Shared -{ -public: - - // - // Marshal the endpoint - // - virtual void streamWrite(BasicStream*) const = 0; - - // - // Convert the endpoint to its string form - // - virtual std::string toString() const = 0; - - // - // Return the endpoint type - // - virtual ::Ice::Short type() const = 0; - - // - // Return the timeout for the endpoint in milliseconds. 0 means - // non-blocking, -1 means no timeout. - // - virtual ::Ice::Int timeout() const = 0; - - // - // Return a new endpoint with a different timeout value, provided - // that timeouts are supported by the endpoint. Otherwise the same - // endpoint is returned. - // - virtual EndpointPtr timeout(::Ice::Int) const = 0; - - // - // Return true if the endpoint is datagram-based. - // - virtual bool datagram() const = 0; - - // - // Return true if the endpoint is secure. - // - virtual bool secure() const = 0; - - // - // Return true if the endpoint type is unknown. - // - virtual bool unknown() const = 0; - - // - // Return a client side transceiver for this endpoint, or null if a - // transceiver can only be created by a connector. - // - virtual TransceiverPtr clientTransceiver() const = 0; - - // - // Return a server side transceiver for this endpoint, or null if a - // transceiver can only be created by an acceptor. In case a - // transceiver is created, this operation also returns a new - // "effective" endpoint, which might differ from this endpoint, - // for example, if a dynamic port number is assigned. - // - virtual TransceiverPtr serverTransceiver(EndpointPtr&) const = 0; - - // - // Return a connector for this endpoint, or null if no connector - // is available. - // - virtual ConnectorPtr connector() const = 0; - - // - // Return an acceptor for this endpoint, or null if no acceptors - // is available. In case an acceptor is created, this operation - // also returns a new "effective" endpoint, which might differ - // from this endpoint, for example, if a dynamic port number is - // assigned. - // - virtual AcceptorPtr acceptor(EndpointPtr&) const = 0; - - // - // Check whether the endpoint is equivalent to a specific - // Transceiver or Acceptor - // - virtual bool equivalent(const TransceiverPtr&) const = 0; - virtual bool equivalent(const AcceptorPtr&) const = 0; - - // - // Compare endpoints for sorting purposes - // - virtual bool operator==(const Endpoint&) const = 0; - virtual bool operator!=(const Endpoint&) const = 0; - virtual bool operator<(const Endpoint&) const = 0; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ENDPOINT_H
+#define ICE_ENDPOINT_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/EndpointF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/TransceiverF.h>
+#include <Ice/ConnectorF.h>
+#include <Ice/AcceptorF.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+class ICE_PROTOCOL_API Endpoint : public ::IceUtil::Shared
+{
+public:
+
+ //
+ // Marshal the endpoint
+ //
+ virtual void streamWrite(BasicStream*) const = 0;
+
+ //
+ // Convert the endpoint to its string form
+ //
+ virtual std::string toString() const = 0;
+
+ //
+ // Return the endpoint type
+ //
+ virtual ::Ice::Short type() const = 0;
+
+ //
+ // Return the timeout for the endpoint in milliseconds. 0 means
+ // non-blocking, -1 means no timeout.
+ //
+ virtual ::Ice::Int timeout() const = 0;
+
+ //
+ // Return a new endpoint with a different timeout value, provided
+ // that timeouts are supported by the endpoint. Otherwise the same
+ // endpoint is returned.
+ //
+ virtual EndpointPtr timeout(::Ice::Int) const = 0;
+
+ //
+ // Return true if the endpoint is datagram-based.
+ //
+ virtual bool datagram() const = 0;
+
+ //
+ // Return true if the endpoint is secure.
+ //
+ virtual bool secure() const = 0;
+
+ //
+ // Return true if the endpoint type is unknown.
+ //
+ virtual bool unknown() const = 0;
+
+ //
+ // Return a client side transceiver for this endpoint, or null if a
+ // transceiver can only be created by a connector.
+ //
+ virtual TransceiverPtr clientTransceiver() const = 0;
+
+ //
+ // Return a server side transceiver for this endpoint, or null if a
+ // transceiver can only be created by an acceptor. In case a
+ // transceiver is created, this operation also returns a new
+ // "effective" endpoint, which might differ from this endpoint,
+ // for example, if a dynamic port number is assigned.
+ //
+ virtual TransceiverPtr serverTransceiver(EndpointPtr&) const = 0;
+
+ //
+ // Return a connector for this endpoint, or null if no connector
+ // is available.
+ //
+ virtual ConnectorPtr connector() const = 0;
+
+ //
+ // Return an acceptor for this endpoint, or null if no acceptors
+ // is available. In case an acceptor is created, this operation
+ // also returns a new "effective" endpoint, which might differ
+ // from this endpoint, for example, if a dynamic port number is
+ // assigned.
+ //
+ virtual AcceptorPtr acceptor(EndpointPtr&) const = 0;
+
+ //
+ // Check whether the endpoint is equivalent to a specific
+ // Transceiver or Acceptor
+ //
+ virtual bool equivalent(const TransceiverPtr&) const = 0;
+ virtual bool equivalent(const AcceptorPtr&) const = 0;
+
+ //
+ // Compare endpoints for sorting purposes
+ //
+ virtual bool operator==(const Endpoint&) const = 0;
+ virtual bool operator!=(const Endpoint&) const = 0;
+ virtual bool operator<(const Endpoint&) const = 0;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp index d8f3cc93a07..b8c58ae96df 100644 --- a/cpp/src/Ice/EndpointFactoryManager.cpp +++ b/cpp/src/Ice/EndpointFactoryManager.cpp @@ -36,9 +36,9 @@ IceInternal::EndpointFactoryManager::add(const EndpointFactoryPtr& factory) // // TODO: Optimize with a map? // - for (vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) + for(vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) { - if (_factories[i]->type() == factory->type()) + if(_factories[i]->type() == factory->type()) { assert(false); // TODO: Exception? } @@ -54,9 +54,9 @@ IceInternal::EndpointFactoryManager::get(Short type) const // // TODO: Optimize with a map? // - for (vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) + for(vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) { - if (_factories[i]->type() == type) + if(_factories[i]->type() == type) { return _factories[i]; } @@ -72,20 +72,20 @@ IceInternal::EndpointFactoryManager::create(const string& str) const static const string delim = " \t\n\r"; string::size_type beg = str.find_first_not_of(delim); - if (beg == string::npos) + if(beg == string::npos) { throw EndpointParseException(__FILE__, __LINE__); } string::size_type end = str.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } string protocol = str.substr(beg, end - beg); - if (protocol == "default") + if(protocol == "default") { protocol = _instance->defaultsAndOverrides()->defaultProtocol; } @@ -93,9 +93,9 @@ IceInternal::EndpointFactoryManager::create(const string& str) const // // TODO: Optimize with a map? // - for (vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) + for(vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) { - if (_factories[i]->protocol() == protocol) + if(_factories[i]->protocol() == protocol) { return _factories[i]->create(str.substr(end)); } @@ -115,9 +115,9 @@ IceInternal::EndpointFactoryManager::read(BasicStream* s) const // // TODO: Optimize with a map? // - for (vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) + for(vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) { - if (_factories[i]->type() == type) + if(_factories[i]->type() == type) { return _factories[i]->read(s); } @@ -129,7 +129,7 @@ IceInternal::EndpointFactoryManager::read(BasicStream* s) const void IceInternal::EndpointFactoryManager::destroy() { - for (vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) + for(vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++) { _factories[i]->destroy(); } diff --git a/cpp/src/Ice/EndpointFactoryManager.h b/cpp/src/Ice/EndpointFactoryManager.h index 34f953f199c..807982cd61c 100644 --- a/cpp/src/Ice/EndpointFactoryManager.h +++ b/cpp/src/Ice/EndpointFactoryManager.h @@ -1,47 +1,47 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ENDPOINT_FACTORY_MANAGER_H -#define ICE_ENDPOINT_FACTORY_MANAGER_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/InstanceF.h> -#include <Ice/EndpointF.h> -#include <Ice/EndpointFactoryF.h> -#include <Ice/EndpointFactoryManagerF.h> - -namespace IceInternal -{ - -class BasicStream; - -class EndpointFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - void add(const EndpointFactoryPtr&); - EndpointFactoryPtr get(::Ice::Short) const; - EndpointPtr create(const std::string&) const; - EndpointPtr read(BasicStream*) const; - -private: - - EndpointFactoryManager(const InstancePtr&); - void destroy(); - friend class Instance; - - InstancePtr _instance; - std::vector<EndpointFactoryPtr> _factories; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ENDPOINT_FACTORY_MANAGER_H
+#define ICE_ENDPOINT_FACTORY_MANAGER_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/InstanceF.h>
+#include <Ice/EndpointF.h>
+#include <Ice/EndpointFactoryF.h>
+#include <Ice/EndpointFactoryManagerF.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+class EndpointFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ void add(const EndpointFactoryPtr&);
+ EndpointFactoryPtr get(::Ice::Short) const;
+ EndpointPtr create(const std::string&) const;
+ EndpointPtr read(BasicStream*) const;
+
+private:
+
+ EndpointFactoryManager(const InstancePtr&);
+ void destroy();
+ friend class Instance;
+
+ InstancePtr _instance;
+ std::vector<EndpointFactoryPtr> _factories;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/EndpointFactoryManagerF.h b/cpp/src/Ice/EndpointFactoryManagerF.h index 2f5363e9eed..afeea66cf24 100644 --- a/cpp/src/Ice/EndpointFactoryManagerF.h +++ b/cpp/src/Ice/EndpointFactoryManagerF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ENDPOINT_FACTORY_MANAGER_F_H -#define ICE_ENDPOINT_FACTORY_MANAGER_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class EndpointFactoryManager; -void incRef(EndpointFactoryManager*); -void decRef(EndpointFactoryManager*); -typedef Handle<EndpointFactoryManager> EndpointFactoryManagerPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ENDPOINT_FACTORY_MANAGER_F_H
+#define ICE_ENDPOINT_FACTORY_MANAGER_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class EndpointFactoryManager;
+void incRef(EndpointFactoryManager*);
+void decRef(EndpointFactoryManager*);
+typedef Handle<EndpointFactoryManager> EndpointFactoryManagerPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h index 3205f077489..02dbece7c9d 100644 --- a/cpp/src/Ice/EventHandler.h +++ b/cpp/src/Ice/EventHandler.h @@ -1,87 +1,87 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_EVENT_HANDLER_H -#define ICE_EVENT_HANDLER_H - -#include <IceUtil/Shared.h> -#include <Ice/EventHandlerF.h> -#include <Ice/InstanceF.h> -#include <Ice/ThreadPoolF.h> -#include <Ice/BasicStream.h> - -namespace Ice -{ - -class LocalException; - -} - -namespace IceInternal -{ - -class EventHandler : public ::IceUtil::Shared -{ -public: - - // - // Return true if read() must be called before calling message(). - // - virtual bool readable() const = 0; - - // - // Read data via the event handler. May only be called if - // readable() returns true. - // - virtual void read(BasicStream&) = 0; - - // - // A complete message has been received. - // - virtual void message(BasicStream&, const ThreadPoolPtr&) = 0; - - // - // Will be called if the event handler is finally - // unregistered. (Calling unregister() does not unregister - // immediately.) - // - virtual void finished(const ThreadPoolPtr&) = 0; - - // - // Propagate an exception to the event handler. - // - virtual void exception(const ::Ice::LocalException&) = 0; - - // - // Try to destroy the event handler. Returns false if the event - // handler cannot be destroyed because it is in use, or true - // otherwise. - // -// virtual bool tryDestroy(const ThreadPoolPtr&) = 0; - -protected: - - EventHandler(const InstancePtr&); - virtual ~EventHandler(); - - InstancePtr _instance; - -private: - - // - // The _stream data member is for use by ThreadPool only - // - BasicStream _stream; - friend class ThreadPool; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_EVENT_HANDLER_H
+#define ICE_EVENT_HANDLER_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/EventHandlerF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/ThreadPoolF.h>
+#include <Ice/BasicStream.h>
+
+namespace Ice
+{
+
+class LocalException;
+
+}
+
+namespace IceInternal
+{
+
+class EventHandler : public ::IceUtil::Shared
+{
+public:
+
+ //
+ // Return true if read() must be called before calling message().
+ //
+ virtual bool readable() const = 0;
+
+ //
+ // Read data via the event handler. May only be called if
+ // readable() returns true.
+ //
+ virtual void read(BasicStream&) = 0;
+
+ //
+ // A complete message has been received.
+ //
+ virtual void message(BasicStream&, const ThreadPoolPtr&) = 0;
+
+ //
+ // Will be called if the event handler is finally
+ // unregistered. (Calling unregister() does not unregister
+ // immediately.)
+ //
+ virtual void finished(const ThreadPoolPtr&) = 0;
+
+ //
+ // Propagate an exception to the event handler.
+ //
+ virtual void exception(const ::Ice::LocalException&) = 0;
+
+ //
+ // Try to destroy the event handler. Returns false if the event
+ // handler cannot be destroyed because it is in use, or true
+ // otherwise.
+ //
+// virtual bool tryDestroy(const ThreadPoolPtr&) = 0;
+
+protected:
+
+ EventHandler(const InstancePtr&);
+ virtual ~EventHandler();
+
+ InstancePtr _instance;
+
+private:
+
+ //
+ // The _stream data member is for use by ThreadPool only
+ //
+ BasicStream _stream;
+ friend class ThreadPool;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/EventHandlerF.h b/cpp/src/Ice/EventHandlerF.h index 32a1379edfd..1bf5aa9aa8b 100644 --- a/cpp/src/Ice/EventHandlerF.h +++ b/cpp/src/Ice/EventHandlerF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_EVENT_HANDLER_F_H -#define ICE_EVENT_HANDLER_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class EventHandler; -void incRef(EventHandler*); -void decRef(EventHandler*); -typedef Handle<EventHandler> EventHandlerPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_EVENT_HANDLER_F_H
+#define ICE_EVENT_HANDLER_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class EventHandler;
+void incRef(EventHandler*);
+void decRef(EventHandler*);
+typedef Handle<EventHandler> EventHandlerPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index ae8b67ffaaf..817c1764ce4 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -127,7 +127,7 @@ void Ice::SystemException::ice_print(ostream& out) const { Exception::ice_print(out); - if (error != 0) + if(error != 0) { out << ":\nsystem exception: " << errorToString(error); } @@ -152,7 +152,7 @@ Ice::ConnectionLostException::ice_print(ostream& out) const { Exception::ice_print(out); out << ":\nconnection lost: "; - if (error == 0) + if(error == 0) { out << "recv() returned zero"; } @@ -328,7 +328,7 @@ Ice::PluginInitializationException::ice_print(ostream& out) const { Exception::ice_print(out); out << ":\nplug-in initialization failed"; - if (!reason.empty()) + if(!reason.empty()) { out << ": " << reason; } diff --git a/cpp/src/Ice/IdentityUtil.cpp b/cpp/src/Ice/IdentityUtil.cpp index 4dba3a78841..54e1ab40de5 100644 --- a/cpp/src/Ice/IdentityUtil.cpp +++ b/cpp/src/Ice/IdentityUtil.cpp @@ -25,7 +25,7 @@ Ice::stringToIdentity(const string& s) { Identity ident; string::size_type pos = s.find_first_of("/"); - if (pos != string::npos) + if(pos != string::npos) { ident.category = s.substr(0, pos); ident.name = s.substr(pos + 1); @@ -40,7 +40,7 @@ Ice::stringToIdentity(const string& s) string Ice::identityToString(const Identity& ident) { - if (ident.category.empty()) + if(ident.category.empty()) { return ident.name; } diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 5ccfdea59d9..e75ed427c2b 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -35,7 +35,7 @@ IceInternal::Incoming::invoke(bool response) _is.read(current.nonmutating); Int sz; _is.readSize(sz); - while (sz--) + while(sz--) { pair<string, string> pair; _is.read(pair.first); @@ -44,7 +44,7 @@ IceInternal::Incoming::invoke(bool response) } BasicStream::Container::size_type statusPos = 0; // Initialize, to keep the compiler happy. - if (response) + if(response) { statusPos = _os.b.size(); _os.write(static_cast<Byte>(0)); @@ -56,7 +56,7 @@ IceInternal::Incoming::invoke(bool response) // blobs. // _is.startReadEncaps(); - if (response) + if(response) { _os.startWriteEncaps(); } @@ -67,23 +67,23 @@ IceInternal::Incoming::invoke(bool response) try { - if (_adapter) + if(_adapter) { servant = _adapter->identityToServant(current.identity); - if (!servant && !current.identity.category.empty()) + if(!servant && !current.identity.category.empty()) { locator = _adapter->findServantLocator(current.identity.category); - if (locator) + if(locator) { servant = locator->locate(_adapter, current, cookie); } } - if (!servant) + if(!servant) { locator = _adapter->findServantLocator(""); - if (locator) + if(locator) { servant = locator->locate(_adapter, current, cookie); } @@ -92,16 +92,16 @@ IceInternal::Incoming::invoke(bool response) DispatchStatus status; - if (!servant) + if(!servant) { status = DispatchObjectNotExist; } else { - if (!current.facet.empty()) + if(!current.facet.empty()) { ObjectPtr facetServant = servant->ice_findFacet(current.facet); - if (!facetServant) + if(!facetServant) { status = DispatchFacetNotExist; } @@ -116,23 +116,23 @@ IceInternal::Incoming::invoke(bool response) } } - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); - if (status != DispatchOK && status != DispatchUserException) + if(status != DispatchOK && status != DispatchUserException) { _os.b.resize(statusPos); _os.write(static_cast<Byte>(status)); - if (status == DispatchObjectNotExist) + if(status == DispatchObjectNotExist) { current.identity.__write(&_os); } @@ -153,14 +153,14 @@ IceInternal::Incoming::invoke(bool response) } catch (const LocationForward& ex) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); @@ -170,14 +170,14 @@ IceInternal::Incoming::invoke(bool response) } catch (const ObjectNotExistException& ex) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); @@ -192,14 +192,14 @@ IceInternal::Incoming::invoke(bool response) } catch (const FacetNotExistException& ex) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); @@ -214,14 +214,14 @@ IceInternal::Incoming::invoke(bool response) } catch (const OperationNotExistException& ex) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); @@ -236,14 +236,14 @@ IceInternal::Incoming::invoke(bool response) } catch (const LocalException& ex) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); @@ -255,14 +255,14 @@ IceInternal::Incoming::invoke(bool response) } catch (const UserException& ex) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); @@ -274,14 +274,14 @@ IceInternal::Incoming::invoke(bool response) } catch (...) { - if (locator && servant) + if(locator && servant) { assert(_adapter); locator->finished(_adapter, current, servant, cookie); } _is.endReadEncaps(); - if (response) + if(response) { _os.endWriteEncaps(); _os.b.resize(statusPos); diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index dcb044b42e4..fa3ad904841 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -21,7 +21,7 @@ CommunicatorPtr Ice::initialize(int& argc, char* argv[], Int version) { #ifndef ICE_IGNORE_VERSION - if (version != ICE_INT_VERSION) + if(version != ICE_INT_VERSION) { throw VersionMismatchException(__FILE__, __LINE__); } @@ -38,7 +38,7 @@ CommunicatorPtr Ice::initializeWithProperties(int& argc, char* argv[], const PropertiesPtr& properties, Int version) { #ifndef ICE_IGNORE_VERSION - if (version != ICE_INT_VERSION) + if(version != ICE_INT_VERSION) { throw VersionMismatchException(__FILE__, __LINE__); } @@ -65,7 +65,7 @@ static DefaultPropertiesDestroyer defaultPropertiesDestroyer; PropertiesPtr Ice::getDefaultProperties() { - if (!defaultProperties) + if(!defaultProperties) { defaultProperties = createProperties(); } @@ -75,7 +75,7 @@ Ice::getDefaultProperties() PropertiesPtr Ice::getDefaultProperties(StringSeq& args) { - if (!defaultProperties) + if(!defaultProperties) { defaultProperties = createProperties(args); } @@ -85,7 +85,7 @@ Ice::getDefaultProperties(StringSeq& args) PropertiesPtr Ice::getDefaultProperties(int& argc, char* argv[]) { - if (!defaultProperties) + if(!defaultProperties) { defaultProperties = createProperties(argc, argv); } @@ -114,7 +114,7 @@ StringSeq Ice::argsToStringSeq(int argc, char* argv[]) { StringSeq result; - for (int i = 0; i < argc; i++) + for(int i = 0; i < argc; i++) { result.push_back(argv[i]); } @@ -129,11 +129,11 @@ Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[]) // beginning of argv. // int i = 0; - while (i < argc) + while(i < argc) { - if (find(args.begin(), args.end(), argv[i]) == args.end()) + if(find(args.begin(), args.end(), argv[i]) == args.end()) { - for (int j = i; j < argc - 1; j++) + for(int j = i; j < argc - 1; j++) { argv[j] = argv[j + 1]; } diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index e1c87922d90..62bc82a4486 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -168,9 +168,9 @@ IceInternal::Instance::clientThreadPool() { IceUtil::RecMutex::Lock sync(*this); - if (_communicator) // Not destroyed? + if(_communicator) // Not destroyed? { - if (!_clientThreadPool) // Lazy initialization. + if(!_clientThreadPool) // Lazy initialization. { _clientThreadPool = new ThreadPool(this, false); } @@ -184,9 +184,9 @@ IceInternal::Instance::serverThreadPool() { IceUtil::RecMutex::Lock sync(*this); - if (_communicator) // Not destroyed? + if(_communicator) // Not destroyed? { - if (!_serverThreadPool) // Lazy initialization. + if(!_serverThreadPool) // Lazy initialization. { _serverThreadPool = new ThreadPool(this, true); } @@ -228,14 +228,14 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, { __setNoDelete(true); - if (_globalStateCounter == 1) // Only on first call + if(_globalStateCounter == 1) // Only on first call { srand(static_cast<timeval>(IceUtil::Time::now()).tv_usec); #ifdef _WIN32 WORD version = MAKEWORD(1, 1); WSADATA data; - if (WSAStartup(version, &data) != 0) + if(WSAStartup(version, &data) != 0) { _globalStateMutex->unlock(); SocketException ex(__FILE__, __LINE__); @@ -252,24 +252,24 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, sigaction(SIGPIPE, &action, 0); string newUser = _properties->getProperty("Ice.ChangeUser"); - if (!newUser.empty()) + if(!newUser.empty()) { struct passwd* pw = getpwnam(newUser.c_str()); - if (!pw) + if(!pw) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); throw ex; } - if (setgid(pw->pw_gid) == -1) + if(setgid(pw->pw_gid) == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); throw ex; } - if (setuid(pw->pw_uid) == -1) + if(setuid(pw->pw_uid) == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -277,10 +277,10 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, } } - if (_properties->getPropertyAsInt("Ice.UseSyslog") > 0) + if(_properties->getPropertyAsInt("Ice.UseSyslog") > 0) { _identForOpenlog = _properties->getProperty("Ice.ProgramName"); - if (_identForOpenlog.empty()) + if(_identForOpenlog.empty()) { _identForOpenlog = "<Unknown Ice Program>"; } @@ -290,7 +290,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, } #ifndef _WIN32 - if (_properties->getPropertyAsInt("Ice.UseSyslog") > 0) + if(_properties->getPropertyAsInt("Ice.UseSyslog") > 0) { _logger = new SysLoggerI; } @@ -320,7 +320,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, _pluginManager = new PluginManagerI(this); - if (!_defaultsAndOverrides->defaultRouter.empty()) + if(!_defaultsAndOverrides->defaultRouter.empty()) { _referenceFactory->setDefaultRouter( RouterPrx::uncheckedCast(_proxyFactory->stringToProxy(_defaultsAndOverrides->defaultRouter))); @@ -360,13 +360,13 @@ IceInternal::Instance::~Instance() assert(!_endpointFactoryManager); assert(!_pluginManager); - if (_globalStateMutex != 0) + if(_globalStateMutex != 0) { _globalStateMutex->lock(); } assert(_globalStateCounter > 0); - if (--_globalStateCounter == 0) // Only on last call + if(--_globalStateCounter == 0) // Only on last call { #ifdef _WIN32 WSACleanup(); @@ -381,7 +381,7 @@ IceInternal::Instance::~Instance() #endif #ifndef _WIN32 - if (!_identForOpenlog.empty()) + if(!_identForOpenlog.empty()) { closelog(); _identForOpenlog.clear(); @@ -389,7 +389,7 @@ IceInternal::Instance::~Instance() #endif } - if (_globalStateMutex != 0) + if(_globalStateMutex != 0) { _globalStateMutex->unlock(); } @@ -415,12 +415,12 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) // threads, etc. Perhaps we need a two-stage plug-in // initialization? // - if (_properties->getPropertyAsInt("Ice.Daemon") > 0) + if(_properties->getPropertyAsInt("Ice.Daemon") > 0) { int noclose = _properties->getPropertyAsInt("Ice.DaemonNoClose"); int nochdir = _properties->getPropertyAsInt("Ice.DaemonNoChdir"); - if (daemon(nochdir, noclose) == -1) + if(daemon(nochdir, noclose) == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -434,7 +434,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) // forks. Does not work together with Ice.Daemon if // Ice.DaemonNoClose is not set. // - if (_properties->getPropertyAsInt("Ice.PrintProcessId") > 0) + if(_properties->getPropertyAsInt("Ice.PrintProcessId") > 0) { #ifdef _WIN32 cout << _getpid() << endl; @@ -469,58 +469,58 @@ IceInternal::Instance::destroy() // to avoid cyclic object dependencies. // - if (_communicator) + if(_communicator) { // Don't destroy the communicator -- the communicator destroys // this object, not the other way. _communicator = 0; } - if (_objectAdapterFactory) + if(_objectAdapterFactory) { // Don't shut down the object adapters -- the communicator // must do this before it destroys this object. _objectAdapterFactory = 0; } - if (_servantFactoryManager) + if(_servantFactoryManager) { _servantFactoryManager->destroy(); _servantFactoryManager = 0; } - if (_userExceptionFactoryManager) + if(_userExceptionFactoryManager) { _userExceptionFactoryManager->destroy(); _userExceptionFactoryManager = 0; } - if (_referenceFactory) + if(_referenceFactory) { _referenceFactory->destroy(); _referenceFactory = 0; } - if (_proxyFactory) + if(_proxyFactory) { // No destroy function defined // _proxyFactory->destroy(); _proxyFactory = 0; } - if (_outgoingConnectionFactory) + if(_outgoingConnectionFactory) { _outgoingConnectionFactory->destroy(); _outgoingConnectionFactory = 0; } - if (_routerManager) + if(_routerManager) { _routerManager->destroy(); _routerManager = 0; } - if (_endpointFactoryManager) + if(_endpointFactoryManager) { _endpointFactoryManager->destroy(); _endpointFactoryManager = 0; @@ -542,21 +542,21 @@ IceInternal::Instance::destroy() _pluginManager = 0; } - if (clientThreadPool) + if(clientThreadPool) { clientThreadPool->waitUntilFinished(); clientThreadPool->destroy(); clientThreadPool->joinWithAllThreads(); } - if (serverThreadPool) + if(serverThreadPool) { serverThreadPool->waitUntilFinished(); serverThreadPool->destroy(); serverThreadPool->joinWithAllThreads(); } - if (pluginManager) + if(pluginManager) { pluginManager->destroy(); } diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 7cc4ec3ff0b..f69a8e40f38 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -1,105 +1,105 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_INSTANCE_H -#define ICE_INSTANCE_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/RecMutex.h> -#include <Ice/InstanceF.h> -#include <Ice/CommunicatorF.h> -#include <Ice/PropertiesF.h> -#include <Ice/LoggerF.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/DefaultsAndOverridesF.h> -#include <Ice/RouterInfoF.h> -#include <Ice/ReferenceFactoryF.h> -#include <Ice/ProxyFactoryF.h> -#include <Ice/ThreadPoolF.h> -#include <Ice/ConnectionFactoryF.h> -#include <Ice/ObjectFactoryManagerF.h> -#include <Ice/UserExceptionFactoryManagerF.h> -#include <Ice/ObjectAdapterFactoryF.h> -#include <Ice/EndpointFactoryManagerF.h> -#include <Ice/PluginF.h> -#include <list> - -namespace Ice -{ - -class CommunicatorI; - -} - -namespace IceInternal -{ - -class Instance : public ::IceUtil::Shared, public ::IceUtil::RecMutex -{ -public: - - ::Ice::CommunicatorPtr communicator(); - ::Ice::PropertiesPtr properties(); - ::Ice::LoggerPtr logger(); - void logger(const ::Ice::LoggerPtr&); - TraceLevelsPtr traceLevels(); - DefaultsAndOverridesPtr defaultsAndOverrides(); - RouterManagerPtr routerManager(); - ReferenceFactoryPtr referenceFactory(); - ProxyFactoryPtr proxyFactory(); - OutgoingConnectionFactoryPtr outgoingConnectionFactory(); - ObjectFactoryManagerPtr servantFactoryManager(); - UserExceptionFactoryManagerPtr userExceptionFactoryManager(); - ObjectAdapterFactoryPtr objectAdapterFactory(); - ThreadPoolPtr clientThreadPool(); - ThreadPoolPtr serverThreadPool(); - EndpointFactoryManagerPtr endpointFactoryManager(); - ::Ice::PluginManagerPtr pluginManager(); - -private: - - Instance(const ::Ice::CommunicatorPtr&, int&, char*[], const ::Ice::PropertiesPtr&); - virtual ~Instance(); - void finishSetup(int&, char*[]); - void destroy(); - friend class ::Ice::CommunicatorI; - - ::Ice::CommunicatorPtr _communicator; - ::Ice::PropertiesPtr _properties; // Immutable, not reset by destroy(). - ::Ice::LoggerPtr _logger; // Not reset by destroy(). - TraceLevelsPtr _traceLevels; // Immutable, not reset by destroy(). - DefaultsAndOverridesPtr _defaultsAndOverrides; // Immutable, not reset by destroy(). - RouterManagerPtr _routerManager; - ReferenceFactoryPtr _referenceFactory; - ProxyFactoryPtr _proxyFactory; - OutgoingConnectionFactoryPtr _outgoingConnectionFactory; - ObjectFactoryManagerPtr _servantFactoryManager; - UserExceptionFactoryManagerPtr _userExceptionFactoryManager; - ObjectAdapterFactoryPtr _objectAdapterFactory; - ThreadPoolPtr _clientThreadPool; - ThreadPoolPtr _serverThreadPool; - EndpointFactoryManagerPtr _endpointFactoryManager; - ::Ice::PluginManagerPtr _pluginManager; - - // - // Global state management - // - friend class GlobalStateMutexDestroyer; - static int _globalStateCounter; - static ::IceUtil::Mutex* _globalStateMutex; -#ifndef _WIN32 - static std::string _identForOpenlog; -#endif -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_INSTANCE_H
+#define ICE_INSTANCE_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <IceUtil/RecMutex.h>
+#include <Ice/InstanceF.h>
+#include <Ice/CommunicatorF.h>
+#include <Ice/PropertiesF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/DefaultsAndOverridesF.h>
+#include <Ice/RouterInfoF.h>
+#include <Ice/ReferenceFactoryF.h>
+#include <Ice/ProxyFactoryF.h>
+#include <Ice/ThreadPoolF.h>
+#include <Ice/ConnectionFactoryF.h>
+#include <Ice/ObjectFactoryManagerF.h>
+#include <Ice/UserExceptionFactoryManagerF.h>
+#include <Ice/ObjectAdapterFactoryF.h>
+#include <Ice/EndpointFactoryManagerF.h>
+#include <Ice/PluginF.h>
+#include <list>
+
+namespace Ice
+{
+
+class CommunicatorI;
+
+}
+
+namespace IceInternal
+{
+
+class Instance : public ::IceUtil::Shared, public ::IceUtil::RecMutex
+{
+public:
+
+ ::Ice::CommunicatorPtr communicator();
+ ::Ice::PropertiesPtr properties();
+ ::Ice::LoggerPtr logger();
+ void logger(const ::Ice::LoggerPtr&);
+ TraceLevelsPtr traceLevels();
+ DefaultsAndOverridesPtr defaultsAndOverrides();
+ RouterManagerPtr routerManager();
+ ReferenceFactoryPtr referenceFactory();
+ ProxyFactoryPtr proxyFactory();
+ OutgoingConnectionFactoryPtr outgoingConnectionFactory();
+ ObjectFactoryManagerPtr servantFactoryManager();
+ UserExceptionFactoryManagerPtr userExceptionFactoryManager();
+ ObjectAdapterFactoryPtr objectAdapterFactory();
+ ThreadPoolPtr clientThreadPool();
+ ThreadPoolPtr serverThreadPool();
+ EndpointFactoryManagerPtr endpointFactoryManager();
+ ::Ice::PluginManagerPtr pluginManager();
+
+private:
+
+ Instance(const ::Ice::CommunicatorPtr&, int&, char*[], const ::Ice::PropertiesPtr&);
+ virtual ~Instance();
+ void finishSetup(int&, char*[]);
+ void destroy();
+ friend class ::Ice::CommunicatorI;
+
+ ::Ice::CommunicatorPtr _communicator;
+ ::Ice::PropertiesPtr _properties; // Immutable, not reset by destroy().
+ ::Ice::LoggerPtr _logger; // Not reset by destroy().
+ TraceLevelsPtr _traceLevels; // Immutable, not reset by destroy().
+ DefaultsAndOverridesPtr _defaultsAndOverrides; // Immutable, not reset by destroy().
+ RouterManagerPtr _routerManager;
+ ReferenceFactoryPtr _referenceFactory;
+ ProxyFactoryPtr _proxyFactory;
+ OutgoingConnectionFactoryPtr _outgoingConnectionFactory;
+ ObjectFactoryManagerPtr _servantFactoryManager;
+ UserExceptionFactoryManagerPtr _userExceptionFactoryManager;
+ ObjectAdapterFactoryPtr _objectAdapterFactory;
+ ThreadPoolPtr _clientThreadPool;
+ ThreadPoolPtr _serverThreadPool;
+ EndpointFactoryManagerPtr _endpointFactoryManager;
+ ::Ice::PluginManagerPtr _pluginManager;
+
+ //
+ // Global state management
+ //
+ friend class GlobalStateMutexDestroyer;
+ static int _globalStateCounter;
+ static ::IceUtil::Mutex* _globalStateMutex;
+#ifndef _WIN32
+ static std::string _identForOpenlog;
+#endif
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index b37819a6387..06472990f26 100644 --- a/cpp/src/Ice/LoggerI.cpp +++ b/cpp/src/Ice/LoggerI.cpp @@ -20,7 +20,7 @@ Ice::LoggerI::trace(const string& category, const string& message) IceUtil::Mutex::Lock sync(*this); string s = "[ " + category + ": " + message + " ]"; string::size_type idx = 0; - while ((idx = s.find("\n", idx)) != string::npos) + while((idx = s.find("\n", idx)) != string::npos) { s.insert(idx + 1, " "); ++idx; diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h index d7866b8e462..25ac67eebe1 100644 --- a/cpp/src/Ice/LoggerI.h +++ b/cpp/src/Ice/LoggerI.h @@ -1,31 +1,31 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_LOGGER_I_H -#define ICE_LOGGER_I_H - -#include <IceUtil/Mutex.h> -#include <Ice/Logger.h> - -namespace Ice -{ - -class LoggerI : public Logger, public ::IceUtil::Mutex -{ -public: - - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_LOGGER_I_H
+#define ICE_LOGGER_I_H
+
+#include <IceUtil/Mutex.h>
+#include <Ice/Logger.h>
+
+namespace Ice
+{
+
+class LoggerI : public Logger, public ::IceUtil::Mutex
+{
+public:
+
+ virtual void trace(const std::string&, const std::string&);
+ virtual void warning(const std::string&);
+ virtual void error(const std::string&);
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/LoggerUtil.cpp b/cpp/src/Ice/LoggerUtil.cpp index 1b803bc304a..ca19aea13dd 100644 --- a/cpp/src/Ice/LoggerUtil.cpp +++ b/cpp/src/Ice/LoggerUtil.cpp @@ -29,7 +29,7 @@ void Ice::Warning::flush() { string s = _str.str(); - if (!s.empty()) + if(!s.empty()) { _logger->warning(s); } @@ -63,7 +63,7 @@ void Ice::Error::flush() { string s = _str.str(); - if (!s.empty()) + if(!s.empty()) { _logger->error(s); } @@ -98,7 +98,7 @@ void Ice::Trace::flush() { string s = _str.str(); - if (!s.empty()) + if(!s.empty()) { _logger->trace(_category, s); } diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 4c8007df1f5..9bbb26d9bdf 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -21,12 +21,12 @@ IceInternal::interrupted() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAEINTR) + if(error == WSAEINTR) { return true; } #else - if (errno == EINTR || + if(errno == EINTR || errno == EPROTO) { return true; @@ -41,21 +41,21 @@ IceInternal::interrupted() bool IceInternal::acceptInterrupted() { - if (interrupted()) + if(interrupted()) { return true; } #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAECONNABORTED || + if(error == WSAECONNABORTED || error == WSAECONNRESET || error == WSAETIMEDOUT) { return true; } #else - if (errno == ECONNABORTED || + if(errno == ECONNABORTED || errno == ECONNRESET || errno == ETIMEDOUT) { @@ -73,13 +73,13 @@ IceInternal::noBuffers() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAENOBUFS || + if(error == WSAENOBUFS || error == WSAEFAULT) { return true; } #else - if (errno == ENOBUFS) + if(errno == ENOBUFS) { return true; } @@ -95,12 +95,12 @@ IceInternal::wouldBlock() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAEWOULDBLOCK) + if(error == WSAEWOULDBLOCK) { return true; } #else - if (errno == EAGAIN || + if(errno == EAGAIN || errno == EWOULDBLOCK) { return true; @@ -117,7 +117,7 @@ IceInternal::connectFailed() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAECONNREFUSED || + if(error == WSAECONNREFUSED || error == WSAETIMEDOUT || error == WSAENETUNREACH || error == WSAECONNRESET || @@ -127,7 +127,7 @@ IceInternal::connectFailed() return true; } #else - if (errno == ECONNREFUSED || + if(errno == ECONNREFUSED || errno == ETIMEDOUT || errno == ENETUNREACH || errno == ECONNRESET || @@ -148,12 +148,12 @@ IceInternal::connectInProgress() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAEWOULDBLOCK) + if(error == WSAEWOULDBLOCK) { return true; } #else - if (errno == EINPROGRESS) + if(errno == EINPROGRESS) { return true; } @@ -169,14 +169,14 @@ IceInternal::connectionLost() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAECONNRESET || + if(error == WSAECONNRESET || error == WSAESHUTDOWN || error == WSAECONNABORTED) { return true; } #else - if (errno == ECONNRESET || + if(errno == ECONNRESET || errno == ESHUTDOWN || errno == ECONNABORTED) { @@ -194,12 +194,12 @@ IceInternal::notConnected() { #ifdef _WIN32 int error = WSAGetLastError(); - if (error == WSAENOTCONN) + if(error == WSAENOTCONN) { return true; } #else - if (errno == ENOTCONN) + if(errno == ENOTCONN) { return true; } @@ -215,7 +215,7 @@ IceInternal::createSocket(bool udp) { SOCKET fd; - if (udp) + if(udp) { fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); } @@ -224,14 +224,14 @@ IceInternal::createSocket(bool udp) fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); } - if (fd == INVALID_SOCKET) + if(fd == INVALID_SOCKET) { SocketException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); throw ex; } - if (!udp) + if(!udp) { setTcpNoDelay(fd); setKeepAlive(fd); @@ -257,7 +257,7 @@ IceInternal::closeSocket(SOCKET fd) void IceInternal::setBlock(SOCKET fd, bool block) { - if (block) + if(block) { #ifdef _WIN32 unsigned long arg = 0; @@ -285,7 +285,7 @@ void IceInternal::setTcpNoDelay(SOCKET fd) { int flag = 1; - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int)) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -298,7 +298,7 @@ void IceInternal::setKeepAlive(SOCKET fd) { int flag = 1; - if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&flag, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&flag, sizeof(int)) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -310,7 +310,7 @@ IceInternal::setKeepAlive(SOCKET fd) void IceInternal::setSendBufferSize(SOCKET fd, int sz) { - if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, sizeof(int)) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -324,7 +324,7 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr) { #ifndef _WIN32 int flag = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, sizeof(int)) == SOCKET_ERROR) + if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, sizeof(int)) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -333,7 +333,7 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr) } #endif - if (bind(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) + if(bind(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -354,9 +354,9 @@ void IceInternal::doListen(SOCKET fd, int backlog) { repeatListen: - if (::listen(fd, backlog) == SOCKET_ERROR) + if(::listen(fd, backlog) == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatListen; } @@ -380,14 +380,14 @@ IceInternal::doConnect(SOCKET fd, struct sockaddr_in& addr, int timeout) #endif repeatConnect: - if (::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) + if(::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatConnect; } - if (connectInProgress()) + if(connectInProgress()) { repeatSelect: int ret; @@ -403,7 +403,7 @@ repeatConnect: FD_ZERO(&xFdSet); FD_SET(fd, &xFdSet); #endif - if (timeout >= 0) + if(timeout >= 0) { struct timeval tv; tv.tv_sec = timeout / 1000; @@ -423,14 +423,14 @@ repeatConnect: #endif } - if (ret == 0) + if(ret == 0) { closeSocket(fd); throw ConnectTimeoutException(__FILE__, __LINE__); } - else if (ret == SOCKET_ERROR) + else if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -450,7 +450,7 @@ repeatConnect: #endif socklen_t len = sizeof(socklen_t); int val; - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR) + if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -458,7 +458,7 @@ repeatConnect: throw ex; } - if (val > 0) + if(val > 0) { closeSocket(fd); #ifdef _WIN32 @@ -466,7 +466,7 @@ repeatConnect: #else errno = val; #endif - if (connectFailed()) + if(connectFailed()) { ConnectFailedException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -484,7 +484,7 @@ repeatConnect: } closeSocket(fd); - if (connectFailed()) + if(connectFailed()) { ConnectFailedException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -505,21 +505,21 @@ IceInternal::doAccept(SOCKET fd, int timeout) int ret; repeatAccept: - if ((ret = ::accept(fd, 0, 0)) == INVALID_SOCKET) + if((ret = ::accept(fd, 0, 0)) == INVALID_SOCKET) { - if (acceptInterrupted()) + if(acceptInterrupted()) { goto repeatAccept; } - if (wouldBlock()) + if(wouldBlock()) { repeatSelect: int ret; fd_set fdSet; FD_ZERO(&fdSet); FD_SET(fd, &fdSet); - if (timeout >= 0) + if(timeout >= 0) { struct timeval tv; tv.tv_sec = timeout / 1000; @@ -531,9 +531,9 @@ repeatAccept: ret = ::select(fd + 1, 0, &fdSet, 0, 0); } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -543,7 +543,7 @@ repeatAccept: throw ex; } - if (ret == 0) + if(ret == 0) { throw TimeoutException(__FILE__, __LINE__); } @@ -581,7 +581,7 @@ IceInternal::getAddress(const string& host, int port, struct sockaddr_in& addr) addr.sin_port = htons(port); addr.sin_addr.s_addr = inet_addr(host.c_str()); - if (addr.sin_addr.s_addr == INADDR_NONE) + if(addr.sin_addr.s_addr == INADDR_NONE) { IceUtil::Mutex::Lock sync(getHostByNameMutex); @@ -593,12 +593,12 @@ IceInternal::getAddress(const string& host, int port, struct sockaddr_in& addr) entry = gethostbyname(host.c_str()); } #ifdef _WIN32 - while (!entry && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0); + while(!entry && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0); #else - while (!entry && h_errno == TRY_AGAIN && --retry >= 0); + while(!entry && h_errno == TRY_AGAIN && --retry >= 0); #endif - if (!entry) + if(!entry) { DNSException ex(__FILE__, __LINE__); ex.error = getDNSErrno(); @@ -613,7 +613,7 @@ string IceInternal::getLocalHost(bool numeric) { char host[1024 + 1]; - if (gethostname(host, 1024) == SOCKET_ERROR) + if(gethostname(host, 1024) == SOCKET_ERROR) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -631,19 +631,19 @@ IceInternal::getLocalHost(bool numeric) entry = gethostbyname(host); } #ifdef _WIN32 - while (!entry && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0); + while(!entry && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0); #else - while (!entry && h_errno == TRY_AGAIN && --retry >= 0); + while(!entry && h_errno == TRY_AGAIN && --retry >= 0); #endif - if (!entry) + if(!entry) { DNSException ex(__FILE__, __LINE__); ex.error = getDNSErrno(); throw ex; } - if (numeric) + if(numeric) { struct sockaddr_in addr; memset(&addr, 0, sizeof(struct sockaddr_in)); @@ -710,7 +710,7 @@ IceInternal::createPipe(SOCKET fds[2]) #else - if (::pipe(fds) != 0) + if(::pipe(fds) != 0) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -728,7 +728,7 @@ IceInternal::createPipe(SOCKET fds[2]) string IceInternal::errorToString(int error) { - if (error < WSABASEERR) + if(error < WSABASEERR) { LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -743,7 +743,7 @@ IceInternal::errorToString(int error) return result; } - switch (error) + switch(error) { case WSAEINTR: return "WSAEINTR"; @@ -920,7 +920,7 @@ IceInternal::errorToString(int error) string IceInternal::errorToStringDNS(int error) { - switch (error) + switch(error) { case NETDB_SUCCESS: return "no problem"; @@ -979,7 +979,7 @@ IceInternal::fdToString(SOCKET fd) socklen_t localLen = sizeof(struct sockaddr_in); struct sockaddr_in localAddr; - if (getsockname(fd, reinterpret_cast<struct sockaddr*>(&localAddr), &localLen) == SOCKET_ERROR) + if(getsockname(fd, reinterpret_cast<struct sockaddr*>(&localAddr), &localLen) == SOCKET_ERROR) { closeSocket(fd); SocketException ex(__FILE__, __LINE__); @@ -990,9 +990,9 @@ IceInternal::fdToString(SOCKET fd) bool peerNotConnected = false; socklen_t remoteLen = sizeof(struct sockaddr_in); struct sockaddr_in remoteAddr; - if (getpeername(fd, reinterpret_cast<struct sockaddr*>(&remoteAddr), &remoteLen) == SOCKET_ERROR) + if(getpeername(fd, reinterpret_cast<struct sockaddr*>(&remoteAddr), &remoteLen) == SOCKET_ERROR) { - if (notConnected()) + if(notConnected()) { peerNotConnected = true; } @@ -1011,7 +1011,7 @@ IceInternal::fdToString(SOCKET fd) IceUtil::Mutex::Lock sync(inetNtoaMutex); s << "local address = " << inet_ntoa(localAddr.sin_addr) << ':' << ntohs(localAddr.sin_port); - if (peerNotConnected) + if(peerNotConnected) { s << "\nremote address = <not connected>"; } diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index 4196c109080..ac57f0b15ae 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -1,100 +1,100 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_NETWORK_H -#define ICE_NETWORK_H - -#include <Ice/Config.h> - -#ifdef _WIN32 -# include <winsock.h> -#else -# include <unistd.h> -# include <fcntl.h> -# include <sys/socket.h> -# include <sys/select.h> -# include <netinet/in.h> -# include <netinet/tcp.h> -# include <arpa/inet.h> -# include <netdb.h> -#endif - -#ifdef _WIN32 -typedef int socklen_t; -#endif - -#ifndef _WIN32 -# define SOCKET int -# define SOCKET_ERROR -1 -# define INVALID_SOCKET -1 -#endif - -#ifndef SHUT_RD -# define SHUT_RD 0 -#endif - -#ifndef SHUT_WR -# define SHUT_WR 1 -#endif - -#ifndef SHUT_RDWR -# define SHUT_RDWR 2 -#endif - -#ifndef NETDB_INTERNAL -# define NETDB_INTERNAL -1 -#endif - -#ifndef NETDB_SUCCESS -# define NETDB_SUCCESS 0 -#endif - -namespace IceInternal -{ - -ICE_PROTOCOL_API bool interrupted(); -ICE_PROTOCOL_API bool acceptInterrupted(); -ICE_PROTOCOL_API bool noBuffers(); -ICE_PROTOCOL_API bool wouldBlock(); -ICE_PROTOCOL_API bool connectFailed(); -ICE_PROTOCOL_API bool connectInProgress(); -ICE_PROTOCOL_API bool connectionLost(); -ICE_PROTOCOL_API bool notConnected(); - -ICE_PROTOCOL_API SOCKET createSocket(bool); -ICE_PROTOCOL_API void closeSocket(SOCKET); - -ICE_PROTOCOL_API void setBlock(SOCKET, bool); -ICE_PROTOCOL_API void setTcpNoDelay(SOCKET); -ICE_PROTOCOL_API void setKeepAlive(SOCKET); -ICE_PROTOCOL_API void setSendBufferSize(SOCKET, int); - -ICE_PROTOCOL_API void doBind(SOCKET, struct sockaddr_in&); -ICE_PROTOCOL_API void doListen(SOCKET, int); -ICE_PROTOCOL_API void doConnect(SOCKET, struct sockaddr_in&, int); -ICE_PROTOCOL_API SOCKET doAccept(SOCKET, int); - -ICE_PROTOCOL_API void getAddress(const std::string&, int, struct sockaddr_in&); -ICE_PROTOCOL_API std::string getLocalHost(bool); -ICE_PROTOCOL_API bool compareAddress(const struct sockaddr_in&, const struct sockaddr_in&); - -ICE_PROTOCOL_API void createPipe(SOCKET fds[2]); - -ICE_PROTOCOL_API std::string errorToString(int); -ICE_PROTOCOL_API std::string errorToStringDNS(int); -ICE_PROTOCOL_API std::string lastErrorToString(); -ICE_PROTOCOL_API std::string lastErrorToStringDNS(); - -ICE_PROTOCOL_API std::string fdToString(SOCKET); -ICE_PROTOCOL_API std::string addrToString(const struct sockaddr_in&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_NETWORK_H
+#define ICE_NETWORK_H
+
+#include <Ice/Config.h>
+
+#ifdef _WIN32
+# include <winsock.h>
+#else
+# include <unistd.h>
+# include <fcntl.h>
+# include <sys/socket.h>
+# include <sys/select.h>
+# include <netinet/in.h>
+# include <netinet/tcp.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+#endif
+
+#ifdef _WIN32
+typedef int socklen_t;
+#endif
+
+#ifndef _WIN32
+# define SOCKET int
+# define SOCKET_ERROR -1
+# define INVALID_SOCKET -1
+#endif
+
+#ifndef SHUT_RD
+# define SHUT_RD 0
+#endif
+
+#ifndef SHUT_WR
+# define SHUT_WR 1
+#endif
+
+#ifndef SHUT_RDWR
+# define SHUT_RDWR 2
+#endif
+
+#ifndef NETDB_INTERNAL
+# define NETDB_INTERNAL -1
+#endif
+
+#ifndef NETDB_SUCCESS
+# define NETDB_SUCCESS 0
+#endif
+
+namespace IceInternal
+{
+
+ICE_PROTOCOL_API bool interrupted();
+ICE_PROTOCOL_API bool acceptInterrupted();
+ICE_PROTOCOL_API bool noBuffers();
+ICE_PROTOCOL_API bool wouldBlock();
+ICE_PROTOCOL_API bool connectFailed();
+ICE_PROTOCOL_API bool connectInProgress();
+ICE_PROTOCOL_API bool connectionLost();
+ICE_PROTOCOL_API bool notConnected();
+
+ICE_PROTOCOL_API SOCKET createSocket(bool);
+ICE_PROTOCOL_API void closeSocket(SOCKET);
+
+ICE_PROTOCOL_API void setBlock(SOCKET, bool);
+ICE_PROTOCOL_API void setTcpNoDelay(SOCKET);
+ICE_PROTOCOL_API void setKeepAlive(SOCKET);
+ICE_PROTOCOL_API void setSendBufferSize(SOCKET, int);
+
+ICE_PROTOCOL_API void doBind(SOCKET, struct sockaddr_in&);
+ICE_PROTOCOL_API void doListen(SOCKET, int);
+ICE_PROTOCOL_API void doConnect(SOCKET, struct sockaddr_in&, int);
+ICE_PROTOCOL_API SOCKET doAccept(SOCKET, int);
+
+ICE_PROTOCOL_API void getAddress(const std::string&, int, struct sockaddr_in&);
+ICE_PROTOCOL_API std::string getLocalHost(bool);
+ICE_PROTOCOL_API bool compareAddress(const struct sockaddr_in&, const struct sockaddr_in&);
+
+ICE_PROTOCOL_API void createPipe(SOCKET fds[2]);
+
+ICE_PROTOCOL_API std::string errorToString(int);
+ICE_PROTOCOL_API std::string errorToStringDNS(int);
+ICE_PROTOCOL_API std::string lastErrorToString();
+ICE_PROTOCOL_API std::string lastErrorToStringDNS();
+
+ICE_PROTOCOL_API std::string fdToString(SOCKET);
+ICE_PROTOCOL_API std::string addrToString(const struct sockaddr_in&);
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 66f63eb84ce..9543d7b6f85 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -92,7 +92,7 @@ vector<string> Ice::Object::ice_facets(const Current&) { vector<string> v; - for (map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) + for(map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) { v.push_back(p->first); } @@ -168,12 +168,12 @@ Ice::Object::__dispatch(Incoming& in, const Current& current) pair<const string*, const string*> r = equal_range(__all, __all + sizeof(__all) / sizeof(string), current.operation); - if (r.first == r.second) + if(r.first == r.second) { return DispatchOperationNotExist; } - switch (r.first - __all) + switch(r.first - __all) { case 0: { @@ -207,7 +207,7 @@ Ice::Object::__write(::IceInternal::BasicStream* __os) const IceUtil::Mutex::Lock sync(_activeFacetMapMutex); __os->writeSize(Int(_activeFacetMap.size())); - for (map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) + for(map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) { __os->write(p->first); __os->write(p->second); @@ -225,7 +225,7 @@ Ice::Object::__read(::IceInternal::BasicStream* __is) _activeFacetMap.clear(); _activeFacetMapHint = _activeFacetMap.end(); - while (sz-- > 0) + while(sz-- > 0) { pair<string, ObjectPtr> v; __is->read(v.first); @@ -240,7 +240,7 @@ Ice::Object::__marshal(const ::Ice::StreamPtr& __os) const IceUtil::Mutex::Lock sync(_activeFacetMapMutex); __os->startWriteDictionary("ice:facets", _activeFacetMap.size()); - for (map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) + for(map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p) { __os->startWriteDictionaryElement(); __os->writeString("key", p->first); @@ -265,7 +265,7 @@ Ice::Object::__unmarshal(const ::Ice::StreamPtr& __is) _activeFacetMap.clear(); _activeFacetMapHint = _activeFacetMap.end(); - while (sz-- > 0) + while(sz-- > 0) { __is->startReadDictionaryElement(); pair<string, ObjectPtr> v; @@ -304,22 +304,22 @@ Ice::Object::ice_removeFacet(const string& name) map<string, ObjectPtr>::iterator p = _activeFacetMap.end(); - if (_activeFacetMapHint != _activeFacetMap.end()) + if(_activeFacetMapHint != _activeFacetMap.end()) { - if (_activeFacetMapHint->first == name) + if(_activeFacetMapHint->first == name) { p = _activeFacetMapHint; } } - if (p == _activeFacetMap.end()) + if(p == _activeFacetMap.end()) { p = _activeFacetMap.find(name); } - if (p != _activeFacetMap.end()) + if(p != _activeFacetMap.end()) { - if (p == _activeFacetMapHint) + if(p == _activeFacetMapHint) { _activeFacetMap.erase(p++); _activeFacetMapHint = p; @@ -347,20 +347,20 @@ Ice::Object::ice_findFacet(const string& name) map<string, ObjectPtr>::iterator p = _activeFacetMap.end(); - if (_activeFacetMapHint != _activeFacetMap.end()) + if(_activeFacetMapHint != _activeFacetMap.end()) { - if (_activeFacetMapHint->first == name) + if(_activeFacetMapHint->first == name) { p = _activeFacetMapHint; } } - if (p == _activeFacetMap.end()) + if(p == _activeFacetMap.end()) { p = _activeFacetMap.find(name); } - if (p != _activeFacetMap.end()) + if(p != _activeFacetMap.end()) { _activeFacetMapHint = p; return p->second; @@ -380,7 +380,7 @@ Ice::Blobject::__dispatch(Incoming& in, const Current& current) in.is()->readBlob(inParams, sz); bool ok = ice_invoke(inParams, outParams, current); in.os()->writeBlob(outParams); - if (ok) + if(ok) { return ::IceInternal::DispatchOK; } diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp index ba2e6604c07..0933965b2da 100644 --- a/cpp/src/Ice/ObjectAdapterFactory.cpp +++ b/cpp/src/Ice/ObjectAdapterFactory.cpp @@ -34,7 +34,7 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const { IceUtil::RecMutex::Lock sync(*this); map<string, ObjectAdapterIPtr>::iterator p = _adapters.find(name); - if (p != _adapters.end()) + if(p != _adapters.end()) { return p->second; } @@ -47,9 +47,9 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const ObjectAdapterPtr IceInternal::ObjectAdapterFactory::findObjectAdapter(const ObjectPrx& proxy) { - for (map<string, ObjectAdapterIPtr>::iterator p = _adapters.begin(); p != _adapters.end(); ++p) + for(map<string, ObjectAdapterIPtr>::iterator p = _adapters.begin(); p != _adapters.end(); ++p) { - if (p->second->isLocal(proxy)) + if(p->second->isLocal(proxy)) { return p->second; } diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h index b9a10c46aa2..0eeb03c956f 100644 --- a/cpp/src/Ice/ObjectAdapterFactory.h +++ b/cpp/src/Ice/ObjectAdapterFactory.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OBJECT_ADAPTER_FACTORY_H -#define ICE_OBJECT_ADAPTER_FACTORY_H - -#include <Ice/ObjectAdapterI.h> -#include <IceUtil/RecMutex.h> - -namespace IceInternal -{ - -class ObjectAdapterFactory : public ::IceUtil::Shared, public ::IceUtil::RecMutex -{ -public: - - void shutdown(); - ::Ice::ObjectAdapterPtr createObjectAdapter(const std::string&, const std::string&); - ::Ice::ObjectAdapterPtr findObjectAdapter(const ::Ice::ObjectPrx&); - -private: - - ObjectAdapterFactory(const InstancePtr&); - friend class Instance; - - InstancePtr _instance; - std::map<std::string, ::Ice::ObjectAdapterIPtr> _adapters; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OBJECT_ADAPTER_FACTORY_H
+#define ICE_OBJECT_ADAPTER_FACTORY_H
+
+#include <Ice/ObjectAdapterI.h>
+#include <IceUtil/RecMutex.h>
+
+namespace IceInternal
+{
+
+class ObjectAdapterFactory : public ::IceUtil::Shared, public ::IceUtil::RecMutex
+{
+public:
+
+ void shutdown();
+ ::Ice::ObjectAdapterPtr createObjectAdapter(const std::string&, const std::string&);
+ ::Ice::ObjectAdapterPtr findObjectAdapter(const ::Ice::ObjectPrx&);
+
+private:
+
+ ObjectAdapterFactory(const InstancePtr&);
+ friend class Instance;
+
+ InstancePtr _instance;
+ std::map<std::string, ::Ice::ObjectAdapterIPtr> _adapters;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 638b62b0823..0a496e35d0f 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -45,7 +45,7 @@ Ice::ObjectAdapterI::getCommunicator() { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -58,7 +58,7 @@ Ice::ObjectAdapterI::activate() { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -66,9 +66,9 @@ Ice::ObjectAdapterI::activate() for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), Ice::voidMemFun(&IncomingConnectionFactory::activate)); - if (!_printAdapterReadyDone) + if(!_printAdapterReadyDone) { - if (_instance->properties()->getPropertyAsInt("Ice.PrintAdapterReady") > 0) + if(_instance->properties()->getPropertyAsInt("Ice.PrintAdapterReady") > 0) { cout << _name << " ready" << endl; } @@ -82,7 +82,7 @@ Ice::ObjectAdapterI::hold() { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -96,7 +96,7 @@ Ice::ObjectAdapterI::deactivate() { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { // // Ignore deactivation requests if the Object Adapter has @@ -138,7 +138,7 @@ Ice::ObjectAdapterI::add(const ObjectPtr& object, const Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -153,7 +153,7 @@ Ice::ObjectAdapterI::addWithUUID(const ObjectPtr& object) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -171,7 +171,7 @@ Ice::ObjectAdapterI::remove(const Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -185,7 +185,7 @@ Ice::ObjectAdapterI::addServantLocator(const ServantLocatorPtr& locator, const s { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -198,31 +198,31 @@ Ice::ObjectAdapterI::removeServantLocator(const string& prefix) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } map<string, ServantLocatorPtr>::iterator p = _locatorMap.end(); - if (_locatorMapHint != _locatorMap.end()) + if(_locatorMapHint != _locatorMap.end()) { - if (_locatorMapHint->first == prefix) + if(_locatorMapHint->first == prefix) { p = _locatorMapHint; } } - if (p == _locatorMap.end()) + if(p == _locatorMap.end()) { p = _locatorMap.find(prefix); } - if (p != _locatorMap.end()) + if(p != _locatorMap.end()) { p->second->deactivate(); - if (p == _locatorMapHint) + if(p == _locatorMapHint) { _locatorMap.erase(p++); _locatorMapHint = p; @@ -239,27 +239,27 @@ Ice::ObjectAdapterI::findServantLocator(const string& prefix) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } map<string, ServantLocatorPtr>::iterator p = _locatorMap.end(); - if (_locatorMapHint != _locatorMap.end()) + if(_locatorMapHint != _locatorMap.end()) { - if (_locatorMapHint->first == prefix) + if(_locatorMapHint->first == prefix) { p = _locatorMapHint; } } - if (p == _locatorMap.end()) + if(p == _locatorMap.end()) { p = _locatorMap.find(prefix); } - if (p != _locatorMap.end()) + if(p != _locatorMap.end()) { _locatorMapHint = p; return p->second; @@ -275,16 +275,16 @@ Ice::ObjectAdapterI::identityToServant(const Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (_activeServantMapHint != _activeServantMap.end()) + if(_activeServantMapHint != _activeServantMap.end()) { - if (_activeServantMapHint->first == ident) + if(_activeServantMapHint->first == ident) { return _activeServantMapHint->second; } } ObjectDict::iterator p = _activeServantMap.find(ident); - if (p != _activeServantMap.end()) + if(p != _activeServantMap.end()) { _activeServantMapHint = p; return p->second; @@ -307,7 +307,7 @@ Ice::ObjectAdapterI::createProxy(const Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -320,7 +320,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } @@ -339,13 +339,13 @@ Ice::ObjectAdapterI::addRouter(const RouterPrx& router) { IceUtil::Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw ObjectAdapterDeactivatedException(__FILE__, __LINE__); } RouterInfoPtr routerInfo = _instance->routerManager()->get(router); - if (routerInfo) + if(routerInfo) { // // Add the router's server proxy endpoints to this object @@ -386,7 +386,7 @@ Ice::ObjectAdapterI::getIncomingConnections() const // list<ConnectionPtr> connections; vector<IncomingConnectionFactoryPtr>::const_iterator p; - for (p = _incomingConnectionFactories.begin(); p != _incomingConnectionFactories.end(); ++p) + for(p = _incomingConnectionFactories.begin(); p != _incomingConnectionFactories.end(); ++p) { list<ConnectionPtr> cons = (*p)->connections(); connections.splice(connections.end(), cons); @@ -410,23 +410,23 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& n string::size_type beg; string::size_type end = 0; - while (end < s.length()) + while(end < s.length()) { static const string delim = " \t\n\r"; beg = s.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } end = s.find(':', beg); - if (end == string::npos) + if(end == string::npos) { end = s.length(); } - if (end == beg) + if(end == beg) { break; } @@ -458,7 +458,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& n // router. (See addRouter.) // /* - if (_incomingConnectionFactories.empty()) + if(_incomingConnectionFactories.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -467,7 +467,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const string& n Ice::ObjectAdapterI::~ObjectAdapterI() { - if (_instance) + if(_instance) { Warning out(_instance->logger()); out << "object adapter has not been deactivated"; @@ -515,12 +515,12 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const // endpoints used by this object adapter's incoming connection // factories are considered local. // - for (p = ref->endpoints.begin(); p != ref->endpoints.end(); ++p) + for(p = ref->endpoints.begin(); p != ref->endpoints.end(); ++p) { vector<IncomingConnectionFactoryPtr>::const_iterator q; - for (q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q) + for(q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q) { - if ((*q)->equivalent(*p)) + if((*q)->equivalent(*p)) { return true; } @@ -535,9 +535,9 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const // router's server proxy endpoints (if any), are also considered // local. // - for (p = ref->endpoints.begin(); p != ref->endpoints.end(); ++p) + for(p = ref->endpoints.begin(); p != ref->endpoints.end(); ++p) { - if (binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted. + if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted. { return true; } diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index e9378be1c67..b31e15626f4 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -1,86 +1,86 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OBJECT_ADAPTER_I_H -#define ICE_OBJECT_ADAPTER_I_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/ObjectAdapter.h> -#include <Ice/InstanceF.h> -#include <Ice/ObjectAdapterFactoryF.h> -#include <Ice/CommunicatorF.h> -#include <Ice/ConnectionFactoryF.h> -#include <Ice/ProxyF.h> -#include <Ice/ObjectF.h> -#include <Ice/Exception.h> -#include <Ice/EndpointF.h> -#include <list> - -namespace Ice -{ - -class ObjectAdapterI; -typedef IceUtil::Handle<ObjectAdapterI> ObjectAdapterIPtr; - -class ObjectAdapterI : public ObjectAdapter, public ::IceUtil::Mutex -{ -public: - - virtual std::string getName(); - virtual CommunicatorPtr getCommunicator(); - - virtual void activate(); - virtual void hold(); - virtual void deactivate(); - virtual void waitForDeactivate(); - - virtual ObjectPrx add(const ObjectPtr&, const Identity&); - virtual ObjectPrx addWithUUID(const ObjectPtr&); - virtual void remove(const Identity&); - - virtual void addServantLocator(const ServantLocatorPtr&, const std::string&); - virtual void removeServantLocator(const std::string&); - virtual ServantLocatorPtr findServantLocator(const std::string&); - - virtual ObjectPtr identityToServant(const Identity&); - virtual ObjectPtr proxyToServant(const ObjectPrx&); - - virtual ObjectPrx createProxy(const Identity&); - virtual ObjectPrx createReverseProxy(const Identity&); - - virtual void addRouter(const RouterPrx&); - - std::list< ::IceInternal::ConnectionPtr> getIncomingConnections() const; - -private: - - ObjectAdapterI(const ::IceInternal::InstancePtr&, const std::string&, const std::string&); - virtual ~ObjectAdapterI(); - friend class ::IceInternal::ObjectAdapterFactory; - - ObjectPrx newProxy(const Identity&) const; - bool isLocal(const ObjectPrx&) const; - - ::IceInternal::InstancePtr _instance; - bool _printAdapterReadyDone; - std::string _name; - ObjectDict _activeServantMap; - ObjectDict::iterator _activeServantMapHint; - std::map<std::string, ServantLocatorPtr> _locatorMap; - std::map<std::string, ServantLocatorPtr>::iterator _locatorMapHint; - std::vector< ::IceInternal::IncomingConnectionFactoryPtr> _incomingConnectionFactories; - std::vector< ::IceInternal::EndpointPtr> _routerEndpoints; - IceUtil::Mutex _routerEndpointsMutex; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OBJECT_ADAPTER_I_H
+#define ICE_OBJECT_ADAPTER_I_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/ObjectAdapter.h>
+#include <Ice/InstanceF.h>
+#include <Ice/ObjectAdapterFactoryF.h>
+#include <Ice/CommunicatorF.h>
+#include <Ice/ConnectionFactoryF.h>
+#include <Ice/ProxyF.h>
+#include <Ice/ObjectF.h>
+#include <Ice/Exception.h>
+#include <Ice/EndpointF.h>
+#include <list>
+
+namespace Ice
+{
+
+class ObjectAdapterI;
+typedef IceUtil::Handle<ObjectAdapterI> ObjectAdapterIPtr;
+
+class ObjectAdapterI : public ObjectAdapter, public ::IceUtil::Mutex
+{
+public:
+
+ virtual std::string getName();
+ virtual CommunicatorPtr getCommunicator();
+
+ virtual void activate();
+ virtual void hold();
+ virtual void deactivate();
+ virtual void waitForDeactivate();
+
+ virtual ObjectPrx add(const ObjectPtr&, const Identity&);
+ virtual ObjectPrx addWithUUID(const ObjectPtr&);
+ virtual void remove(const Identity&);
+
+ virtual void addServantLocator(const ServantLocatorPtr&, const std::string&);
+ virtual void removeServantLocator(const std::string&);
+ virtual ServantLocatorPtr findServantLocator(const std::string&);
+
+ virtual ObjectPtr identityToServant(const Identity&);
+ virtual ObjectPtr proxyToServant(const ObjectPrx&);
+
+ virtual ObjectPrx createProxy(const Identity&);
+ virtual ObjectPrx createReverseProxy(const Identity&);
+
+ virtual void addRouter(const RouterPrx&);
+
+ std::list< ::IceInternal::ConnectionPtr> getIncomingConnections() const;
+
+private:
+
+ ObjectAdapterI(const ::IceInternal::InstancePtr&, const std::string&, const std::string&);
+ virtual ~ObjectAdapterI();
+ friend class ::IceInternal::ObjectAdapterFactory;
+
+ ObjectPrx newProxy(const Identity&) const;
+ bool isLocal(const ObjectPrx&) const;
+
+ ::IceInternal::InstancePtr _instance;
+ bool _printAdapterReadyDone;
+ std::string _name;
+ ObjectDict _activeServantMap;
+ ObjectDict::iterator _activeServantMapHint;
+ std::map<std::string, ServantLocatorPtr> _locatorMap;
+ std::map<std::string, ServantLocatorPtr>::iterator _locatorMapHint;
+ std::vector< ::IceInternal::IncomingConnectionFactoryPtr> _incomingConnectionFactories;
+ std::vector< ::IceInternal::EndpointPtr> _routerEndpoints;
+ IceUtil::Mutex _routerEndpointsMutex;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ObjectFactoryManager.cpp b/cpp/src/Ice/ObjectFactoryManager.cpp index 49bb6537e1b..ffc4b9a4099 100644 --- a/cpp/src/Ice/ObjectFactoryManager.cpp +++ b/cpp/src/Ice/ObjectFactoryManager.cpp @@ -33,24 +33,24 @@ IceInternal::ObjectFactoryManager::remove(const string& id) map<string, ::Ice::ObjectFactoryPtr>::iterator p = _factoryMap.end(); - if (_factoryMapHint != _factoryMap.end()) + if(_factoryMapHint != _factoryMap.end()) { - if (_factoryMapHint->first == id) + if(_factoryMapHint->first == id) { p = _factoryMapHint; } } - if (p == _factoryMap.end()) + if(p == _factoryMap.end()) { p = _factoryMap.find(id); } - if (p != _factoryMap.end()) + if(p != _factoryMap.end()) { p->second->destroy(); - if (p == _factoryMapHint) + if(p == _factoryMapHint) { _factoryMap.erase(p++); _factoryMapHint = p; @@ -69,20 +69,20 @@ IceInternal::ObjectFactoryManager::find(const string& id) map<string, ::Ice::ObjectFactoryPtr>::iterator p = _factoryMap.end(); - if (_factoryMapHint != _factoryMap.end()) + if(_factoryMapHint != _factoryMap.end()) { - if (_factoryMapHint->first == id) + if(_factoryMapHint->first == id) { p = _factoryMapHint; } } - if (p == _factoryMap.end()) + if(p == _factoryMap.end()) { p = _factoryMap.find(id); } - if (p != _factoryMap.end()) + if(p != _factoryMap.end()) { _factoryMapHint = p; return p->second; diff --git a/cpp/src/Ice/ObjectFactoryManager.h b/cpp/src/Ice/ObjectFactoryManager.h index c10cd4fe09c..df0415714a3 100644 --- a/cpp/src/Ice/ObjectFactoryManager.h +++ b/cpp/src/Ice/ObjectFactoryManager.h @@ -1,42 +1,42 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SERVANT_FACTORY_MANAGER_H -#define ICE_SERVANT_FACTORY_MANAGER_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/ObjectFactoryManagerF.h> -#include <Ice/ObjectFactoryF.h> - -namespace IceInternal -{ - -class ObjectFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - void add(const ::Ice::ObjectFactoryPtr&, const std::string&); - void remove(const std::string&); - ::Ice::ObjectFactoryPtr find(const std::string&); - -private: - - ObjectFactoryManager(); - void destroy(); - friend class Instance; - - std::map<std::string, ::Ice::ObjectFactoryPtr> _factoryMap; - std::map<std::string, ::Ice::ObjectFactoryPtr>::iterator _factoryMapHint; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SERVANT_FACTORY_MANAGER_H
+#define ICE_SERVANT_FACTORY_MANAGER_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/ObjectFactoryManagerF.h>
+#include <Ice/ObjectFactoryF.h>
+
+namespace IceInternal
+{
+
+class ObjectFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ void add(const ::Ice::ObjectFactoryPtr&, const std::string&);
+ void remove(const std::string&);
+ ::Ice::ObjectFactoryPtr find(const std::string&);
+
+private:
+
+ ObjectFactoryManager();
+ void destroy();
+ friend class Instance;
+
+ std::map<std::string, ::Ice::ObjectFactoryPtr> _factoryMap;
+ std::map<std::string, ::Ice::ObjectFactoryPtr>::iterator _factoryMapHint;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ObjectFactoryManagerF.h b/cpp/src/Ice/ObjectFactoryManagerF.h index c9d1bd79004..7f61f76cc2f 100644 --- a/cpp/src/Ice/ObjectFactoryManagerF.h +++ b/cpp/src/Ice/ObjectFactoryManagerF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SERVANT_FACTORY_MANAGER_F_H -#define ICE_SERVANT_FACTORY_MANAGER_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class ObjectFactoryManager; -void incRef(ObjectFactoryManager*); -void decRef(ObjectFactoryManager*); -typedef Handle<ObjectFactoryManager> ObjectFactoryManagerPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SERVANT_FACTORY_MANAGER_F_H
+#define ICE_SERVANT_FACTORY_MANAGER_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class ObjectFactoryManager;
+void incRef(ObjectFactoryManager*);
+void decRef(ObjectFactoryManager*);
+typedef Handle<ObjectFactoryManager> ObjectFactoryManagerPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 77304c9dd0d..58902503b48 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -44,7 +44,7 @@ IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const Reference _is(ref->instance), _os(ref->instance) { - switch (_reference->mode) + switch(_reference->mode) { case Reference::ModeTwoway: case Reference::ModeOneway: @@ -68,7 +68,7 @@ IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const Reference _os.write(nonmutating); _os.writeSize(Int(context.size())); Context::const_iterator p; - for (p = context.begin(); p != context.end(); ++p) + for(p = context.begin(); p != context.end(); ++p) { _os.write(p->first); _os.write(p->second); @@ -84,7 +84,7 @@ IceInternal::Outgoing::Outgoing(const ConnectionPtr& connection, const Reference IceInternal::Outgoing::~Outgoing() { - if (_state == StateUnsent && + if(_state == StateUnsent && (_reference->mode == Reference::ModeBatchOneway || _reference->mode == Reference::ModeBatchDatagram)) { _connection->abortBatchRequest(); @@ -96,7 +96,7 @@ IceInternal::Outgoing::invoke() { _os.endWriteEncaps(); - switch (_reference->mode) + switch(_reference->mode) { case Reference::ModeTwoway: { @@ -109,12 +109,12 @@ IceInternal::Outgoing::invoke() _state = StateInProgress; Int timeout = _connection->timeout(); - while (_state == StateInProgress) + while(_state == StateInProgress) { - if (timeout >= 0) + if(timeout >= 0) { timedWait(IceUtil::Time::milliSeconds(timeout)); - if (_state == StateInProgress) + if(_state == StateInProgress) { timedOut = true; _state = StateLocalException; @@ -128,7 +128,7 @@ IceInternal::Outgoing::invoke() } } - if (timedOut) + if(timedOut) { // // Must be called outside the synchronization of this @@ -137,7 +137,7 @@ IceInternal::Outgoing::invoke() _connection->exception(*_exception.get()); } - if (_exception.get()) + if(_exception.get()) { // // A CloseConnectionException indicates graceful @@ -160,12 +160,12 @@ IceInternal::Outgoing::invoke() throw NonRepeatable(*_exception.get()); } - if (_state == StateUserException) + if(_state == StateUserException) { return false; } - if (_state == StateLocationForward) + if(_state == StateLocationForward) { ObjectPrx p; _is.read(p); @@ -209,12 +209,12 @@ IceInternal::Outgoing::finished(BasicStream& is) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if (_state == StateInProgress) + if(_state == StateInProgress) { _is.swap(is); Byte status; _is.read(status); - switch (static_cast<DispatchStatus>(status)) + switch(static_cast<DispatchStatus>(status)) { case DispatchOK: { @@ -323,7 +323,7 @@ IceInternal::Outgoing::finished(const LocalException& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if (_state == StateInProgress) + if(_state == StateInProgress) { _state = StateLocalException; _exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex.ice_clone())); diff --git a/cpp/src/Ice/PicklerI.h b/cpp/src/Ice/PicklerI.h index cbe7358bae4..41d694dceb3 100644 --- a/cpp/src/Ice/PicklerI.h +++ b/cpp/src/Ice/PicklerI.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PICKLER_I_H -#define ICE_PICKLER_I_H - -#include <IceUtil/Shared.h> -#include <Ice/Pickler.h> -#include <Ice/InstanceF.h> - -namespace Ice -{ - -class ICE_API PicklerI : public Pickler -{ -public: - - void pickle(const ObjectPtr&, std::ostream&); - ObjectPtr unpickle(const std::string&, std::istream&); - -private: - - PicklerI(const ::IceInternal::InstancePtr&); - friend ::IceInternal::Instance; - - ::IceInternal::InstancePtr _instance; -}; - -} - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PICKLER_I_H
+#define ICE_PICKLER_I_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/Pickler.h>
+#include <Ice/InstanceF.h>
+
+namespace Ice
+{
+
+class ICE_API PicklerI : public Pickler
+{
+public:
+
+ void pickle(const ObjectPtr&, std::ostream&);
+ ObjectPtr unpickle(const std::string&, std::istream&);
+
+private:
+
+ PicklerI(const ::IceInternal::InstancePtr&);
+ friend ::IceInternal::Instance;
+
+ ::IceInternal::InstancePtr _instance;
+};
+
+}
+
+#endif
+
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp index f69c751fae4..c585dab36f1 100644 --- a/cpp/src/Ice/PluginManagerI.cpp +++ b/cpp/src/Ice/PluginManagerI.cpp @@ -33,7 +33,7 @@ Ice::PluginManagerI::getPlugin(const string& name) IceUtil::Mutex::Lock sync(*this); map<string, PluginInfo>::const_iterator r = _plugins.find(name); - if (r != _plugins.end()) + if(r != _plugins.end()) { return (*r).second.plugin; } @@ -46,7 +46,7 @@ Ice::PluginManagerI::addPlugin(const string& name, const PluginPtr& plugin) IceUtil::Mutex::Lock sync(*this); map<string, PluginInfo>::const_iterator r = _plugins.find(name); - if (r != _plugins.end()) + if(r != _plugins.end()) { throw PluginExistsException(__FILE__, __LINE__); } @@ -61,7 +61,7 @@ Ice::PluginManagerI::destroy() IceUtil::Mutex::Lock sync(*this); map<string, PluginInfo>::iterator r; - for (r = _plugins.begin(); r != _plugins.end(); ++r) + for(r = _plugins.begin(); r != _plugins.end(); ++r) { (*r).second.plugin->destroy(); (*r).second.plugin = 0; @@ -85,7 +85,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) PropertiesPtr properties = _instance->properties(); PropertyDict plugins = properties->getPropertiesForPrefix(prefix); PropertyDict::const_iterator p; - for (p = plugins.begin(); p != plugins.end(); ++p) + for(p = plugins.begin(); p != plugins.end(); ++p) { string name = p->first.substr(prefix.size()); const string& value = p->second; @@ -96,7 +96,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) string entryPoint; StringSeq args; string::size_type pos = value.find_first_of(" \t\n"); - if (pos == string::npos) + if(pos == string::npos) { entryPoint = value; } @@ -104,10 +104,10 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) { entryPoint = value.substr(0, pos); string::size_type beg = value.find_first_not_of(" \t\n", pos); - while (beg != string::npos) + while(beg != string::npos) { string::size_type end = value.find_first_of(" \t\n", beg); - if (end == string::npos) + if(end == string::npos) { args.push_back(value.substr(beg)); beg = end; @@ -143,12 +143,12 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& entryPoint, co PluginInfo info; info.library = new DynamicLibrary(); DynamicLibrary::symbol_type sym = info.library->loadEntryPoint(entryPoint); - if (sym == 0) + if(sym == 0) { ostringstream out; string msg = info.library->getErrorMessage(); out << "unable to load entry point `" << entryPoint << "'"; - if (!msg.empty()) + if(!msg.empty()) { out << ": " + msg; } diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h index 60663ffdc38..e668b6afc4d 100644 --- a/cpp/src/Ice/PluginManagerI.h +++ b/cpp/src/Ice/PluginManagerI.h @@ -1,55 +1,55 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PLUGIN_MANAGER_I_H -#define ICE_PLUGIN_MANAGER_I_H - -#include <Ice/Plugin.h> -#include <Ice/InstanceF.h> -#include <Ice/CommunicatorF.h> -#include <Ice/DynamicLibraryF.h> -#include <Ice/BuiltinSequences.h> -#include <IceUtil/Mutex.h> -#include <map> - -namespace Ice -{ - -class PluginManagerI : public PluginManager, public IceUtil::Mutex -{ -public: - - virtual PluginPtr getPlugin(const std::string&); - - virtual void addPlugin(const std::string&, const PluginPtr&); - - virtual void destroy(); - - struct PluginInfo - { - PluginPtr plugin; - IceInternal::DynamicLibraryPtr library; - }; - -private: - - PluginManagerI(const IceInternal::InstancePtr&); - void loadPlugins(int&, char*[]); - friend class IceInternal::Instance; - - void loadPlugin(const std::string&, const std::string&, const StringSeq&); - - IceInternal::InstancePtr _instance; - std::map<std::string, PluginInfo> _plugins; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PLUGIN_MANAGER_I_H
+#define ICE_PLUGIN_MANAGER_I_H
+
+#include <Ice/Plugin.h>
+#include <Ice/InstanceF.h>
+#include <Ice/CommunicatorF.h>
+#include <Ice/DynamicLibraryF.h>
+#include <Ice/BuiltinSequences.h>
+#include <IceUtil/Mutex.h>
+#include <map>
+
+namespace Ice
+{
+
+class PluginManagerI : public PluginManager, public IceUtil::Mutex
+{
+public:
+
+ virtual PluginPtr getPlugin(const std::string&);
+
+ virtual void addPlugin(const std::string&, const PluginPtr&);
+
+ virtual void destroy();
+
+ struct PluginInfo
+ {
+ PluginPtr plugin;
+ IceInternal::DynamicLibraryPtr library;
+ };
+
+private:
+
+ PluginManagerI(const IceInternal::InstancePtr&);
+ void loadPlugins(int&, char*[]);
+ friend class IceInternal::Instance;
+
+ void loadPlugin(const std::string&, const std::string&, const StringSeq&);
+
+ IceInternal::InstancePtr _instance;
+ std::map<std::string, PluginInfo> _plugins;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 0306455ce54..9a4f492eaeb 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -22,7 +22,7 @@ Ice::PropertiesI::getProperty(const string& key) IceUtil::Mutex::Lock sync(*this); map<string, string>::const_iterator p = _properties.find(key); - if (p != _properties.end()) + if(p != _properties.end()) { return p->second; } @@ -38,7 +38,7 @@ Ice::PropertiesI::getPropertyWithDefault(const string& key, const string& value) IceUtil::Mutex::Lock sync(*this); map<string, string>::const_iterator p = _properties.find(key); - if (p != _properties.end()) + if(p != _properties.end()) { return p->second; } @@ -60,7 +60,7 @@ Ice::PropertiesI::getPropertyAsIntWithDefault(const string& key, Int value) IceUtil::Mutex::Lock sync(*this); map<string, string>::const_iterator p = _properties.find(key); - if (p != _properties.end()) + if(p != _properties.end()) { return static_cast<Int>(atoi(p->second.c_str())); } @@ -77,9 +77,9 @@ Ice::PropertiesI::getPropertiesForPrefix(const string& prefix) PropertyDict result; map<string, string>::const_iterator p; - for (p = _properties.begin(); p != _properties.end(); ++p) + for(p = _properties.begin(); p != _properties.end(); ++p) { - if (prefix.empty() || p->first.compare(0, prefix.size(), prefix) == 0) + if(prefix.empty() || p->first.compare(0, prefix.size(), prefix) == 0) { result.insert(*p); } @@ -104,7 +104,7 @@ Ice::PropertiesI::getCommandLineOptions() StringSeq result; result.reserve(_properties.size()); map<string, string>::const_iterator p; - for (p = _properties.begin(); p != _properties.end(); ++p) + for(p = _properties.begin(); p != _properties.end(); ++p) { result.push_back("--" + p->first + "=" + p->second); } @@ -116,12 +116,12 @@ Ice::PropertiesI::parseCommandLineOptions(const string& prefix, const StringSeq& { StringSeq result; StringSeq::size_type i; - for (i = 0; i < options.size(); i++) + for(i = 0; i < options.size(); i++) { string opt = options[i]; - if (opt.find("--" + prefix + ".") == 0) + if(opt.find("--" + prefix + ".") == 0) { - if (opt.find('=') == string::npos) + if(opt.find('=') == string::npos) { opt += "=1"; } @@ -140,7 +140,7 @@ void Ice::PropertiesI::load(const std::string& file) { ifstream in(file.c_str()); - if (!in) + if(!in) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -148,7 +148,7 @@ Ice::PropertiesI::load(const std::string& file) } char line[1024]; - while (in.getline(line, 1024)) + while(in.getline(line, 1024)) { parseLine(line); } @@ -172,12 +172,12 @@ Ice::PropertiesI::PropertiesI() Ice::PropertiesI::PropertiesI(StringSeq& args) { StringSeq::iterator q = args.begin(); - while (q != args.end()) + while(q != args.end()) { string s = *q; - if (s.find("--Ice.Config") == 0) + if(s.find("--Ice.Config") == 0) { - if (s.find('=') == string::npos) + if(s.find('=') == string::npos) { s += "=1"; } @@ -195,17 +195,17 @@ Ice::PropertiesI::PropertiesI(StringSeq& args) Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strncmp(argv[i], "--Ice.Config", 12) == 0) + if(strncmp(argv[i], "--Ice.Config", 12) == 0) { string line = argv[i]; - if (line.find('=') == string::npos) + if(line.find('=') == string::npos) { line += "=1"; } parseLine(line.substr(2)); - for (int j = i; j + 1 < argc; ++j) + for(int j = i; j + 1 < argc; ++j) { argv[j] = argv[j + 1]; } @@ -215,10 +215,10 @@ Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) loadConfig(); - if (argc > 0) + if(argc > 0) { string name = getProperty("Ice.ProgramName"); - if (name.empty()) + if(name.empty()) { setProperty("Ice.ProgramName", argv[0]); } @@ -232,25 +232,25 @@ Ice::PropertiesI::parseLine(const string& line) string s = line; string::size_type idx = s.find('#'); - if (idx != string::npos) + if(idx != string::npos) { s.erase(idx); } idx = s.find_last_not_of(delim); - if (idx != string::npos && idx + 1 < s.length()) + if(idx != string::npos && idx + 1 < s.length()) { s.erase(idx + 1); } string::size_type beg = s.find_first_not_of(delim); - if (beg == string::npos) + if(beg == string::npos) { return; } string::size_type end = s.find_first_of(delim + "=", beg); - if (end == string::npos) + if(end == string::npos) { return; } @@ -258,7 +258,7 @@ Ice::PropertiesI::parseLine(const string& line) string key = s.substr(beg, end - beg); end = s.find('=', end); - if (end == string::npos) + if(end == string::npos) { return; } @@ -266,7 +266,7 @@ Ice::PropertiesI::parseLine(const string& line) string value; beg = s.find_first_not_of(delim, end); - if (beg != string::npos) + if(beg != string::npos) { end = s.length(); value = s.substr(beg, end - beg); @@ -280,24 +280,24 @@ Ice::PropertiesI::loadConfig() { string value = getProperty("Ice.Config"); - if (value.empty() || value == "1") + if(value.empty() || value == "1") { const char* s = getenv("ICE_CONFIG"); - if (s && *s != '\0') + if(s && *s != '\0') { value = s; } } - if (!value.empty()) + if(!value.empty()) { static const string delim = " \t\r\n"; string::size_type beg = value.find_first_not_of(delim); - while (beg != string::npos) + while(beg != string::npos) { string::size_type end = value.find(",", beg); string file; - if (end == string::npos) + if(end == string::npos) { file = value.substr(beg); beg = end; diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index da843b70611..954e3d37d75 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -1,54 +1,54 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROPERTIES_I_H -#define ICE_PROPERTIES_I_H - -#include <IceUtil/Mutex.h> -#include <Ice/Properties.h> -#include <set> - -namespace Ice -{ - -class ICE_API PropertiesI : public Properties, public IceUtil::Mutex -{ -public: - - virtual std::string getProperty(const std::string&); - virtual std::string getPropertyWithDefault(const std::string&, const std::string&); - virtual Ice::Int getPropertyAsInt(const std::string&); - virtual Ice::Int getPropertyAsIntWithDefault(const std::string&, Ice::Int); - virtual PropertyDict getPropertiesForPrefix(const std::string&); - virtual void setProperty(const std::string&, const std::string&); - virtual StringSeq getCommandLineOptions(); - virtual StringSeq parseCommandLineOptions(const std::string&, const StringSeq&); - virtual void load(const std::string&); - virtual PropertiesPtr clone(); - -private: - - PropertiesI(); - PropertiesI(StringSeq&); - PropertiesI(int&, char*[]); - friend ICE_API PropertiesPtr createProperties(); - friend ICE_API PropertiesPtr createProperties(StringSeq&); - friend ICE_API PropertiesPtr createProperties(int&, char*[]); - - void parseLine(const std::string&); - - void loadConfig(); - - std::map<std::string, std::string> _properties; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROPERTIES_I_H
+#define ICE_PROPERTIES_I_H
+
+#include <IceUtil/Mutex.h>
+#include <Ice/Properties.h>
+#include <set>
+
+namespace Ice
+{
+
+class ICE_API PropertiesI : public Properties, public IceUtil::Mutex
+{
+public:
+
+ virtual std::string getProperty(const std::string&);
+ virtual std::string getPropertyWithDefault(const std::string&, const std::string&);
+ virtual Ice::Int getPropertyAsInt(const std::string&);
+ virtual Ice::Int getPropertyAsIntWithDefault(const std::string&, Ice::Int);
+ virtual PropertyDict getPropertiesForPrefix(const std::string&);
+ virtual void setProperty(const std::string&, const std::string&);
+ virtual StringSeq getCommandLineOptions();
+ virtual StringSeq parseCommandLineOptions(const std::string&, const StringSeq&);
+ virtual void load(const std::string&);
+ virtual PropertiesPtr clone();
+
+private:
+
+ PropertiesI();
+ PropertiesI(StringSeq&);
+ PropertiesI(int&, char*[]);
+ friend ICE_API PropertiesPtr createProperties();
+ friend ICE_API PropertiesPtr createProperties(StringSeq&);
+ friend ICE_API PropertiesPtr createProperties(int&, char*[]);
+
+ void parseLine(const std::string&);
+
+ void loadConfig();
+
+ std::map<std::string, std::string> _properties;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Protocol.h b/cpp/src/Ice/Protocol.h index 4d9c879b3b6..e9bbdf3d185 100644 --- a/cpp/src/Ice/Protocol.h +++ b/cpp/src/Ice/Protocol.h @@ -1,48 +1,48 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROTOCOL_H -#define ICE_PROTOCOL_H - -#include <Ice/Config.h> - -namespace IceInternal -{ - -// -// Size of the Ice protocol header -// -// Protocol version (Byte) -// Encoding version (Byte) -// Message type (Byte) -// Message size (Int) -// -const ::Ice::Int headerSize = 7; - -// -// The current Ice protocol and encoding version -// -const ::Ice::Byte protocolVersion = 0; -const ::Ice::Byte encodingVersion = 0; - -// -// The Ice protocol message types -// -const ::Ice::Byte requestMsg = 0; -const ::Ice::Byte requestBatchMsg = 1; -const ::Ice::Byte replyMsg = 2; -const ::Ice::Byte closeConnectionMsg = 3; -const ::Ice::Byte compressedRequestMsg = 4; -const ::Ice::Byte compressedRequestBatchMsg = 5; -const ::Ice::Byte compressedReplyMsg = 6; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROTOCOL_H
+#define ICE_PROTOCOL_H
+
+#include <Ice/Config.h>
+
+namespace IceInternal
+{
+
+//
+// Size of the Ice protocol header
+//
+// Protocol version (Byte)
+// Encoding version (Byte)
+// Message type (Byte)
+// Message size (Int)
+//
+const ::Ice::Int headerSize = 7;
+
+//
+// The current Ice protocol and encoding version
+//
+const ::Ice::Byte protocolVersion = 0;
+const ::Ice::Byte encodingVersion = 0;
+
+//
+// The Ice protocol message types
+//
+const ::Ice::Byte requestMsg = 0;
+const ::Ice::Byte requestBatchMsg = 1;
+const ::Ice::Byte replyMsg = 2;
+const ::Ice::Byte closeConnectionMsg = 3;
+const ::Ice::Byte compressedRequestMsg = 4;
+const ::Ice::Byte compressedRequestBatchMsg = 5;
+const ::Ice::Byte compressedReplyMsg = 6;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 9828955df81..0adbf4d522e 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -47,9 +47,9 @@ void IceInternal::checkedCast(const ObjectPrx& b, const string& f, ObjectPrx& d) { d = 0; - if (b) + if(b) { - if (f == b->ice_getFacet()) + if(f == b->ice_getFacet()) { d = b; } @@ -77,7 +77,7 @@ void IceInternal::uncheckedCast(const ObjectPrx& b, const string& f, ObjectPrx& d) { d = 0; - if (b) + if(b) { d = b->ice_newFacet(f); } @@ -110,7 +110,7 @@ bool IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) { int __cnt = 0; - while (true) + while(true) { try { @@ -136,7 +136,7 @@ void IceProxy::Ice::Object::ice_ping(const Context& __context) { int __cnt = 0; - while (true) + while(true) { try { @@ -163,7 +163,7 @@ vector<string> IceProxy::Ice::Object::ice_ids(const Context& __context) { int __cnt = 0; - while (true) + while(true) { try { @@ -189,7 +189,7 @@ string IceProxy::Ice::Object::ice_id(const Context& __context) { int __cnt = 0; - while (true) + while(true) { try { @@ -215,7 +215,7 @@ vector<string> IceProxy::Ice::Object::ice_facets(const Context& __context) { int __cnt = 0; - while (true) + while(true) { try { @@ -245,7 +245,7 @@ IceProxy::Ice::Object::ice_invoke(const string& operation, const Context& context) { int __cnt = 0; - while (true) + while(true) { try { @@ -258,7 +258,7 @@ IceProxy::Ice::Object::ice_invoke(const string& operation, } catch (const NonRepeatable& __ex) { - if (nonmutating) + if(nonmutating) { __handleException(*__ex.get(), __cnt); } @@ -283,7 +283,7 @@ IceProxy::Ice::Object::ice_getIdentity() const ObjectPrx IceProxy::Ice::Object::ice_newIdentity(const Identity& newIdentity) const { - if (newIdentity == _reference->identity) + if(newIdentity == _reference->identity) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -304,7 +304,7 @@ IceProxy::Ice::Object::ice_getFacet() const ObjectPrx IceProxy::Ice::Object::ice_newFacet(const string& newFacet) const { - if (newFacet == _reference->facet) + if(newFacet == _reference->facet) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -320,7 +320,7 @@ ObjectPrx IceProxy::Ice::Object::ice_twoway() const { ReferencePtr ref = _reference->changeMode(Reference::ModeTwoway); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -336,7 +336,7 @@ ObjectPrx IceProxy::Ice::Object::ice_oneway() const { ReferencePtr ref = _reference->changeMode(Reference::ModeOneway); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -352,7 +352,7 @@ ObjectPrx IceProxy::Ice::Object::ice_batchOneway() const { ReferencePtr ref = _reference->changeMode(Reference::ModeBatchOneway); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -368,7 +368,7 @@ ObjectPrx IceProxy::Ice::Object::ice_datagram() const { ReferencePtr ref = _reference->changeMode(Reference::ModeDatagram); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -384,7 +384,7 @@ ObjectPrx IceProxy::Ice::Object::ice_batchDatagram() const { ReferencePtr ref = _reference->changeMode(Reference::ModeBatchDatagram); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -400,7 +400,7 @@ ObjectPrx IceProxy::Ice::Object::ice_secure(bool b) const { ReferencePtr ref = _reference->changeSecure(b); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -416,7 +416,7 @@ ObjectPrx IceProxy::Ice::Object::ice_compress(bool b) const { ReferencePtr ref = _reference->changeCompress(b); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -432,7 +432,7 @@ ObjectPrx IceProxy::Ice::Object::ice_timeout(int t) const { ReferencePtr ref = _reference->changeTimeout(t); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -448,7 +448,7 @@ ObjectPrx IceProxy::Ice::Object::ice_router(const RouterPrx& router) const { ReferencePtr ref = _reference->changeRouter(router); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -464,7 +464,7 @@ ObjectPrx IceProxy::Ice::Object::ice_default() const { ReferencePtr ref = _reference->changeDefault(); - if (ref == _reference) + if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } @@ -511,13 +511,13 @@ IceProxy::Ice::Object::__copyFrom(const ObjectPrx& from) _reference = ref; - if (delegateD) + if(delegateD) { Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD(); delegate->__copyFrom(delegateD); _delegate = delegate; } - else if (delegateM) + else if(delegateM) { Handle< ::IceDelegateM::Ice::Object> delegate = __createDelegateM(); delegate->__copyFrom(delegateM); @@ -564,7 +564,7 @@ IceProxy::Ice::Object::__handleException(const LocalException& ex, int& cnt) if(cnt > max) { - if (traceLevels->retry >= 1) + if(traceLevels->retry >= 1) { Trace out(logger, traceLevels->retryCat); out << "cannot retry operation call because retry limit has been exceeded\n" << ex; @@ -572,7 +572,7 @@ IceProxy::Ice::Object::__handleException(const LocalException& ex, int& cnt) ex.ice_throw(); } - if (traceLevels->retry >= 1) + if(traceLevels->retry >= 1) { Trace out(logger, traceLevels->retryCat); out << "re-trying operation call because of exception\n" << ex; @@ -591,7 +591,7 @@ IceProxy::Ice::Object::__locationForward(const LocationForward& ex) _delegate = 0; - if (_reference->identity != ex._prx->_reference->identity) + if(_reference->identity != ex._prx->_reference->identity) { throw LocationForwardIdentityException(__FILE__, __LINE__); } @@ -602,7 +602,7 @@ IceProxy::Ice::Object::__locationForward(const LocationForward& ex) TraceLevelsPtr traceLevels = _reference->instance->traceLevels(); LoggerPtr logger = _reference->instance->logger(); - if (traceLevels->locationForward >= 1) + if(traceLevels->locationForward >= 1) { Trace out(logger, traceLevels->retryCat); out << "location forward for object with identity `" << _reference.identity << "'"; @@ -625,10 +625,10 @@ IceProxy::Ice::Object::__getDelegate() { IceUtil::Mutex::Lock sync(*this); - if (!_delegate) + if(!_delegate) { ObjectAdapterPtr adapter = _reference->instance->objectAdapterFactory()->findObjectAdapter(this); - if (adapter) + if(adapter) { Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD(); delegate->setup(_reference, adapter); @@ -645,7 +645,7 @@ IceProxy::Ice::Object::__getDelegate() // using a router, then add this proxy to the router info // object. // - if (_reference->routerInfo) + if(_reference->routerInfo) { _reference->routerInfo->addProxy(this); } @@ -679,7 +679,7 @@ IceProxy::Ice::Object::setup(const ReferencePtr& ref) IceDelegateM::Ice::Object::~Object() { - if (__connection) + if(__connection) { __connection->decProxyUsageCount(); } @@ -693,7 +693,7 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context& __context) BasicStream* __is = __out.is(); BasicStream* __os = __out.os(); __os->write(__id); - if (!__out.invoke()) + if(!__out.invoke()) { throw ::Ice::UnknownUserException(__FILE__, __LINE__); } @@ -707,7 +707,7 @@ IceDelegateM::Ice::Object::ice_ping(const Context& __context) { static const string __operation("ice_ping"); Outgoing __out(__connection, __reference, __operation, true, __context); - if (!__out.invoke()) + if(!__out.invoke()) { throw ::Ice::UnknownUserException(__FILE__, __LINE__); } @@ -719,7 +719,7 @@ IceDelegateM::Ice::Object::ice_ids(const Context& __context) static const string __operation("ice_ids"); Outgoing __out(__connection, __reference, __operation, true, __context); BasicStream* __is = __out.is(); - if (!__out.invoke()) + if(!__out.invoke()) { throw ::Ice::UnknownUserException(__FILE__, __LINE__); } @@ -734,7 +734,7 @@ IceDelegateM::Ice::Object::ice_id(const Context& __context) static const string __operation("ice_id"); Outgoing __out(__connection, __reference, __operation, true, __context); BasicStream* __is = __out.is(); - if (!__out.invoke()) + if(!__out.invoke()) { throw ::Ice::UnknownUserException(__FILE__, __LINE__); } @@ -749,7 +749,7 @@ IceDelegateM::Ice::Object::ice_facets(const Context& __context) static const string __operation("ice_facets"); Outgoing __out(__connection, __reference, __operation, true, __context); BasicStream* __is = __out.is(); - if (!__out.invoke()) + if(!__out.invoke()) { throw ::Ice::UnknownUserException(__FILE__, __LINE__); } @@ -769,7 +769,7 @@ IceDelegateM::Ice::Object::ice_invoke(const string& operation, BasicStream* __os = __out.os(); __os->writeBlob(inParams); bool ok = __out.invoke(); - if (__reference->mode == Reference::ModeTwoway) + if(__reference->mode == Reference::ModeTwoway) { BasicStream* __is = __out.is(); Int sz = __is->getReadEncapsSize(); @@ -799,12 +799,12 @@ IceDelegateM::Ice::Object::__copyFrom(const ::IceInternal::Handle< ::IceDelegate __reference = from->__reference; - if (from->__connection) + if(from->__connection) { from->__connection->incProxyUsageCount(); } - if (__connection) + if(__connection) { __connection->decProxyUsageCount(); } @@ -821,7 +821,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) // __reference = ref; - if (__reference->reverseAdapter) + if(__reference->reverseAdapter) { // // If we have a reverse object adapter, we use the incoming @@ -837,15 +837,15 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) ::Ice::constMemFun(&Connection::endpoint)); endpoints = filterEndpoints(endpoints); - if (endpoints.empty()) + if(endpoints.empty()) { throw NoEndpointException(__FILE__, __LINE__); } list<ConnectionPtr>::iterator p; - for (p = connections.begin(); p != connections.end(); ++p) + for(p = connections.begin(); p != connections.end(); ++p) { - if ((*p)->endpoint() == endpoints.front()) + if((*p)->endpoint() == endpoints.front()) { break; } @@ -857,7 +857,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) else { vector<EndpointPtr> endpoints; - if (__reference->routerInfo) + if(__reference->routerInfo) { // // If we route, we send everything to the router's client @@ -871,7 +871,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) endpoints = filterEndpoints(__reference->endpoints); } - if (endpoints.empty()) + if(endpoints.empty()) { throw NoEndpointException(__FILE__, __LINE__); } @@ -886,7 +886,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& ref) // (if any) to the new connection, so that callbacks from the // router can be received over this new connection. // - if (__reference->routerInfo) + if(__reference->routerInfo) { __connection->setAdapter(__reference->routerInfo->getAdapter()); } @@ -904,7 +904,7 @@ IceDelegateM::Ice::Object::filterEndpoints(const vector<EndpointPtr>& allEndpoin endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), ::Ice::constMemFun(&Endpoint::unknown)), endpoints.end()); - switch (__reference->mode) + switch(__reference->mode) { case Reference::ModeTwoway: case Reference::ModeOneway: @@ -942,7 +942,7 @@ IceDelegateM::Ice::Object::filterEndpoints(const vector<EndpointPtr>& allEndpoin // secure endpoints by partitioning the endpoint vector, so that // non-secure endpoints come first. // - if (__reference->secure) + if(__reference->secure) { endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(::Ice::constMemFun(&Endpoint::secure))), endpoints.end()); @@ -960,7 +960,7 @@ IceDelegateD::Ice::Object::ice_isA(const string& __id, const Context& __context) { Current __current; __initCurrent(__current, "ice_isA", true, __context); - while (true) + while(true) { Direct __direct(__adapter, __current); try @@ -987,7 +987,7 @@ IceDelegateD::Ice::Object::ice_ping(const ::Ice::Context& __context) { Current __current; __initCurrent(__current, "ice_ping", true, __context); - while (true) + while(true) { Direct __direct(__adapter, __current); try @@ -1015,7 +1015,7 @@ IceDelegateD::Ice::Object::ice_ids(const ::Ice::Context& __context) { Current __current; __initCurrent(__current, "ice_ids", true, __context); - while (true) + while(true) { Direct __direct(__adapter, __current); try @@ -1042,7 +1042,7 @@ IceDelegateD::Ice::Object::ice_id(const ::Ice::Context& __context) { Current __current; __initCurrent(__current, "ice_id", true, __context); - while (true) + while(true) { Direct __direct(__adapter, __current); try @@ -1069,7 +1069,7 @@ IceDelegateD::Ice::Object::ice_facets(const ::Ice::Context& __context) { Current __current; __initCurrent(__current, "ice_facets", true, __context); - while (true) + while(true) { Direct __direct(__adapter, __current); try @@ -1100,11 +1100,11 @@ IceDelegateD::Ice::Object::ice_invoke(const string& operation, { Current current; __initCurrent(current, operation, nonmutating, context); - while (true) + while(true) { Direct __direct(__adapter, current); Blobject* __servant = dynamic_cast<Blobject*>(__direct.facetServant().get()); - if (!__servant) + if(!__servant) { OperationNotExistException ex(__FILE__, __LINE__); ex.operation = current.operation; diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index a718fa78b3e..e51b56c8a58 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -24,7 +24,7 @@ void IceInternal::decRef(ProxyFactory* p) { p->__decRef(); } ObjectPrx IceInternal::ProxyFactory::stringToProxy(const string& str) const { - if (str.empty()) + if(str.empty()) { return 0; } @@ -39,7 +39,7 @@ string IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) const { static const string nilProxy(""); - if (proxy) + if(proxy) { return proxy->__reference()->toString(); } @@ -55,7 +55,7 @@ IceInternal::ProxyFactory::streamToProxy(BasicStream* s) const Identity ident; ident.__read(s); - if (ident.name.empty()) + if(ident.name.empty()) { return 0; } @@ -69,7 +69,7 @@ IceInternal::ProxyFactory::streamToProxy(BasicStream* s) const void IceInternal::ProxyFactory::proxyToStream(const ObjectPrx& proxy, BasicStream* s) const { - if (proxy) + if(proxy) { proxy->__reference()->identity.__write(s); proxy->__reference()->streamWrite(s); diff --git a/cpp/src/Ice/ProxyFactory.h b/cpp/src/Ice/ProxyFactory.h index 1154d5e767a..0eb5eaef0fe 100644 --- a/cpp/src/Ice/ProxyFactory.h +++ b/cpp/src/Ice/ProxyFactory.h @@ -1,49 +1,49 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PROXY_FACTORY_H -#define ICE_PROXY_FACTORY_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/ProxyFactoryF.h> -#include <Ice/InstanceF.h> -#include <Ice/ReferenceF.h> -#include <Ice/ProxyF.h> - -namespace IceInternal -{ - -class BasicStream; - -class ProxyFactory : public ::IceUtil::Shared -{ -public: - - ::Ice::ObjectPrx stringToProxy(const std::string&) const; - std::string proxyToString(const ::Ice::ObjectPrx&) const; - - ::Ice::ObjectPrx streamToProxy(BasicStream*) const; - void proxyToStream(const ::Ice::ObjectPrx&, BasicStream*) const; - - ::Ice::ObjectPrx referenceToProxy(const ReferencePtr&) const; - -private: - - ProxyFactory(const InstancePtr&); - virtual ~ProxyFactory(); - friend class Instance; - - InstancePtr _instance; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PROXY_FACTORY_H
+#define ICE_PROXY_FACTORY_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/ProxyFactoryF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/ReferenceF.h>
+#include <Ice/ProxyF.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+class ProxyFactory : public ::IceUtil::Shared
+{
+public:
+
+ ::Ice::ObjectPrx stringToProxy(const std::string&) const;
+ std::string proxyToString(const ::Ice::ObjectPrx&) const;
+
+ ::Ice::ObjectPrx streamToProxy(BasicStream*) const;
+ void proxyToStream(const ::Ice::ObjectPrx&, BasicStream*) const;
+
+ ::Ice::ObjectPrx referenceToProxy(const ReferencePtr&) const;
+
+private:
+
+ ProxyFactory(const InstancePtr&);
+ virtual ~ProxyFactory();
+ friend class Instance;
+
+ InstancePtr _instance;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index 5d454d063c0..4174baad0be 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -28,52 +28,52 @@ void IceInternal::decRef(::IceInternal::Reference* p) { p->__decRef(); } bool IceInternal::Reference::operator==(const Reference& r) const { - if (this == &r) + if(this == &r) { return true; } - if (identity != r.identity) + if(identity != r.identity) { return false; } - if (facet != r.facet) + if(facet != r.facet) { return false; } - if (mode != r.mode) + if(mode != r.mode) { return false; } - if (secure != r.secure) + if(secure != r.secure) { return false; } - if (compress != r.compress) + if(compress != r.compress) { return false; } - if (origEndpoints != r.origEndpoints) + if(origEndpoints != r.origEndpoints) { return false; } - if (endpoints != r.endpoints) + if(endpoints != r.endpoints) { return false; } - if (routerInfo != r.routerInfo) + if(routerInfo != r.routerInfo) { return false; } - if (reverseAdapter != r.reverseAdapter) + if(reverseAdapter != r.reverseAdapter) { return false; } @@ -90,88 +90,88 @@ IceInternal::Reference::operator!=(const Reference& r) const bool IceInternal::Reference::operator<(const Reference& r) const { - if (this == &r) + if(this == &r) { return false; } - if (identity < r.identity) + if(identity < r.identity) { return true; } - else if (r.identity < identity) + else if(r.identity < identity) { return false; } - if (facet < r.facet) + if(facet < r.facet) { return true; } - else if (r.facet < facet) + else if(r.facet < facet) { return false; } - if (mode < r.mode) + if(mode < r.mode) { return true; } - else if (r.mode < mode) + else if(r.mode < mode) { return false; } - if (!secure && r.secure) + if(!secure && r.secure) { return true; } - else if (r.secure < secure) + else if(r.secure < secure) { return false; } - if (!compress && r.compress) + if(!compress && r.compress) { return true; } - else if (r.compress < compress) + else if(r.compress < compress) { return false; } - if (origEndpoints < r.origEndpoints) + if(origEndpoints < r.origEndpoints) { return true; } - else if (r.origEndpoints < origEndpoints) + else if(r.origEndpoints < origEndpoints) { return false; } - if (endpoints < r.endpoints) + if(endpoints < r.endpoints) { return true; } - else if (r.endpoints < endpoints) + else if(r.endpoints < endpoints) { return false; } - if (routerInfo < r.routerInfo) + if(routerInfo < r.routerInfo) { return true; } - else if (r.routerInfo < routerInfo) + else if(r.routerInfo < routerInfo) { return false; } - if (reverseAdapter < r.reverseAdapter) + if(reverseAdapter < r.reverseAdapter) { return true; } - else if (r.reverseAdapter < reverseAdapter) + else if(r.reverseAdapter < reverseAdapter) { return false; } @@ -198,12 +198,12 @@ IceInternal::Reference::streamWrite(BasicStream* s) const vector<EndpointPtr>::const_iterator p; s->writeSize(Ice::Int(origEndpoints.size())); - for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) + for(p = origEndpoints.begin(); p != origEndpoints.end(); ++p) { (*p)->streamWrite(s); } - if (endpoints == origEndpoints) + if(endpoints == origEndpoints) { s->write(true); } @@ -211,7 +211,7 @@ IceInternal::Reference::streamWrite(BasicStream* s) const { s->write(false); s->writeSize(Ice::Int(endpoints.size())); - for (p = endpoints.begin(); p != endpoints.end(); ++p) + for(p = endpoints.begin(); p != endpoints.end(); ++p) { (*p)->streamWrite(s); } @@ -225,12 +225,12 @@ IceInternal::Reference::toString() const s << identity; - if (!facet.empty()) + if(!facet.empty()) { s << " -f " << facet; } - switch (mode) + switch(mode) { case ModeTwoway: { @@ -263,27 +263,27 @@ IceInternal::Reference::toString() const } } - if (secure) + if(secure) { s << " -s"; } - if (compress) + if(compress) { s << " -s"; } vector<EndpointPtr>::const_iterator p; - for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) + for(p = origEndpoints.begin(); p != origEndpoints.end(); ++p) { s << ':' << (*p)->toString(); } - if (endpoints != origEndpoints) + if(endpoints != origEndpoints) { s << ':'; - for (p = endpoints.begin(); p != endpoints.end(); ++p) + for(p = endpoints.begin(); p != endpoints.end(); ++p) { s << ':' << (*p)->toString(); } @@ -295,7 +295,7 @@ IceInternal::Reference::toString() const ReferencePtr IceInternal::Reference::changeIdentity(const Identity& newIdentity) const { - if (newIdentity == identity) + if(newIdentity == identity) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -310,7 +310,7 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const ReferencePtr IceInternal::Reference::changeFacet(const string& newFacet) const { - if (newFacet == facet) + if(newFacet == facet) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -331,13 +331,13 @@ IceInternal::Reference::changeTimeout(int timeout) const vector<EndpointPtr>::const_iterator p; vector<EndpointPtr> newOrigEndpoints; - for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) + for(p = origEndpoints.begin(); p != origEndpoints.end(); ++p) { newOrigEndpoints.push_back((*p)->timeout(timeout)); } vector<EndpointPtr> newEndpoints; - for (p = endpoints.begin(); p != endpoints.end(); ++p) + for(p = endpoints.begin(); p != endpoints.end(); ++p) { newEndpoints.push_back((*p)->timeout(timeout)); } @@ -347,7 +347,7 @@ IceInternal::Reference::changeTimeout(int timeout) const // router and the router's client proxy. // RouterInfoPtr newRouterInfo; - if (routerInfo) + if(routerInfo) { try { @@ -370,7 +370,7 @@ IceInternal::Reference::changeTimeout(int timeout) const ReferencePtr IceInternal::Reference::changeMode(Mode newMode) const { - if (newMode == mode) + if(newMode == mode) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -385,7 +385,7 @@ IceInternal::Reference::changeMode(Mode newMode) const ReferencePtr IceInternal::Reference::changeSecure(bool newSecure) const { - if (newSecure == secure) + if(newSecure == secure) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -400,7 +400,7 @@ IceInternal::Reference::changeSecure(bool newSecure) const ReferencePtr IceInternal::Reference::changeCompress(bool newCompress) const { - if (newCompress == compress) + if(newCompress == compress) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -415,7 +415,7 @@ IceInternal::Reference::changeCompress(bool newCompress) const ReferencePtr IceInternal::Reference::changeEndpoints(const vector<EndpointPtr>& newEndpoints) const { - if (newEndpoints == endpoints) + if(newEndpoints == endpoints) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -432,7 +432,7 @@ IceInternal::Reference::changeRouter(const RouterPrx& newRouter) const { RouterInfoPtr newRouterInfo = instance->routerManager()->get(newRouter); - if (newRouterInfo == routerInfo) + if(newRouterInfo == routerInfo) { return ReferencePtr(const_cast<Reference*>(this)); } @@ -478,17 +478,17 @@ IceInternal::Reference::Reference(const InstancePtr& inst, string::const_iterator p; - for (p = identity.name.begin(); p != identity.name.end(); ++p) + for(p = identity.name.begin(); p != identity.name.end(); ++p) { h = 5 * h + *p; } - for (p = identity.category.begin(); p != identity.category.end(); ++p) + for(p = identity.category.begin(); p != identity.category.end(); ++p) { h = 5 * h + *p; } - for (p = facet.begin(); p != facet.end(); ++p) + for(p = facet.begin(); p != facet.end(); ++p) { h = 5 * h + *p; } diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 1c64e87c3d2..88a1bde88a5 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -1,96 +1,96 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_REFERENCE_H -#define ICE_REFERENCE_H - -#include <IceUtil/Shared.h> -#include <Ice/ReferenceF.h> -#include <Ice/ReferenceFactoryF.h> -#include <Ice/EndpointF.h> -#include <Ice/InstanceF.h> -#include <Ice/RouterF.h> -#include <Ice/RouterInfoF.h> -#include <Ice/ObjectAdapterF.h> -#include <Ice/Identity.h> - -namespace IceInternal -{ - -class BasicStream; - -class Reference : public ::IceUtil::Shared -{ -public: - - enum Mode - { - ModeTwoway, - ModeOneway, - ModeBatchOneway, - ModeDatagram, - ModeBatchDatagram, - ModeLast = ModeBatchDatagram - }; - - bool operator==(const Reference&) const; - bool operator!=(const Reference&) const; - bool operator<(const Reference&) const; - - // - // Marshal the reference - // - void streamWrite(BasicStream*) const; - - // - // Convert the reference to its string form - // - std::string toString() const; - - // - // All members are const, because References are immutable. - // - const InstancePtr instance; - const Ice::Identity identity; - const std::string facet; - const Mode mode; - const bool secure; - const bool compress; - const std::vector<EndpointPtr> origEndpoints; // Original endpoints. - const std::vector<EndpointPtr> endpoints; // Actual endpoints, changed by a location forwards. - const RouterInfoPtr routerInfo; // Null if no router is used. - const Ice::ObjectAdapterPtr reverseAdapter; // For reverse communications using the adapter's incoming connections. - const Ice::Int hashValue; - - // - // Get a new reference, based on the existing one, overwriting - // certain values. - // - ReferencePtr changeIdentity(const Ice::Identity&) const; - ReferencePtr changeFacet(const std::string&) const; - ReferencePtr changeTimeout(int) const; - ReferencePtr changeMode(Mode) const; - ReferencePtr changeSecure(bool) const; - ReferencePtr changeCompress(bool) const; - ReferencePtr changeEndpoints(const std::vector<EndpointPtr>&) const; - ReferencePtr changeRouter(const ::Ice::RouterPrx&) const; - ReferencePtr changeDefault() const; - -private: - - Reference(const InstancePtr&, const Ice::Identity&, const std::string&, Mode, bool, bool, - const std::vector<EndpointPtr>&, const std::vector<EndpointPtr>&, - const RouterInfoPtr&, const Ice::ObjectAdapterPtr&); - friend class ReferenceFactory; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_REFERENCE_H
+#define ICE_REFERENCE_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/ReferenceF.h>
+#include <Ice/ReferenceFactoryF.h>
+#include <Ice/EndpointF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/RouterF.h>
+#include <Ice/RouterInfoF.h>
+#include <Ice/ObjectAdapterF.h>
+#include <Ice/Identity.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+class Reference : public ::IceUtil::Shared
+{
+public:
+
+ enum Mode
+ {
+ ModeTwoway,
+ ModeOneway,
+ ModeBatchOneway,
+ ModeDatagram,
+ ModeBatchDatagram,
+ ModeLast = ModeBatchDatagram
+ };
+
+ bool operator==(const Reference&) const;
+ bool operator!=(const Reference&) const;
+ bool operator<(const Reference&) const;
+
+ //
+ // Marshal the reference
+ //
+ void streamWrite(BasicStream*) const;
+
+ //
+ // Convert the reference to its string form
+ //
+ std::string toString() const;
+
+ //
+ // All members are const, because References are immutable.
+ //
+ const InstancePtr instance;
+ const Ice::Identity identity;
+ const std::string facet;
+ const Mode mode;
+ const bool secure;
+ const bool compress;
+ const std::vector<EndpointPtr> origEndpoints; // Original endpoints.
+ const std::vector<EndpointPtr> endpoints; // Actual endpoints, changed by a location forwards.
+ const RouterInfoPtr routerInfo; // Null if no router is used.
+ const Ice::ObjectAdapterPtr reverseAdapter; // For reverse communications using the adapter's incoming connections.
+ const Ice::Int hashValue;
+
+ //
+ // Get a new reference, based on the existing one, overwriting
+ // certain values.
+ //
+ ReferencePtr changeIdentity(const Ice::Identity&) const;
+ ReferencePtr changeFacet(const std::string&) const;
+ ReferencePtr changeTimeout(int) const;
+ ReferencePtr changeMode(Mode) const;
+ ReferencePtr changeSecure(bool) const;
+ ReferencePtr changeCompress(bool) const;
+ ReferencePtr changeEndpoints(const std::vector<EndpointPtr>&) const;
+ ReferencePtr changeRouter(const ::Ice::RouterPrx&) const;
+ ReferencePtr changeDefault() const;
+
+private:
+
+ Reference(const InstancePtr&, const Ice::Identity&, const std::string&, Mode, bool, bool,
+ const std::vector<EndpointPtr>&, const std::vector<EndpointPtr>&,
+ const RouterInfoPtr&, const Ice::ObjectAdapterPtr&);
+ friend class ReferenceFactory;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index e3d157ab2e4..aff3f9193b8 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -37,7 +37,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, { Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } @@ -56,20 +56,20 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // set<ReferencePtr>::iterator p = _references.end(); - if (_referencesHint != _references.end()) + if(_referencesHint != _references.end()) { - if (*_referencesHint == ref) + if(*_referencesHint == ref) { p = _referencesHint; } } - if (p == _references.end()) + if(p == _references.end()) { p = _references.find(ref); } - if (p == _references.end()) + if(p == _references.end()) { _referencesHint = _references.insert(_referencesHint, ref); } @@ -82,13 +82,13 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // At every 10th call, evict references which are not in use anymore. // - if (++_evict >= 10) + if(++_evict >= 10) { _evict = 0; p = _references.begin(); - while (p != _references.end()) + while(p != _references.end()) { - if ((*p)->__getRef() == 1) + if((*p)->__getRef() == 1) { assert(p != _referencesHint); _references.erase(p++); @@ -113,18 +113,18 @@ IceInternal::ReferenceFactory::create(const string& str) string::size_type end = 0; beg = s.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { throw ProxyParseException(__FILE__, __LINE__); } end = s.find_first_of(delim + ":", beg); - if (end == string::npos) + if(end == string::npos) { end = s.length(); } - if (beg == end) + if(beg == end) { throw ProxyParseException(__FILE__, __LINE__); } @@ -135,43 +135,43 @@ IceInternal::ReferenceFactory::create(const string& str) bool secure = false; bool compress = false; - while (true) + while(true) { beg = s.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } - if (s[beg] == ':') + if(s[beg] == ':') { break; } end = s.find_first_of(delim + ":", beg); - if (end == string::npos) + if(end == string::npos) { end = s.length(); } - if (beg == end) + if(beg == end) { break; } string option = s.substr(beg, end - beg); - if (option.length() != 2 || option[0] != '-') + if(option.length() != 2 || option[0] != '-') { throw ProxyParseException(__FILE__, __LINE__); } string argument; string::size_type argumentBeg = str.find_first_not_of(delim, end); - if (argumentBeg != string::npos && str[argumentBeg] != '-') + if(argumentBeg != string::npos && str[argumentBeg] != '-') { beg = argumentBeg; end = str.find_first_of(delim + ":", beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } @@ -182,11 +182,11 @@ IceInternal::ReferenceFactory::create(const string& str) // If any new options are added here, // IceInternal::Reference::toString() must be updated as well. // - switch (option[1]) + switch(option[1]) { case 'f': { - if (argument.empty()) + if(argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -196,7 +196,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 't': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -206,7 +206,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 'o': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -216,7 +216,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 'O': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -226,7 +226,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 'd': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -236,7 +236,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 'D': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -246,7 +246,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 's': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -256,7 +256,7 @@ IceInternal::ReferenceFactory::create(const string& str) case 'c': { - if (!argument.empty()) + if(!argument.empty()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -275,19 +275,19 @@ IceInternal::ReferenceFactory::create(const string& str) vector<EndpointPtr> endpoints; bool orig = true; - while (end < s.length() && s[end] == ':') + while(end < s.length() && s[end] == ':') { beg = end + 1; end = s.find(':', beg); - if (end == string::npos) + if(end == string::npos) { end = s.length(); } - if (beg == end) // "::" + if(beg == end) // "::" { - if (!orig) + if(!orig) { throw ProxyParseException(__FILE__, __LINE__); } @@ -299,7 +299,7 @@ IceInternal::ReferenceFactory::create(const string& str) string es = s.substr(beg, end - beg); EndpointPtr endp = _instance->endpointFactoryManager()->create(es); - if (orig) + if(orig) { origEndpoints.push_back(endp); } @@ -309,12 +309,12 @@ IceInternal::ReferenceFactory::create(const string& str) } } - if (orig) + if(orig) { endpoints = origEndpoints; } - if (!origEndpoints.size() || !endpoints.size()) + if(!origEndpoints.size() || !endpoints.size()) { throw ProxyParseException(__FILE__, __LINE__); } @@ -337,7 +337,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) Byte modeAsByte; s->read(modeAsByte); Reference::Mode mode = static_cast<Reference::Mode>(modeAsByte); - if (mode < 0 || mode > Reference::ModeLast) + if(mode < 0 || mode > Reference::ModeLast) { throw ProxyUnmarshalException(__FILE__, __LINE__); } @@ -354,7 +354,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) Ice::Int sz; s->readSize(sz); origEndpoints.reserve(sz); - while (sz--) + while(sz--) { EndpointPtr endpoint = _instance->endpointFactoryManager()->read(s); origEndpoints.push_back(endpoint); @@ -362,7 +362,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) bool same; s->read(same); - if (same) // origEndpoints == endpoints + if(same) // origEndpoints == endpoints { endpoints = origEndpoints; } @@ -370,7 +370,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) { s->readSize(sz); endpoints.reserve(sz); - while (sz--) + while(sz--) { EndpointPtr endpoint = _instance->endpointFactoryManager()->read(s); endpoints.push_back(endpoint); @@ -407,7 +407,7 @@ IceInternal::ReferenceFactory::destroy() { Mutex::Lock sync(*this); - if (!_instance) + if(!_instance) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h index cd7bd723c26..84bd3bd17d1 100644 --- a/cpp/src/Ice/ReferenceFactory.h +++ b/cpp/src/Ice/ReferenceFactory.h @@ -1,51 +1,51 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_REFERENCE_FACTORY_H -#define ICE_REFERENCE_FACTORY_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/ReferenceFactoryF.h> -#include <Ice/Reference.h> // For Reference::Mode -#include <set> - -namespace IceInternal -{ - -class ReferenceFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - ReferencePtr create(const Ice::Identity&, const std::string&, Reference::Mode, bool, bool, - const std::vector<EndpointPtr>&, const std::vector<EndpointPtr>&, - const RouterInfoPtr&, const Ice::ObjectAdapterPtr&); - ReferencePtr create(const std::string&); - ReferencePtr create(const Ice::Identity&, BasicStream*); - - void setDefaultRouter(const ::Ice::RouterPrx&); - Ice::RouterPrx getDefaultRouter() const; - -private: - - ReferenceFactory(const InstancePtr&); - void destroy(); - friend class Instance; - - InstancePtr _instance; - Ice::RouterPrx _defaultRouter; - std::set<ReferencePtr> _references; - std::set<ReferencePtr>::iterator _referencesHint; - int _evict; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_REFERENCE_FACTORY_H
+#define ICE_REFERENCE_FACTORY_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/ReferenceFactoryF.h>
+#include <Ice/Reference.h> // For Reference::Mode
+#include <set>
+
+namespace IceInternal
+{
+
+class ReferenceFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ ReferencePtr create(const Ice::Identity&, const std::string&, Reference::Mode, bool, bool,
+ const std::vector<EndpointPtr>&, const std::vector<EndpointPtr>&,
+ const RouterInfoPtr&, const Ice::ObjectAdapterPtr&);
+ ReferencePtr create(const std::string&);
+ ReferencePtr create(const Ice::Identity&, BasicStream*);
+
+ void setDefaultRouter(const ::Ice::RouterPrx&);
+ Ice::RouterPrx getDefaultRouter() const;
+
+private:
+
+ ReferenceFactory(const InstancePtr&);
+ void destroy();
+ friend class Instance;
+
+ InstancePtr _instance;
+ Ice::RouterPrx _defaultRouter;
+ std::set<ReferencePtr> _references;
+ std::set<ReferencePtr>::iterator _referencesHint;
+ int _evict;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ReferenceFactoryF.h b/cpp/src/Ice/ReferenceFactoryF.h index ffeaebc5a68..840723ceb94 100644 --- a/cpp/src/Ice/ReferenceFactoryF.h +++ b/cpp/src/Ice/ReferenceFactoryF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_REFERENCE_FACTORY_F_H -#define ICE_REFERENCE_FACTORY_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class ReferenceFactory; -void incRef(ReferenceFactory*); -void decRef(ReferenceFactory*); -typedef Handle<ReferenceFactory> ReferenceFactoryPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_REFERENCE_FACTORY_F_H
+#define ICE_REFERENCE_FACTORY_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class ReferenceFactory;
+void incRef(ReferenceFactory*);
+void decRef(ReferenceFactory*);
+typedef Handle<ReferenceFactory> ReferenceFactoryPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp index 736737f8806..412032f4dc9 100644 --- a/cpp/src/Ice/RouterInfo.cpp +++ b/cpp/src/Ice/RouterInfo.cpp @@ -40,7 +40,7 @@ IceInternal::RouterManager::destroy() RouterInfoPtr IceInternal::RouterManager::get(const RouterPrx& rtr) { - if (!rtr) + if(!rtr) { return 0; } @@ -51,20 +51,20 @@ IceInternal::RouterManager::get(const RouterPrx& rtr) map<RouterPrx, RouterInfoPtr>::iterator p = _table.end(); - if (_tableHint != _table.end()) + if(_tableHint != _table.end()) { - if (_tableHint->first == router) + if(_tableHint->first == router) { p = _tableHint; } } - if (p == _table.end()) + if(p == _table.end()) { p = _table.find(router); } - if (p == _table.end()) + if(p == _table.end()) { _tableHint = _table.insert(_tableHint, make_pair(router, new RouterInfo(router))); } @@ -115,10 +115,10 @@ IceInternal::RouterInfo::getClientProxy() { IceUtil::Mutex::Lock sync(*this); - if (!_clientProxy) // Lazy initialization. + if(!_clientProxy) // Lazy initialization. { _clientProxy = _router->getClientProxy(); - if (!_clientProxy) + if(!_clientProxy) { throw NoEndpointException(__FILE__, __LINE__); } @@ -140,10 +140,10 @@ IceInternal::RouterInfo::getServerProxy() { IceUtil::Mutex::Lock sync(*this); - if (!_serverProxy) // Lazy initialization. + if(!_serverProxy) // Lazy initialization. { _serverProxy = _router->getServerProxy(); - if (!_serverProxy) + if(!_serverProxy) { throw NoEndpointException(__FILE__, __LINE__); } @@ -167,7 +167,7 @@ IceInternal::RouterInfo::addProxy(const ObjectPrx& proxy) // No mutex lock necessary, _routingTable is immutable, and // RoutingTable is mutex protected. // - if (_routingTable->add(proxy)) // Only add the proxy to the router if it's not already in the routing table. + if(_routingTable->add(proxy)) // Only add the proxy to the router if it's not already in the routing table. { _router->addProxy(proxy); } diff --git a/cpp/src/Ice/RouterInfo.h b/cpp/src/Ice/RouterInfo.h index 15fa489175e..b7d3791bea9 100644 --- a/cpp/src/Ice/RouterInfo.h +++ b/cpp/src/Ice/RouterInfo.h @@ -1,74 +1,74 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ROUTER_INFO_H -#define ICE_ROUTER_INFO_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/RouterInfoF.h> -#include <Ice/RouterF.h> -#include <Ice/ProxyF.h> -#include <Ice/RoutingTableF.h> - -namespace IceInternal -{ - -class RouterManager : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - RouterManager(); - - void destroy(); - - // - // Returns router info for a given router. Automatically creates - // the router info if it doesn't exist yet. - // - RouterInfoPtr get(const ::Ice::RouterPrx&); - -private: - - std::map< ::Ice::RouterPrx, RouterInfoPtr> _table; - std::map< ::Ice::RouterPrx, RouterInfoPtr>::iterator _tableHint; -}; - -class RouterInfo : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - RouterInfo(const ::Ice::RouterPrx&); - - bool operator==(const RouterInfo&) const; - bool operator!=(const RouterInfo&) const; - bool operator<(const RouterInfo&) const; - - ::Ice::RouterPrx getRouter(); - ::Ice::ObjectPrx getClientProxy(); - void setClientProxy(const ::Ice::ObjectPrx&); - ::Ice::ObjectPrx getServerProxy(); - void setServerProxy(const ::Ice::ObjectPrx&); - void addProxy(const ::Ice::ObjectPrx&); - void setAdapter(const ::Ice::ObjectAdapterPtr&); - ::Ice::ObjectAdapterPtr getAdapter(); - -private: - - ::Ice::RouterPrx _router; - ::Ice::ObjectPrx _clientProxy; - ::Ice::ObjectPrx _serverProxy; - RoutingTablePtr _routingTable; - ::Ice::ObjectAdapterPtr _adapter; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ROUTER_INFO_H
+#define ICE_ROUTER_INFO_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/RouterInfoF.h>
+#include <Ice/RouterF.h>
+#include <Ice/ProxyF.h>
+#include <Ice/RoutingTableF.h>
+
+namespace IceInternal
+{
+
+class RouterManager : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ RouterManager();
+
+ void destroy();
+
+ //
+ // Returns router info for a given router. Automatically creates
+ // the router info if it doesn't exist yet.
+ //
+ RouterInfoPtr get(const ::Ice::RouterPrx&);
+
+private:
+
+ std::map< ::Ice::RouterPrx, RouterInfoPtr> _table;
+ std::map< ::Ice::RouterPrx, RouterInfoPtr>::iterator _tableHint;
+};
+
+class RouterInfo : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ RouterInfo(const ::Ice::RouterPrx&);
+
+ bool operator==(const RouterInfo&) const;
+ bool operator!=(const RouterInfo&) const;
+ bool operator<(const RouterInfo&) const;
+
+ ::Ice::RouterPrx getRouter();
+ ::Ice::ObjectPrx getClientProxy();
+ void setClientProxy(const ::Ice::ObjectPrx&);
+ ::Ice::ObjectPrx getServerProxy();
+ void setServerProxy(const ::Ice::ObjectPrx&);
+ void addProxy(const ::Ice::ObjectPrx&);
+ void setAdapter(const ::Ice::ObjectAdapterPtr&);
+ ::Ice::ObjectAdapterPtr getAdapter();
+
+private:
+
+ ::Ice::RouterPrx _router;
+ ::Ice::ObjectPrx _clientProxy;
+ ::Ice::ObjectPrx _serverProxy;
+ RoutingTablePtr _routingTable;
+ ::Ice::ObjectAdapterPtr _adapter;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/RouterInfoF.h b/cpp/src/Ice/RouterInfoF.h index 72afbc70e7f..1db2e9bb606 100644 --- a/cpp/src/Ice/RouterInfoF.h +++ b/cpp/src/Ice/RouterInfoF.h @@ -1,31 +1,31 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_ROUTER_INFO_F_H -#define ICE_ROUTER_INFO_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class RouterManager; -void incRef(RouterManager*); -void decRef(RouterManager*); -typedef Handle<RouterManager> RouterManagerPtr; - -class RouterInfo; -void incRef(RouterInfo*); -void decRef(RouterInfo*); -typedef Handle<RouterInfo> RouterInfoPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_ROUTER_INFO_F_H
+#define ICE_ROUTER_INFO_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class RouterManager;
+void incRef(RouterManager*);
+void decRef(RouterManager*);
+typedef Handle<RouterManager> RouterManagerPtr;
+
+class RouterInfo;
+void incRef(RouterInfo*);
+void decRef(RouterInfo*);
+typedef Handle<RouterInfo> RouterInfoPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/RoutingTable.cpp b/cpp/src/Ice/RoutingTable.cpp index e1e88f5804c..79d13233636 100644 --- a/cpp/src/Ice/RoutingTable.cpp +++ b/cpp/src/Ice/RoutingTable.cpp @@ -26,7 +26,7 @@ IceInternal::RoutingTable::RoutingTable() : bool IceInternal::RoutingTable::add(const ObjectPrx& prx) { - if (!prx) + if(!prx) { return false; } @@ -37,20 +37,20 @@ IceInternal::RoutingTable::add(const ObjectPrx& prx) map<Identity, ObjectPrx>::iterator p = _table.end(); - if (_tableHint != _table.end()) + if(_tableHint != _table.end()) { - if (_tableHint->first == proxy->ice_getIdentity()) + if(_tableHint->first == proxy->ice_getIdentity()) { p = _tableHint; } } - if (p == _table.end()) + if(p == _table.end()) { p = _table.find(proxy->ice_getIdentity()); } - if (p == _table.end()) + if(p == _table.end()) { _tableHint = _table.insert(_tableHint, make_pair(proxy->ice_getIdentity(), proxy)); return true; @@ -64,7 +64,7 @@ IceInternal::RoutingTable::add(const ObjectPrx& prx) ObjectPrx IceInternal::RoutingTable::get(const Identity& ident) { - if (ident.name.empty()) + if(ident.name.empty()) { return 0; } @@ -73,20 +73,20 @@ IceInternal::RoutingTable::get(const Identity& ident) map<Identity, ObjectPrx>::iterator p = _table.end(); - if (_tableHint != _table.end()) + if(_tableHint != _table.end()) { - if (_tableHint->first == ident) + if(_tableHint->first == ident) { p = _tableHint; } } - if (p == _table.end()) + if(p == _table.end()) { p = _table.find(ident); } - if (p == _table.end()) + if(p == _table.end()) { return 0; } diff --git a/cpp/src/Ice/SysLoggerI.h b/cpp/src/Ice/SysLoggerI.h index 8ddde95cf7e..f7d14c324e2 100644 --- a/cpp/src/Ice/SysLoggerI.h +++ b/cpp/src/Ice/SysLoggerI.h @@ -1,31 +1,31 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SYS_LOGGER_I_H -#define ICE_SYS_LOGGER_I_H - -#include <IceUtil/Mutex.h> -#include <Ice/Logger.h> - -namespace Ice -{ - -class SysLoggerI : public Logger, public ::IceUtil::Mutex -{ -public: - - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SYS_LOGGER_I_H
+#define ICE_SYS_LOGGER_I_H
+
+#include <IceUtil/Mutex.h>
+#include <Ice/Logger.h>
+
+namespace Ice
+{
+
+class SysLoggerI : public Logger, public ::IceUtil::Mutex
+{
+public:
+
+ virtual void trace(const std::string&, const std::string&);
+ virtual void warning(const std::string&);
+ virtual void error(const std::string&);
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp index 4217668f956..7a5b63aa229 100644 --- a/cpp/src/Ice/TcpAcceptor.cpp +++ b/cpp/src/Ice/TcpAcceptor.cpp @@ -29,7 +29,7 @@ IceInternal::TcpAcceptor::fd() void IceInternal::TcpAcceptor::close() { - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "stopping to accept tcp connections at " << toString(); @@ -53,7 +53,7 @@ IceInternal::TcpAcceptor::listen() throw; } - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "accepting tcp connections at " << toString(); @@ -66,7 +66,7 @@ IceInternal::TcpAcceptor::accept(int timeout) SOCKET fd = doAccept(_fd, timeout); setBlock(fd, false); - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "accepted tcp connection\n" << fdToString(fd); @@ -101,7 +101,7 @@ IceInternal::TcpAcceptor::TcpAcceptor(const InstancePtr& instance, const string& _logger(instance->logger()), _backlog(0) { - if (_backlog <= 0) + if(_backlog <= 0) { _backlog = 5; } diff --git a/cpp/src/Ice/TcpAcceptor.h b/cpp/src/Ice/TcpAcceptor.h index e98a222f401..2cb462f7864 100644 --- a/cpp/src/Ice/TcpAcceptor.h +++ b/cpp/src/Ice/TcpAcceptor.h @@ -1,58 +1,58 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TCP_ACCEPTOR_H -#define ICE_TCP_ACCEPTOR_H - -#include <Ice/TransceiverF.h> -#include <Ice/InstanceF.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/LoggerF.h> -#include <Ice/Acceptor.h> - -#ifndef _WIN32 -# include <netinet/in.h> // For struct sockaddr_in -#endif - -namespace IceInternal -{ - -class TcpEndpoint; - -class TcpAcceptor : public Acceptor -{ -public: - - virtual SOCKET fd(); - virtual void close(); - virtual void listen(); - virtual TransceiverPtr accept(int); - virtual std::string toString() const; - - bool equivalent(const std::string&, int) const; - int effectivePort(); - -private: - - TcpAcceptor(const InstancePtr&, const std::string&, int); - virtual ~TcpAcceptor(); - friend class TcpEndpoint; - - InstancePtr _instance; - TraceLevelsPtr _traceLevels; - ::Ice::LoggerPtr _logger; - SOCKET _fd; - int _backlog; - struct sockaddr_in _addr; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TCP_ACCEPTOR_H
+#define ICE_TCP_ACCEPTOR_H
+
+#include <Ice/TransceiverF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/Acceptor.h>
+
+#ifndef _WIN32
+# include <netinet/in.h> // For struct sockaddr_in
+#endif
+
+namespace IceInternal
+{
+
+class TcpEndpoint;
+
+class TcpAcceptor : public Acceptor
+{
+public:
+
+ virtual SOCKET fd();
+ virtual void close();
+ virtual void listen();
+ virtual TransceiverPtr accept(int);
+ virtual std::string toString() const;
+
+ bool equivalent(const std::string&, int) const;
+ int effectivePort();
+
+private:
+
+ TcpAcceptor(const InstancePtr&, const std::string&, int);
+ virtual ~TcpAcceptor();
+ friend class TcpEndpoint;
+
+ InstancePtr _instance;
+ TraceLevelsPtr _traceLevels;
+ ::Ice::LoggerPtr _logger;
+ SOCKET _fd;
+ int _backlog;
+ struct sockaddr_in _addr;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TcpConnector.cpp b/cpp/src/Ice/TcpConnector.cpp index 236198804a7..52dcb8475f1 100644 --- a/cpp/src/Ice/TcpConnector.cpp +++ b/cpp/src/Ice/TcpConnector.cpp @@ -23,7 +23,7 @@ using namespace IceInternal; TransceiverPtr IceInternal::TcpConnector::connect(int timeout) { - if (_traceLevels->network >= 2) + if(_traceLevels->network >= 2) { Trace out(_logger, _traceLevels->networkCat); out << "trying to establish tcp connection to " << toString(); @@ -33,7 +33,7 @@ IceInternal::TcpConnector::connect(int timeout) setBlock(fd, false); doConnect(fd, _addr, timeout); - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "tcp connection established\n" << fdToString(fd); diff --git a/cpp/src/Ice/TcpConnector.h b/cpp/src/Ice/TcpConnector.h index e554d7210b5..79dfea97455 100644 --- a/cpp/src/Ice/TcpConnector.h +++ b/cpp/src/Ice/TcpConnector.h @@ -1,50 +1,50 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TCP_CONNECTOR_H -#define ICE_TCP_CONNECTOR_H - -#include <Ice/TransceiverF.h> -#include <Ice/InstanceF.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/LoggerF.h> -#include <Ice/Connector.h> - -#ifndef _WIN32 -# include <netinet/in.h> // For struct sockaddr_in -#endif - -namespace IceInternal -{ - -class TcpEndpoint; - -class TcpConnector : public Connector -{ -public: - - virtual TransceiverPtr connect(int); - virtual std::string toString() const; - -private: - - TcpConnector(const InstancePtr&, const std::string&, int); - virtual ~TcpConnector(); - friend class TcpEndpoint; - - InstancePtr _instance; - TraceLevelsPtr _traceLevels; - ::Ice::LoggerPtr _logger; - struct sockaddr_in _addr; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TCP_CONNECTOR_H
+#define ICE_TCP_CONNECTOR_H
+
+#include <Ice/TransceiverF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/Connector.h>
+
+#ifndef _WIN32
+# include <netinet/in.h> // For struct sockaddr_in
+#endif
+
+namespace IceInternal
+{
+
+class TcpEndpoint;
+
+class TcpConnector : public Connector
+{
+public:
+
+ virtual TransceiverPtr connect(int);
+ virtual std::string toString() const;
+
+private:
+
+ TcpConnector(const InstancePtr&, const std::string&, int);
+ virtual ~TcpConnector();
+ friend class TcpEndpoint;
+
+ InstancePtr _instance;
+ TraceLevelsPtr _traceLevels;
+ ::Ice::LoggerPtr _logger;
+ struct sockaddr_in _addr;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TcpEndpoint.cpp b/cpp/src/Ice/TcpEndpoint.cpp index 8f2a21b8b32..7ffb353d33f 100644 --- a/cpp/src/Ice/TcpEndpoint.cpp +++ b/cpp/src/Ice/TcpEndpoint.cpp @@ -40,44 +40,44 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& string::size_type beg; string::size_type end = 0; - while (true) + while(true) { beg = str.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } end = str.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } string option = str.substr(beg, end - beg); - if (option.length() != 2 || option[0] != '-') + if(option.length() != 2 || option[0] != '-') { throw EndpointParseException(__FILE__, __LINE__); } string argument; string::size_type argumentBeg = str.find_first_not_of(delim, end); - if (argumentBeg != string::npos && str[argumentBeg] != '-') + if(argumentBeg != string::npos && str[argumentBeg] != '-') { beg = argumentBeg; end = str.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } argument = str.substr(beg, end - beg); } - switch (option[1]) + switch(option[1]) { case 'h': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -87,7 +87,7 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& case 'p': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -97,7 +97,7 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& case 't': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -112,7 +112,7 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string& } } - if (_host.empty()) + if(_host.empty()) { const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; } @@ -146,7 +146,7 @@ IceInternal::TcpEndpoint::toString() const { ostringstream s; s << "tcp -h " << _host << " -p " << _port; - if (_timeout != -1) + if(_timeout != -1) { s << " -t " << _timeout; } @@ -168,7 +168,7 @@ IceInternal::TcpEndpoint::timeout() const EndpointPtr IceInternal::TcpEndpoint::timeout(Int timeout) const { - if (timeout == _timeout) + if(timeout == _timeout) { return const_cast<TcpEndpoint*>(this); } @@ -233,7 +233,7 @@ bool IceInternal::TcpEndpoint::equivalent(const AcceptorPtr& acceptor) const { const TcpAcceptor* tcpAcceptor = dynamic_cast<const TcpAcceptor*>(acceptor.get()); - if (!tcpAcceptor) + if(!tcpAcceptor) { return false; } @@ -244,27 +244,27 @@ bool IceInternal::TcpEndpoint::operator==(const Endpoint& r) const { const TcpEndpoint* p = dynamic_cast<const TcpEndpoint*>(&r); - if (!p) + if(!p) { return false; } - if (this == p) + if(this == p) { return true; } - if (_port != p->_port) + if(_port != p->_port) { return false; } - if (_timeout != p->_timeout) + if(_timeout != p->_timeout) { return false; } - if (_host != p->_host) + if(_host != p->_host) { // // We do the most time-consuming part of the comparison last. @@ -289,35 +289,35 @@ bool IceInternal::TcpEndpoint::operator<(const Endpoint& r) const { const TcpEndpoint* p = dynamic_cast<const TcpEndpoint*>(&r); - if (!p) + if(!p) { return type() < r.type(); } - if (this == p) + if(this == p) { return false; } - if (_port < p->_port) + if(_port < p->_port) { return true; } - else if (p->_port < _port) + else if(p->_port < _port) { return false; } - if (_timeout < p->_timeout) + if(_timeout < p->_timeout) { return true; } - else if (p->_timeout < _timeout) + else if(p->_timeout < _timeout) { return false; } - if (_host != p->_host) + if(_host != p->_host) { // // We do the most time-consuming part of the comparison last. @@ -326,11 +326,11 @@ IceInternal::TcpEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host, _port, laddr); getAddress(p->_host, p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) + if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; } - else if (raddr.sin_addr.s_addr < laddr.sin_addr.s_addr) + else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr) { return false; } diff --git a/cpp/src/Ice/TcpEndpoint.h b/cpp/src/Ice/TcpEndpoint.h index 55c7b371132..9ef58fe6eaa 100644 --- a/cpp/src/Ice/TcpEndpoint.h +++ b/cpp/src/Ice/TcpEndpoint.h @@ -1,82 +1,82 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TCP_ENDPOINT_H -#define ICE_TCP_ENDPOINT_H - -#include <Ice/Endpoint.h> -#include <Ice/EndpointFactory.h> - -namespace IceInternal -{ - -const ::Ice::Short TcpEndpointType = 1; - -class TcpEndpoint : public Endpoint -{ -public: - - TcpEndpoint(const InstancePtr&, const std::string&, ::Ice::Int, ::Ice::Int); - TcpEndpoint(const InstancePtr&, const std::string&); - TcpEndpoint(BasicStream*); - - virtual void streamWrite(BasicStream*) const; - virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual EndpointPtr timeout(::Ice::Int) const; - virtual bool datagram() const; - virtual bool secure() const; - virtual bool unknown() const; - virtual TransceiverPtr clientTransceiver() const; - virtual TransceiverPtr serverTransceiver(EndpointPtr&) const; - virtual ConnectorPtr connector() const; - virtual AcceptorPtr acceptor(EndpointPtr&) const; - virtual bool equivalent(const TransceiverPtr&) const; - virtual bool equivalent(const AcceptorPtr&) const; - - virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; - virtual bool operator<(const Endpoint&) const; - -private: - - // - // All members are const, because endpoints are immutable. - // - const InstancePtr _instance; - const std::string _host; - const ::Ice::Int _port; - const ::Ice::Int _timeout; -}; - -class TcpEndpointFactory : public EndpointFactory -{ -public: - - virtual ~TcpEndpointFactory(); - - virtual ::Ice::Short type() const; - virtual const ::std::string& protocol() const; - virtual EndpointPtr create(const std::string&) const; - virtual EndpointPtr read(BasicStream*) const; - virtual void destroy(); - -private: - - TcpEndpointFactory(const InstancePtr&); - friend class Instance; - - InstancePtr _instance; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TCP_ENDPOINT_H
+#define ICE_TCP_ENDPOINT_H
+
+#include <Ice/Endpoint.h>
+#include <Ice/EndpointFactory.h>
+
+namespace IceInternal
+{
+
+const ::Ice::Short TcpEndpointType = 1;
+
+class TcpEndpoint : public Endpoint
+{
+public:
+
+ TcpEndpoint(const InstancePtr&, const std::string&, ::Ice::Int, ::Ice::Int);
+ TcpEndpoint(const InstancePtr&, const std::string&);
+ TcpEndpoint(BasicStream*);
+
+ virtual void streamWrite(BasicStream*) const;
+ virtual std::string toString() const;
+ virtual ::Ice::Short type() const;
+ virtual ::Ice::Int timeout() const;
+ virtual EndpointPtr timeout(::Ice::Int) const;
+ virtual bool datagram() const;
+ virtual bool secure() const;
+ virtual bool unknown() const;
+ virtual TransceiverPtr clientTransceiver() const;
+ virtual TransceiverPtr serverTransceiver(EndpointPtr&) const;
+ virtual ConnectorPtr connector() const;
+ virtual AcceptorPtr acceptor(EndpointPtr&) const;
+ virtual bool equivalent(const TransceiverPtr&) const;
+ virtual bool equivalent(const AcceptorPtr&) const;
+
+ virtual bool operator==(const Endpoint&) const;
+ virtual bool operator!=(const Endpoint&) const;
+ virtual bool operator<(const Endpoint&) const;
+
+private:
+
+ //
+ // All members are const, because endpoints are immutable.
+ //
+ const InstancePtr _instance;
+ const std::string _host;
+ const ::Ice::Int _port;
+ const ::Ice::Int _timeout;
+};
+
+class TcpEndpointFactory : public EndpointFactory
+{
+public:
+
+ virtual ~TcpEndpointFactory();
+
+ virtual ::Ice::Short type() const;
+ virtual const ::std::string& protocol() const;
+ virtual EndpointPtr create(const std::string&) const;
+ virtual EndpointPtr read(BasicStream*) const;
+ virtual void destroy();
+
+private:
+
+ TcpEndpointFactory(const InstancePtr&);
+ friend class Instance;
+
+ InstancePtr _instance;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index 6c8cf640dd8..3014b25161b 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -29,7 +29,7 @@ IceInternal::TcpTransceiver::fd() void IceInternal::TcpTransceiver::close() { - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "closing tcp connection\n" << toString(); @@ -44,7 +44,7 @@ IceInternal::TcpTransceiver::close() void IceInternal::TcpTransceiver::shutdown() { - if (_traceLevels->network >= 2) + if(_traceLevels->network >= 2) { Trace out(_logger, _traceLevels->networkCat); out << "shutting down tcp connection\n" << toString(); @@ -62,45 +62,45 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) // // Limit packet size to avoid performance problems on WIN32 // - if (packetSize > 64 * 1024) + if(packetSize > 64 * 1024) { packetSize = 64 * 1024; } #endif - while (buf.i != buf.b.end()) + while(buf.i != buf.b.end()) { int ret = ::send(_fd, &*buf.i, packetSize, 0); - if (ret == 0) + if(ret == 0) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = 0; throw ex; } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { continue; } - if (noBuffers() && packetSize > 1024) + if(noBuffers() && packetSize > 1024) { packetSize /= 2; continue; } - if (wouldBlock()) + if(wouldBlock()) { SOCKET fd = _fd; // Copy fd, in case another thread calls close() - if (fd != INVALID_SOCKET) + if(fd != INVALID_SOCKET) { repeatSelect: int ret; FD_SET(fd, &_wFdSet); - if (timeout >= 0) + if(timeout >= 0) { struct timeval tv; tv.tv_sec = timeout / 1000; @@ -112,9 +112,9 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) ret = ::select(fd + 1, 0, &_wFdSet, 0, 0); } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -124,7 +124,7 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) throw ex; } - if (ret == 0) + if(ret == 0) { throw TimeoutException(__FILE__, __LINE__); } @@ -133,7 +133,7 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) continue; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -147,7 +147,7 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) } } - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { Trace out(_logger, _traceLevels->networkCat); out << "sent " << ret << " of " << packetSize << " bytes via tcp\n" << toString(); @@ -155,7 +155,7 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout) buf.i += ret; - if (packetSize > buf.b.end() - buf.i) + if(packetSize > buf.b.end() - buf.i) { packetSize = buf.b.end() - buf.i; } @@ -167,39 +167,39 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) { int packetSize = buf.b.end() - buf.i; - while (buf.i != buf.b.end()) + while(buf.i != buf.b.end()) { int ret = ::recv(_fd, &*buf.i, packetSize, 0); - if (ret == 0) + if(ret == 0) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = 0; throw ex; } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { continue; } - if (noBuffers() && packetSize > 1024) + if(noBuffers() && packetSize > 1024) { packetSize /= 2; continue; } - if (wouldBlock()) + if(wouldBlock()) { SOCKET fd = _fd; // Copy fd, in case another thread calls close() - if (fd != INVALID_SOCKET) + if(fd != INVALID_SOCKET) { repeatSelect: int ret; FD_SET(fd, &_rFdSet); - if (timeout >= 0) + if(timeout >= 0) { struct timeval tv; tv.tv_sec = timeout / 1000; @@ -211,9 +211,9 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) ret = ::select(fd + 1, &_rFdSet, 0, 0, 0); } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -223,7 +223,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) throw ex; } - if (ret == 0) + if(ret == 0) { throw TimeoutException(__FILE__, __LINE__); } @@ -232,7 +232,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) continue; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -246,7 +246,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) } } - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { Trace out(_logger, _traceLevels->networkCat); out << "received " << ret << " of " << packetSize << " bytes via tcp\n" << toString(); @@ -254,7 +254,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout) buf.i += ret; - if (packetSize > buf.b.end() - buf.i) + if(packetSize > buf.b.end() - buf.i) { packetSize = buf.b.end() - buf.i; } diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h index 9809f68a60b..c3daa2fdb37 100644 --- a/cpp/src/Ice/TcpTransceiver.h +++ b/cpp/src/Ice/TcpTransceiver.h @@ -1,53 +1,53 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TCP_TRANSCEIVER_H -#define ICE_TCP_TRANSCEIVER_H - -#include <Ice/InstanceF.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/LoggerF.h> -#include <Ice/Transceiver.h> - -namespace IceInternal -{ - -class TcpConnector; -class TcpAcceptor; - -class TcpTransceiver : public Transceiver -{ -public: - - virtual SOCKET fd(); - virtual void close(); - virtual void shutdown(); - virtual void write(Buffer&, int); - virtual void read(Buffer&, int); - virtual std::string toString() const; - -private: - - TcpTransceiver(const InstancePtr&, SOCKET); - virtual ~TcpTransceiver(); - friend class TcpConnector; - friend class TcpAcceptor; - - InstancePtr _instance; - TraceLevelsPtr _traceLevels; - ::Ice::LoggerPtr _logger; - SOCKET _fd; - fd_set _rFdSet; - fd_set _wFdSet; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TCP_TRANSCEIVER_H
+#define ICE_TCP_TRANSCEIVER_H
+
+#include <Ice/InstanceF.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/Transceiver.h>
+
+namespace IceInternal
+{
+
+class TcpConnector;
+class TcpAcceptor;
+
+class TcpTransceiver : public Transceiver
+{
+public:
+
+ virtual SOCKET fd();
+ virtual void close();
+ virtual void shutdown();
+ virtual void write(Buffer&, int);
+ virtual void read(Buffer&, int);
+ virtual std::string toString() const;
+
+private:
+
+ TcpTransceiver(const InstancePtr&, SOCKET);
+ virtual ~TcpTransceiver();
+ friend class TcpConnector;
+ friend class TcpAcceptor;
+
+ InstancePtr _instance;
+ TraceLevelsPtr _traceLevels;
+ ::Ice::LoggerPtr _logger;
+ SOCKET _fd;
+ fd_set _rFdSet;
+ fd_set _wFdSet;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index c372fbb29de..dbcc65a2e6a 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -46,7 +46,7 @@ IceInternal::ThreadPool::unregister(SOCKET fd) void IceInternal::ThreadPool::promoteFollower() { - if (_multipleThreads) + if(_multipleThreads) { _threadMutex.unlock(); } @@ -63,12 +63,12 @@ IceInternal::ThreadPool::waitUntilFinished() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while (_handlers != 0 && _threadNum != 0) + while(_handlers != 0 && _threadNum != 0) { wait(); } - if (_handlers != 0) + if(_handlers != 0) { Error out(_instance->logger()); out << "can't wait for graceful application termination in thread pool\n" @@ -89,7 +89,7 @@ IceInternal::ThreadPool::joinWithAllThreads() // needed. (Synchronization wouldn't be possible here anyway, // because otherwise the other threads would never terminate.) // - for (vector<IceUtil::ThreadControl>::iterator p = _threads.begin(); p != _threads.end(); ++p) + for(vector<IceUtil::ThreadControl>::iterator p = _threads.begin(); p != _threads.end(); ++p) { p->join(); } @@ -114,7 +114,7 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, bool server) : _maxFd = _fdIntrRead; _minFd = _fdIntrRead; - if (server) + if(server) { _timeout = _instance->properties()->getPropertyAsInt("Ice.ServerIdleTime"); _threadNum = _instance->properties()->getPropertyAsIntWithDefault("Ice.ServerThreadPool.Size", 10); @@ -124,12 +124,12 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, bool server) : _threadNum = _instance->properties()->getPropertyAsIntWithDefault("Ice.ClientThreadPool.Size", 1); } - if (_threadNum < 1) + if(_threadNum < 1) { _threadNum = 1; } - if (_threadNum > 1) + if(_threadNum > 1) { _multipleThreads = true; } @@ -137,7 +137,7 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, bool server) : __setNoDelete(true); try { - for (int i = 0 ; i < _threadNum ; ++i) + for(int i = 0 ; i < _threadNum ; ++i) { IceUtil::ThreadPtr thread = new EventHandlerThread(this); _threads.push_back(thread->start()); @@ -187,9 +187,9 @@ IceInternal::ThreadPool::clearInterrupt() repeat: #ifdef _WIN32 - if (::recv(_fdIntrRead, &c, 1, 0) == SOCKET_ERROR) + if(::recv(_fdIntrRead, &c, 1, 0) == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeat; } @@ -199,9 +199,9 @@ repeat: throw ex; } #else - if (::read(_fdIntrRead, &c, 1) == -1) + if(::read(_fdIntrRead, &c, 1) == -1) { - if (interrupted()) + if(interrupted()) { goto repeat; } @@ -221,9 +221,9 @@ IceInternal::ThreadPool::setInterrupt(char c) repeat: #ifdef _WIN32 - if (::send(_fdIntrWrite, &c, 1, 0) == SOCKET_ERROR) + if(::send(_fdIntrWrite, &c, 1, 0) == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeat; } @@ -233,9 +233,9 @@ repeat: throw ex; } #else - if (::write(_fdIntrWrite, &c, 1) == -1) + if(::write(_fdIntrWrite, &c, 1) == -1) { - if (interrupted()) + if(interrupted()) { goto repeat; } @@ -253,20 +253,20 @@ IceInternal::ThreadPool::run() ThreadPoolPtr self = this; bool shutdown = false; - while (true) + while(true) { - if (_multipleThreads) + if(_multipleThreads) { _threadMutex.lock(); } repeatSelect: - if (shutdown) // Shutdown has been initiated. + if(shutdown) // Shutdown has been initiated. { shutdown = false; ObjectAdapterFactoryPtr factory = _instance->objectAdapterFactory(); - if (factory) + if(factory) { factory->shutdown(); } @@ -275,7 +275,7 @@ IceInternal::ThreadPool::run() fd_set fdSet; memcpy(&fdSet, &_fdSet, sizeof(fd_set)); int ret; - if (_timeout) + if(_timeout) { struct timeval tv; tv.tv_sec = _timeout; @@ -287,7 +287,7 @@ IceInternal::ThreadPool::run() ret = ::select(_maxFd + 1, &fdSet, 0, 0, 0); } - if (ret == 0) // Timeout. + if(ret == 0) // Timeout. { assert(_timeout); _timeout = 0; @@ -295,9 +295,9 @@ IceInternal::ThreadPool::run() goto repeatSelect; } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -313,7 +313,7 @@ IceInternal::ThreadPool::run() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - if (FD_ISSET(_fdIntrRead, &fdSet)) + if(FD_ISSET(_fdIntrRead, &fdSet)) { // // There are three possiblities for an interrupt: @@ -328,7 +328,7 @@ IceInternal::ThreadPool::run() // // Thread pool destroyed? // - if (_destroyed) + if(_destroyed) { // // Don't clear the interrupt if destroyed, so that @@ -342,7 +342,7 @@ IceInternal::ThreadPool::run() // // Server shutdown? // - if (shutdown) + if(shutdown) { goto repeatSelect; } @@ -355,7 +355,7 @@ IceInternal::ThreadPool::run() pair<SOCKET, EventHandlerPtr> change = _changes.front(); _changes.pop_front(); - if (change.second) // Addition if handler is set. + if(change.second) // Addition if handler is set. { _handlerMap.insert(change); FD_SET(change.first, &_fdSet); @@ -373,7 +373,7 @@ IceInternal::ThreadPool::run() FD_CLR(change.first, &_fdSet); _maxFd = _fdIntrRead; _minFd = _fdIntrRead; - if (!_handlerMap.empty()) + if(!_handlerMap.empty()) { _maxFd = max(_maxFd, (--_handlerMap.end())->first); _minFd = min(_minFd, _handlerMap.begin()->first); @@ -393,7 +393,7 @@ IceInternal::ThreadPool::run() // // Round robin for the filedescriptors. // - if (fdSet.fd_count == 0) + if(fdSet.fd_count == 0) { Error out(_instance->logger()); out << "select() in thread pool returned " << ret << " but no filedescriptor is readable"; @@ -402,12 +402,12 @@ IceInternal::ThreadPool::run() SOCKET largerFd = _maxFd + 1; SOCKET smallestFd = _maxFd + 1; - for (u_short i = 0; i < fdSet.fd_count; ++i) + for(u_short i = 0; i < fdSet.fd_count; ++i) { SOCKET fd = fdSet.fd_array[i]; assert(fd != INVALID_SOCKET); - if (fd > _lastFd || _lastFd == INVALID_SOCKET) + if(fd > _lastFd || _lastFd == INVALID_SOCKET) { largerFd = min(largerFd, fd); } @@ -415,7 +415,7 @@ IceInternal::ThreadPool::run() smallestFd = min(smallestFd, fd); } - if (largerFd <= _maxFd) + if(largerFd <= _maxFd) { assert(largerFd >= _minFd); _lastFd = largerFd; @@ -429,7 +429,7 @@ IceInternal::ThreadPool::run() // // Round robin for the filedescriptors. // - if (_lastFd < _minFd - 1 || _lastFd == INVALID_SOCKET) + if(_lastFd < _minFd - 1 || _lastFd == INVALID_SOCKET) { _lastFd = _minFd - 1; } @@ -437,15 +437,15 @@ IceInternal::ThreadPool::run() int loops = 0; do { - if (++_lastFd > _maxFd) + if(++_lastFd > _maxFd) { ++loops; _lastFd = _minFd; } } - while (!FD_ISSET(_lastFd, &fdSet) && loops <= 1); + while(!FD_ISSET(_lastFd, &fdSet) && loops <= 1); - if (loops > 1) + if(loops > 1) { Error out(_instance->logger()); out << "select() in thread pool returned " << ret << " but no filedescriptor is readable"; @@ -469,7 +469,7 @@ IceInternal::ThreadPool::run() assert(handler); - if (finished) + if(finished) { // // Notify a handler about it's removal from the thread @@ -480,7 +480,7 @@ IceInternal::ThreadPool::run() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); assert(_handlers > 0); - if (--_handlers == 0) + if(--_handlers == 0) { notifyAll(); // For waitUntilFinished(). } @@ -492,7 +492,7 @@ IceInternal::ThreadPool::run() // If the handler is "readable", try to read a message. // BasicStream stream(_instance); - if (handler->readable()) + if(handler->readable()) { try { @@ -522,13 +522,13 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) { BasicStream& stream = handler->_stream; - if (stream.b.size() == 0) + if(stream.b.size() == 0) { stream.b.resize(headerSize); stream.i = stream.b.begin(); } - if (stream.i != stream.b.end()) + if(stream.i != stream.b.end()) { handler->read(stream); assert(stream.i == stream.b.end()); @@ -539,13 +539,13 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) stream.i = stream.b.begin(); Byte protVer; stream.read(protVer); - if (protVer != protocolVersion) + if(protVer != protocolVersion) { throw UnsupportedProtocolException(__FILE__, __LINE__); } Byte encVer; stream.read(encVer); - if (encVer != encodingVersion) + if(encVer != encodingVersion) { throw UnsupportedEncodingException(__FILE__, __LINE__); } @@ -553,21 +553,21 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) stream.read(messageType); Int size; stream.read(size); - if (size < headerSize) + if(size < headerSize) { throw IllegalMessageSizeException(__FILE__, __LINE__); } - if (size > 1024 * 1024) // TODO: configurable + if(size > 1024 * 1024) // TODO: configurable { throw MemoryLimitException(__FILE__, __LINE__); } - if (size > static_cast<Int>(stream.b.size())) + if(size > static_cast<Int>(stream.b.size())) { stream.b.resize(size); } stream.i = stream.b.begin() + pos; - if (stream.i != stream.b.end()) + if(stream.i != stream.b.end()) { handler->read(stream); assert(stream.i == stream.b.end()); @@ -610,7 +610,7 @@ IceInternal::ThreadPool::EventHandlerThread::run() // "defensive" programming approach when it comes to // multithreading. // - if (_pool->_threadNum == 0) + if(_pool->_threadNum == 0) { _pool->notifyAll(); // For waitUntil...Finished() methods. } diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index dfdb3aa7d53..9343ab54dd5 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -1,93 +1,93 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_THREAD_POOL_H -#define ICE_THREAD_POOL_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/Monitor.h> -#include <IceUtil/Thread.h> - -#include <Ice/ThreadPoolF.h> -#include <Ice/InstanceF.h> -#include <Ice/LoggerF.h> -#include <Ice/PropertiesF.h> -#include <Ice/EventHandlerF.h> -#include <list> - -#ifndef _WIN32 -# define SOCKET int -#endif - -namespace IceInternal -{ - -class BasicStream; - -class ThreadPool : public ::IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - void _register(SOCKET, const EventHandlerPtr&); - void unregister(SOCKET); - void promoteFollower(); - void initiateShutdown(); // Signal-safe shutdown initiation. - void waitUntilFinished(); - void joinWithAllThreads(); - -private: - - ThreadPool(const InstancePtr&, bool); - virtual ~ThreadPool(); - void destroy(); - friend class Instance; - - bool clearInterrupt(); - void setInterrupt(char); - - void run(); - void read(const EventHandlerPtr&); - - InstancePtr _instance; - bool _destroyed; - SOCKET _maxFd; - SOCKET _minFd; - SOCKET _lastFd; - SOCKET _fdIntrRead; - SOCKET _fdIntrWrite; - fd_set _fdSet; - std::list<std::pair<SOCKET, EventHandlerPtr> > _changes; // Event handler set for addition; null for removal. - std::map<SOCKET, EventHandlerPtr> _handlerMap; - int _handlers; - int _timeout; - ::IceUtil::Mutex _threadMutex; - bool _multipleThreads; - - class EventHandlerThread : public ::IceUtil::Thread - { - public: - - EventHandlerThread(const ThreadPoolPtr&); - virtual void run(); - - private: - - ThreadPoolPtr _pool; - }; - friend class EventHandlerThread; - - std::vector<IceUtil::ThreadControl> _threads; // Control for all threads, running or not. - int _threadNum; // Number of running threads. -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_THREAD_POOL_H
+#define ICE_THREAD_POOL_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <IceUtil/Monitor.h>
+#include <IceUtil/Thread.h>
+
+#include <Ice/ThreadPoolF.h>
+#include <Ice/InstanceF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/PropertiesF.h>
+#include <Ice/EventHandlerF.h>
+#include <list>
+
+#ifndef _WIN32
+# define SOCKET int
+#endif
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+class ThreadPool : public ::IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex>
+{
+public:
+
+ void _register(SOCKET, const EventHandlerPtr&);
+ void unregister(SOCKET);
+ void promoteFollower();
+ void initiateShutdown(); // Signal-safe shutdown initiation.
+ void waitUntilFinished();
+ void joinWithAllThreads();
+
+private:
+
+ ThreadPool(const InstancePtr&, bool);
+ virtual ~ThreadPool();
+ void destroy();
+ friend class Instance;
+
+ bool clearInterrupt();
+ void setInterrupt(char);
+
+ void run();
+ void read(const EventHandlerPtr&);
+
+ InstancePtr _instance;
+ bool _destroyed;
+ SOCKET _maxFd;
+ SOCKET _minFd;
+ SOCKET _lastFd;
+ SOCKET _fdIntrRead;
+ SOCKET _fdIntrWrite;
+ fd_set _fdSet;
+ std::list<std::pair<SOCKET, EventHandlerPtr> > _changes; // Event handler set for addition; null for removal.
+ std::map<SOCKET, EventHandlerPtr> _handlerMap;
+ int _handlers;
+ int _timeout;
+ ::IceUtil::Mutex _threadMutex;
+ bool _multipleThreads;
+
+ class EventHandlerThread : public ::IceUtil::Thread
+ {
+ public:
+
+ EventHandlerThread(const ThreadPoolPtr&);
+ virtual void run();
+
+ private:
+
+ ThreadPoolPtr _pool;
+ };
+ friend class EventHandlerThread;
+
+ std::vector<IceUtil::ThreadControl> _threads; // Control for all threads, running or not.
+ int _threadNum; // Number of running threads.
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/ThreadPoolF.h b/cpp/src/Ice/ThreadPoolF.h index 44332d6c413..18628f56397 100644 --- a/cpp/src/Ice/ThreadPoolF.h +++ b/cpp/src/Ice/ThreadPoolF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_THREAD_POOL_F_H -#define ICE_THREAD_POOL_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class ThreadPool; -void incRef(ThreadPool*); -void decRef(ThreadPool*); -typedef Handle<ThreadPool> ThreadPoolPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_THREAD_POOL_F_H
+#define ICE_THREAD_POOL_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class ThreadPool;
+void incRef(ThreadPool*);
+void decRef(ThreadPool*);
+typedef Handle<ThreadPool> ThreadPoolPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TraceLevels.h b/cpp/src/Ice/TraceLevels.h index ea2cec28fb9..80217412055 100644 --- a/cpp/src/Ice/TraceLevels.h +++ b/cpp/src/Ice/TraceLevels.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TRACE_LEVELS_H -#define ICE_TRACE_LEVELS_H - -#include <IceUtil/Shared.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/PropertiesF.h> - -namespace IceInternal -{ - -class TraceLevels : public ::IceUtil::Shared -{ -public: - - TraceLevels(const ::Ice::PropertiesPtr&); - - const int network; - const char* networkCat; - - const int protocol; - const char* protocolCat; - - const int retry; - const char* retryCat; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TRACE_LEVELS_H
+#define ICE_TRACE_LEVELS_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/PropertiesF.h>
+
+namespace IceInternal
+{
+
+class TraceLevels : public ::IceUtil::Shared
+{
+public:
+
+ TraceLevels(const ::Ice::PropertiesPtr&);
+
+ const int network;
+ const char* networkCat;
+
+ const int protocol;
+ const char* protocolCat;
+
+ const int retry;
+ const char* retryCat;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TraceLevelsF.h b/cpp/src/Ice/TraceLevelsF.h index 8b6e37218b6..16648060987 100644 --- a/cpp/src/Ice/TraceLevelsF.h +++ b/cpp/src/Ice/TraceLevelsF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TRACE_LEVELS_F_H -#define ICE_TRACE_LEVELS_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class TraceLevels; -void incRef(TraceLevels*); -void decRef(TraceLevels*); -typedef Handle<TraceLevels> TraceLevelsPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TRACE_LEVELS_F_H
+#define ICE_TRACE_LEVELS_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class TraceLevels;
+void incRef(TraceLevels*);
+void decRef(TraceLevels*);
+typedef Handle<TraceLevels> TraceLevelsPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp index e29609825c6..ac4069fc36f 100644 --- a/cpp/src/Ice/TraceUtil.cpp +++ b/cpp/src/Ice/TraceUtil.cpp @@ -100,13 +100,13 @@ printRequestHeader(ostream& s, BasicStream& stream) Int sz; stream.readSize(sz); s << "\ncontext = "; - while (sz--) + while(sz--) { pair<string, string> pair; stream.read(pair.first); stream.read(pair.second); s << pair.first << '/' << pair.second; - if (sz) + if(sz) { s << ", "; } @@ -122,22 +122,22 @@ dumpOctets(const char* cat, const BasicStream& stream, const ::Ice::LoggerPtr& l const BasicStream::Container::size_type inc = 8; - for (BasicStream::Container::size_type i = 0; i < stream.b.size(); i += inc) + for(BasicStream::Container::size_type i = 0; i < stream.b.size(); i += inc) { - for (BasicStream::Container::size_type j = i; j - i < inc; j++) + for(BasicStream::Container::size_type j = i; j - i < inc; j++) { - if (j < stream.b.size()) + if(j < stream.b.size()) { int n = stream.b[j]; - if (n < 0) + if(n < 0) { n += 256; } - if (n < 10) + if(n < 10) { s << " " << n; } - else if (n < 100) + else if(n < 100) { s << " " << n; } @@ -155,9 +155,9 @@ dumpOctets(const char* cat, const BasicStream& stream, const ::Ice::LoggerPtr& l s << '"'; - for (BasicStream::Container::size_type j = i; j < stream.b.size() && j - i < inc; j++) + for(BasicStream::Container::size_type j = i; j < stream.b.size() && j - i < inc; j++) { - if (stream.b[j] >= 32 && stream.b[j] < 127) + if(stream.b[j] >= 32 && stream.b[j] < 127) { s << (char)stream.b[j]; } @@ -178,7 +178,7 @@ void IceInternal::traceHeader(const char* heading, const BasicStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { - if (tl->protocol >= 1) + if(tl->protocol >= 1) { BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; @@ -195,7 +195,7 @@ void IceInternal::traceRequest(const char* heading, const BasicStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { - if (tl->protocol >= 1) + if(tl->protocol >= 1) { BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; @@ -206,7 +206,7 @@ IceInternal::traceRequest(const char* heading, const BasicStream& str, const ::I Int requestId; stream.read(requestId); s << "\nrequest id = " << requestId; - if (requestId == 0) + if(requestId == 0) { s << " (oneway)"; } @@ -220,7 +220,7 @@ void IceInternal::traceBatchRequest(const char* heading, const BasicStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { - if (tl->protocol >= 1) + if(tl->protocol >= 1) { BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; @@ -229,7 +229,7 @@ IceInternal::traceBatchRequest(const char* heading, const BasicStream& str, cons s << heading; printHeader(s, stream); int cnt = 0; - while (stream.i != stream.b.end()) + while(stream.i != stream.b.end()) { s << "\nrequest #" << cnt++ << ':'; printRequestHeader(s, stream); @@ -244,7 +244,7 @@ void IceInternal::traceReply(const char* heading, const BasicStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { - if (tl->protocol >= 1) + if(tl->protocol >= 1) { BasicStream& stream = const_cast<BasicStream&>(str); BasicStream::Container::iterator p = stream.i; diff --git a/cpp/src/Ice/TraceUtil.h b/cpp/src/Ice/TraceUtil.h index 8841561ad82..d76da5378ac 100644 --- a/cpp/src/Ice/TraceUtil.h +++ b/cpp/src/Ice/TraceUtil.h @@ -1,29 +1,29 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TRACE_UTIL_H -#define ICE_TRACE_UTIL_H - -#include <Ice/LoggerF.h> -#include <Ice/TraceLevelsF.h> - -namespace IceInternal -{ - -class BasicStream; - -void traceHeader(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&); -void traceRequest(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&); -void traceBatchRequest(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&); -void traceReply(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TRACE_UTIL_H
+#define ICE_TRACE_UTIL_H
+
+#include <Ice/LoggerF.h>
+#include <Ice/TraceLevelsF.h>
+
+namespace IceInternal
+{
+
+class BasicStream;
+
+void traceHeader(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&);
+void traceRequest(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&);
+void traceBatchRequest(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&);
+void traceReply(const char*, const BasicStream&, const ::Ice::LoggerPtr&, const TraceLevelsPtr&);
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index 244e2743415..2238527f8b1 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -1,40 +1,40 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TRANSCEIVER_H -#define ICE_TRANSCEIVER_H - -#include <IceUtil/Shared.h> -#include <Ice/TransceiverF.h> - -#ifndef _WIN32 -# define SOCKET int -#endif - -namespace IceInternal -{ - -class Buffer; - -class ICE_PROTOCOL_API Transceiver : public ::IceUtil::Shared -{ -public: - - virtual SOCKET fd() = 0; - virtual void close() = 0; - virtual void shutdown() = 0; - virtual void write(Buffer&, int) = 0; - virtual void read(Buffer&, int) = 0; - virtual std::string toString() const = 0; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TRANSCEIVER_H
+#define ICE_TRANSCEIVER_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/TransceiverF.h>
+
+#ifndef _WIN32
+# define SOCKET int
+#endif
+
+namespace IceInternal
+{
+
+class Buffer;
+
+class ICE_PROTOCOL_API Transceiver : public ::IceUtil::Shared
+{
+public:
+
+ virtual SOCKET fd() = 0;
+ virtual void close() = 0;
+ virtual void shutdown() = 0;
+ virtual void write(Buffer&, int) = 0;
+ virtual void read(Buffer&, int) = 0;
+ virtual std::string toString() const = 0;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/TransceiverF.h b/cpp/src/Ice/TransceiverF.h index 80f3293f0e2..45b1bde641b 100644 --- a/cpp/src/Ice/TransceiverF.h +++ b/cpp/src/Ice/TransceiverF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_TRANSCEIVER_F_H -#define ICE_TRANSCEIVER_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class Transceiver; -ICE_PROTOCOL_API void incRef(Transceiver*); -ICE_PROTOCOL_API void decRef(Transceiver*); -typedef Handle<Transceiver> TransceiverPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_TRANSCEIVER_F_H
+#define ICE_TRANSCEIVER_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class Transceiver;
+ICE_PROTOCOL_API void incRef(Transceiver*);
+ICE_PROTOCOL_API void decRef(Transceiver*);
+typedef Handle<Transceiver> TransceiverPtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/UdpEndpoint.cpp b/cpp/src/Ice/UdpEndpoint.cpp index 62c84ff7aca..8bed2486497 100644 --- a/cpp/src/Ice/UdpEndpoint.cpp +++ b/cpp/src/Ice/UdpEndpoint.cpp @@ -38,44 +38,44 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& string::size_type beg; string::size_type end = 0; - while (true) + while(true) { beg = str.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } end = str.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } string option = str.substr(beg, end - beg); - if (option.length() != 2 || option[0] != '-') + if(option.length() != 2 || option[0] != '-') { throw EndpointParseException(__FILE__, __LINE__); } string argument; string::size_type argumentBeg = str.find_first_not_of(delim, end); - if (argumentBeg != string::npos && str[argumentBeg] != '-') + if(argumentBeg != string::npos && str[argumentBeg] != '-') { beg = argumentBeg; end = str.find_first_of(delim + ":", beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } argument = str.substr(beg, end - beg); } - switch (option[1]) + switch(option[1]) { case 'h': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -85,7 +85,7 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& case 'p': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -95,7 +95,7 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& case 'c': { - if (!argument.empty()) + if(!argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -110,7 +110,7 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& } } - if (_host.empty()) + if(_host.empty()) { const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost; } @@ -146,7 +146,7 @@ IceInternal::UdpEndpoint::toString() const { ostringstream s; s << "udp -h " << _host << " -p " << _port; - if (_connect) + if(_connect) { s << " -c"; } @@ -220,7 +220,7 @@ bool IceInternal::UdpEndpoint::equivalent(const TransceiverPtr& transceiver) const { const UdpTransceiver* udpTransceiver = dynamic_cast<const UdpTransceiver*>(transceiver.get()); - if (!udpTransceiver) + if(!udpTransceiver) { return false; } @@ -237,27 +237,27 @@ bool IceInternal::UdpEndpoint::operator==(const Endpoint& r) const { const UdpEndpoint* p = dynamic_cast<const UdpEndpoint*>(&r); - if (!p) + if(!p) { return false; } - if (this == p) + if(this == p) { return true; } - if (_port != p->_port) + if(_port != p->_port) { return false; } - if (_connect != p->_connect) + if(_connect != p->_connect) { return false; } - if (_host != p->_host) + if(_host != p->_host) { // // We do the most time-consuming part of the comparison last. @@ -282,35 +282,35 @@ bool IceInternal::UdpEndpoint::operator<(const Endpoint& r) const { const UdpEndpoint* p = dynamic_cast<const UdpEndpoint*>(&r); - if (!p) + if(!p) { return type() < r.type(); } - if (this == p) + if(this == p) { return false; } - if (_port < p->_port) + if(_port < p->_port) { return true; } - else if (p->_port < _port) + else if(p->_port < _port) { return false; } - if (!_connect && p->_connect) + if(!_connect && p->_connect) { return true; } - else if (!p->_connect && _connect) + else if(!p->_connect && _connect) { return false; } - if (_host != p->_host) + if(_host != p->_host) { // // We do the most time-consuming part of the comparison last. @@ -319,11 +319,11 @@ IceInternal::UdpEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host, _port, laddr); getAddress(p->_host, p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) + if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; } - else if (raddr.sin_addr.s_addr < laddr.sin_addr.s_addr) + else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr) { return false; } diff --git a/cpp/src/Ice/UdpEndpoint.h b/cpp/src/Ice/UdpEndpoint.h index 321b9214f9e..fe0d3233951 100644 --- a/cpp/src/Ice/UdpEndpoint.h +++ b/cpp/src/Ice/UdpEndpoint.h @@ -1,82 +1,82 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UDP_ENDPOINT_H -#define ICE_UDP_ENDPOINT_H - -#include <Ice/Endpoint.h> -#include <Ice/EndpointFactory.h> - -namespace IceInternal -{ - -const ::Ice::Short UdpEndpointType = 3; - -class UdpEndpoint : public Endpoint -{ -public: - - UdpEndpoint(const InstancePtr&, const std::string&, ::Ice::Int); - UdpEndpoint(const InstancePtr&, const std::string&); - UdpEndpoint(BasicStream*); - - virtual void streamWrite(BasicStream*) const; - virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual EndpointPtr timeout(::Ice::Int) const; - virtual bool datagram() const; - virtual bool secure() const; - virtual bool unknown() const; - virtual TransceiverPtr clientTransceiver() const; - virtual TransceiverPtr serverTransceiver(EndpointPtr&) const; - virtual ConnectorPtr connector() const; - virtual AcceptorPtr acceptor(EndpointPtr&) const; - virtual bool equivalent(const TransceiverPtr&) const; - virtual bool equivalent(const AcceptorPtr&) const; - - virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; - virtual bool operator<(const Endpoint&) const; - -private: - - // - // All members are const, because endpoints are immutable. - // - const InstancePtr _instance; - const std::string _host; - const ::Ice::Int _port; - const bool _connect; -}; - -class UdpEndpointFactory : public EndpointFactory -{ -public: - - virtual ~UdpEndpointFactory(); - - virtual ::Ice::Short type() const; - virtual const ::std::string& protocol() const; - virtual EndpointPtr create(const std::string&) const; - virtual EndpointPtr read(BasicStream*) const; - virtual void destroy(); - -private: - - UdpEndpointFactory(const InstancePtr&); - friend class Instance; - - InstancePtr _instance; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UDP_ENDPOINT_H
+#define ICE_UDP_ENDPOINT_H
+
+#include <Ice/Endpoint.h>
+#include <Ice/EndpointFactory.h>
+
+namespace IceInternal
+{
+
+const ::Ice::Short UdpEndpointType = 3;
+
+class UdpEndpoint : public Endpoint
+{
+public:
+
+ UdpEndpoint(const InstancePtr&, const std::string&, ::Ice::Int);
+ UdpEndpoint(const InstancePtr&, const std::string&);
+ UdpEndpoint(BasicStream*);
+
+ virtual void streamWrite(BasicStream*) const;
+ virtual std::string toString() const;
+ virtual ::Ice::Short type() const;
+ virtual ::Ice::Int timeout() const;
+ virtual EndpointPtr timeout(::Ice::Int) const;
+ virtual bool datagram() const;
+ virtual bool secure() const;
+ virtual bool unknown() const;
+ virtual TransceiverPtr clientTransceiver() const;
+ virtual TransceiverPtr serverTransceiver(EndpointPtr&) const;
+ virtual ConnectorPtr connector() const;
+ virtual AcceptorPtr acceptor(EndpointPtr&) const;
+ virtual bool equivalent(const TransceiverPtr&) const;
+ virtual bool equivalent(const AcceptorPtr&) const;
+
+ virtual bool operator==(const Endpoint&) const;
+ virtual bool operator!=(const Endpoint&) const;
+ virtual bool operator<(const Endpoint&) const;
+
+private:
+
+ //
+ // All members are const, because endpoints are immutable.
+ //
+ const InstancePtr _instance;
+ const std::string _host;
+ const ::Ice::Int _port;
+ const bool _connect;
+};
+
+class UdpEndpointFactory : public EndpointFactory
+{
+public:
+
+ virtual ~UdpEndpointFactory();
+
+ virtual ::Ice::Short type() const;
+ virtual const ::std::string& protocol() const;
+ virtual EndpointPtr create(const std::string&) const;
+ virtual EndpointPtr read(BasicStream*) const;
+ virtual void destroy();
+
+private:
+
+ UdpEndpointFactory(const InstancePtr&);
+ friend class Instance;
+
+ InstancePtr _instance;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index c62a75f11a2..5ccc6c5d333 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -29,7 +29,7 @@ IceInternal::UdpTransceiver::fd() void IceInternal::UdpTransceiver::close() { - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "closing " << _protocolName << " connection\n" << toString(); @@ -57,26 +57,26 @@ IceInternal::UdpTransceiver::write(Buffer& buf, int) repeat: int ret = ::send(_fd, &buf.b[0], buf.b.size(), 0); - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeat; } - if (wouldBlock()) + if(wouldBlock()) { SOCKET fd = _fd; // Copy fd, in case another thread calls close() - if (fd != INVALID_SOCKET) + if(fd != INVALID_SOCKET) { repeatSelect: FD_SET(fd, &_wFdSet); int ret = ::select(fd + 1, 0, &_wFdSet, 0, 0); - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -95,7 +95,7 @@ repeat: throw ex; } - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { Trace out(_logger, _traceLevels->networkCat); out << "sent " << ret << " bytes via " << _protocolName << "\n" << toString(); @@ -116,7 +116,7 @@ IceInternal::UdpTransceiver::read(Buffer& buf, int) repeat: int ret; - if (_connect) + if(_connect) { // // If we must connect, then we connect to the first peer that @@ -126,12 +126,12 @@ repeat: memset(&peerAddr, 0, sizeof(struct sockaddr_in)); socklen_t len = sizeof(peerAddr); ret = recvfrom(_fd, &buf.b[0], packetSize, 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len); - if (ret != SOCKET_ERROR) + if(ret != SOCKET_ERROR) { doConnect(_fd, peerAddr, -1); _connect = false; // We're connected now - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "connected " << _protocolName << " socket\n" << toString(); @@ -143,26 +143,26 @@ repeat: ret = ::recv(_fd, &buf.b[0], packetSize, 0); } - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeat; } - if (wouldBlock()) + if(wouldBlock()) { SOCKET fd = _fd; // Copy fd, in case another thread calls close() - if (fd != INVALID_SOCKET) + if(fd != INVALID_SOCKET) { repeatSelect: FD_SET(fd, &_rFdSet); int ret = ::select(fd + 1, &_rFdSet, 0, 0, 0); - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { - if (interrupted()) + if(interrupted()) { goto repeatSelect; } @@ -181,7 +181,7 @@ repeat: throw ex; } - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { Trace out(_logger, _traceLevels->networkCat); out << "received " << ret << " bytes via " << _protocolName << "\n" << toString(); @@ -234,7 +234,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s doConnect(_fd, _addr, -1); _connect = false; // We're connected now - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "starting to send " << _protocolName << " packets\n" << toString(); @@ -266,7 +266,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s getAddress(host, port, _addr); doBind(_fd, _addr); - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { Trace out(_logger, _traceLevels->networkCat); out << "starting to receive " << _protocolName << " packets\n" << toString(); diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index 5a979dc9ac1..215f8a6bc74 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -1,69 +1,69 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UDP_TRANSCEIVER_H -#define ICE_UDP_TRANSCEIVER_H - -#include <Ice/InstanceF.h> -#include <Ice/TraceLevelsF.h> -#include <Ice/LoggerF.h> -#include <Ice/Transceiver.h> - -#ifndef _WIN32 -# include <netinet/in.h> // For struct sockaddr_in -#endif - -namespace IceInternal -{ - -class UdpEndpoint; - -class SUdpTransceiver; - -class UdpTransceiver : public Transceiver -{ -public: - - virtual SOCKET fd(); - virtual void close(); - virtual void shutdown(); - virtual void write(Buffer&, int); - virtual void read(Buffer&, int); - virtual std::string toString() const; - - bool equivalent(const std::string&, int) const; - int effectivePort(); - void setProtocolName(const std::string&); - -private: - - UdpTransceiver(const InstancePtr&, const std::string&, int, const std::string& protocolName = "udp"); - UdpTransceiver(const InstancePtr&, const std::string&, int, bool, const std::string& protocolName = "udp"); - virtual ~UdpTransceiver(); - - friend class UdpEndpoint; -// friend class SUdpEndpoint; // TODO: Remove as soon as SUdpEndpoint uses SUdpTransceiver. -// friend class SUdpTransceiver; - - InstancePtr _instance; - TraceLevelsPtr _traceLevels; - ::Ice::LoggerPtr _logger; - bool _incoming; - bool _connect; - SOCKET _fd; - struct sockaddr_in _addr; - fd_set _rFdSet; - fd_set _wFdSet; - std::string _protocolName; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UDP_TRANSCEIVER_H
+#define ICE_UDP_TRANSCEIVER_H
+
+#include <Ice/InstanceF.h>
+#include <Ice/TraceLevelsF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/Transceiver.h>
+
+#ifndef _WIN32
+# include <netinet/in.h> // For struct sockaddr_in
+#endif
+
+namespace IceInternal
+{
+
+class UdpEndpoint;
+
+class SUdpTransceiver;
+
+class UdpTransceiver : public Transceiver
+{
+public:
+
+ virtual SOCKET fd();
+ virtual void close();
+ virtual void shutdown();
+ virtual void write(Buffer&, int);
+ virtual void read(Buffer&, int);
+ virtual std::string toString() const;
+
+ bool equivalent(const std::string&, int) const;
+ int effectivePort();
+ void setProtocolName(const std::string&);
+
+private:
+
+ UdpTransceiver(const InstancePtr&, const std::string&, int, const std::string& protocolName = "udp");
+ UdpTransceiver(const InstancePtr&, const std::string&, int, bool, const std::string& protocolName = "udp");
+ virtual ~UdpTransceiver();
+
+ friend class UdpEndpoint;
+// friend class SUdpEndpoint; // TODO: Remove as soon as SUdpEndpoint uses SUdpTransceiver.
+// friend class SUdpTransceiver;
+
+ InstancePtr _instance;
+ TraceLevelsPtr _traceLevels;
+ ::Ice::LoggerPtr _logger;
+ bool _incoming;
+ bool _connect;
+ SOCKET _fd;
+ struct sockaddr_in _addr;
+ fd_set _rFdSet;
+ fd_set _wFdSet;
+ std::string _protocolName;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/UnknownEndpoint.cpp b/cpp/src/Ice/UnknownEndpoint.cpp index 76c4cc3c690..f7c8cf5f57f 100644 --- a/cpp/src/Ice/UnknownEndpoint.cpp +++ b/cpp/src/Ice/UnknownEndpoint.cpp @@ -120,22 +120,22 @@ bool IceInternal::UnknownEndpoint::operator==(const Endpoint& r) const { const UnknownEndpoint* p = dynamic_cast<const UnknownEndpoint*>(&r); - if (!p) + if(!p) { return false; } - if (this == p) + if(this == p) { return true; } - if (_type != p->_type) + if(_type != p->_type) { return false; } - if (_rawBytes != p->_rawBytes) + if(_rawBytes != p->_rawBytes) { return false; } @@ -153,30 +153,30 @@ bool IceInternal::UnknownEndpoint::operator<(const Endpoint& r) const { const UnknownEndpoint* p = dynamic_cast<const UnknownEndpoint*>(&r); - if (!p) + if(!p) { return type() < r.type(); } - if (this == p) + if(this == p) { return false; } - if (_type < p->_type) + if(_type < p->_type) { return true; } - else if (p->_type < _type) + else if(p->_type < _type) { return false; } - if (_rawBytes < p->_rawBytes) + if(_rawBytes < p->_rawBytes) { return true; } - else if (p->_rawBytes < _rawBytes) + else if(p->_rawBytes < _rawBytes) { return false; } diff --git a/cpp/src/Ice/UnknownEndpoint.h b/cpp/src/Ice/UnknownEndpoint.h index 17ea13a7320..ed48fde8fb6 100644 --- a/cpp/src/Ice/UnknownEndpoint.h +++ b/cpp/src/Ice/UnknownEndpoint.h @@ -1,59 +1,59 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_UNKNOWN_ENDPOINT_H -#define ICE_UNKNOWN_ENDPOINT_H - -#include <Ice/Endpoint.h> -#include <Ice/EndpointFactory.h> - -namespace IceInternal -{ - -const ::Ice::Short UnknownEndpointType = 0; - -class UnknownEndpoint : public Endpoint -{ -public: - - UnknownEndpoint(::Ice::Short, BasicStream*); - - virtual void streamWrite(BasicStream*) const; - virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual EndpointPtr timeout(::Ice::Int) const; - virtual bool datagram() const; - virtual bool secure() const; - virtual bool unknown() const; - virtual TransceiverPtr clientTransceiver() const; - virtual TransceiverPtr serverTransceiver(EndpointPtr&) const; - virtual ConnectorPtr connector() const; - virtual AcceptorPtr acceptor(EndpointPtr&) const; - virtual bool equivalent(const TransceiverPtr&) const; - virtual bool equivalent(const AcceptorPtr&) const; - - virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; - virtual bool operator<(const Endpoint&) const; - -private: - - // - // All members are const, because endpoints are immutable. - // - const InstancePtr _instance; - ::Ice::Short _type; - const std::vector< ::Ice::Byte> _rawBytes; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_UNKNOWN_ENDPOINT_H
+#define ICE_UNKNOWN_ENDPOINT_H
+
+#include <Ice/Endpoint.h>
+#include <Ice/EndpointFactory.h>
+
+namespace IceInternal
+{
+
+const ::Ice::Short UnknownEndpointType = 0;
+
+class UnknownEndpoint : public Endpoint
+{
+public:
+
+ UnknownEndpoint(::Ice::Short, BasicStream*);
+
+ virtual void streamWrite(BasicStream*) const;
+ virtual std::string toString() const;
+ virtual ::Ice::Short type() const;
+ virtual ::Ice::Int timeout() const;
+ virtual EndpointPtr timeout(::Ice::Int) const;
+ virtual bool datagram() const;
+ virtual bool secure() const;
+ virtual bool unknown() const;
+ virtual TransceiverPtr clientTransceiver() const;
+ virtual TransceiverPtr serverTransceiver(EndpointPtr&) const;
+ virtual ConnectorPtr connector() const;
+ virtual AcceptorPtr acceptor(EndpointPtr&) const;
+ virtual bool equivalent(const TransceiverPtr&) const;
+ virtual bool equivalent(const AcceptorPtr&) const;
+
+ virtual bool operator==(const Endpoint&) const;
+ virtual bool operator!=(const Endpoint&) const;
+ virtual bool operator<(const Endpoint&) const;
+
+private:
+
+ //
+ // All members are const, because endpoints are immutable.
+ //
+ const InstancePtr _instance;
+ ::Ice::Short _type;
+ const std::vector< ::Ice::Byte> _rawBytes;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/UserExceptionFactoryManager.cpp b/cpp/src/Ice/UserExceptionFactoryManager.cpp index b47500ebacf..272ec1dcde0 100644 --- a/cpp/src/Ice/UserExceptionFactoryManager.cpp +++ b/cpp/src/Ice/UserExceptionFactoryManager.cpp @@ -33,24 +33,24 @@ IceInternal::UserExceptionFactoryManager::remove(const string& id) map<string, ::Ice::UserExceptionFactoryPtr>::iterator p = _factoryMap.end(); - if (_factoryMapHint != _factoryMap.end()) + if(_factoryMapHint != _factoryMap.end()) { - if (_factoryMapHint->first == id) + if(_factoryMapHint->first == id) { p = _factoryMapHint; } } - if (p == _factoryMap.end()) + if(p == _factoryMap.end()) { p = _factoryMap.find(id); } - if (p != _factoryMap.end()) + if(p != _factoryMap.end()) { p->second->destroy(); - if (p == _factoryMapHint) + if(p == _factoryMapHint) { _factoryMap.erase(p++); _factoryMapHint = p; @@ -69,20 +69,20 @@ IceInternal::UserExceptionFactoryManager::find(const string& id) map<string, ::Ice::UserExceptionFactoryPtr>::iterator p = _factoryMap.end(); - if (_factoryMapHint != _factoryMap.end()) + if(_factoryMapHint != _factoryMap.end()) { - if (_factoryMapHint->first == id) + if(_factoryMapHint->first == id) { p = _factoryMapHint; } } - if (p == _factoryMap.end()) + if(p == _factoryMap.end()) { p = _factoryMap.find(id); } - if (p != _factoryMap.end()) + if(p != _factoryMap.end()) { _factoryMapHint = p; return p->second; diff --git a/cpp/src/Ice/UserExceptionFactoryManager.h b/cpp/src/Ice/UserExceptionFactoryManager.h index 8c59c847549..a213272df31 100644 --- a/cpp/src/Ice/UserExceptionFactoryManager.h +++ b/cpp/src/Ice/UserExceptionFactoryManager.h @@ -1,42 +1,42 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_USER_EXCEPTION_FACTORY_MANAGER_H -#define ICE_USER_EXCEPTION_FACTORY_MANAGER_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Mutex.h> -#include <Ice/UserExceptionFactoryManagerF.h> -#include <Ice/UserExceptionFactoryF.h> - -namespace IceInternal -{ - -class UserExceptionFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex -{ -public: - - void add(const ::Ice::UserExceptionFactoryPtr&, const std::string&); - void remove(const std::string&); - ::Ice::UserExceptionFactoryPtr find(const std::string&); - -private: - - UserExceptionFactoryManager(); - void destroy(); - friend class Instance; - - std::map<std::string, ::Ice::UserExceptionFactoryPtr> _factoryMap; - std::map<std::string, ::Ice::UserExceptionFactoryPtr>::iterator _factoryMapHint; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_USER_EXCEPTION_FACTORY_MANAGER_H
+#define ICE_USER_EXCEPTION_FACTORY_MANAGER_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <Ice/UserExceptionFactoryManagerF.h>
+#include <Ice/UserExceptionFactoryF.h>
+
+namespace IceInternal
+{
+
+class UserExceptionFactoryManager : public ::IceUtil::Shared, public ::IceUtil::Mutex
+{
+public:
+
+ void add(const ::Ice::UserExceptionFactoryPtr&, const std::string&);
+ void remove(const std::string&);
+ ::Ice::UserExceptionFactoryPtr find(const std::string&);
+
+private:
+
+ UserExceptionFactoryManager();
+ void destroy();
+ friend class Instance;
+
+ std::map<std::string, ::Ice::UserExceptionFactoryPtr> _factoryMap;
+ std::map<std::string, ::Ice::UserExceptionFactoryPtr>::iterator _factoryMapHint;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Ice/UserExceptionFactoryManagerF.h b/cpp/src/Ice/UserExceptionFactoryManagerF.h index 9f4bb2deac8..5640d639ec9 100644 --- a/cpp/src/Ice/UserExceptionFactoryManagerF.h +++ b/cpp/src/Ice/UserExceptionFactoryManagerF.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_USER_EXCEPTION_FACTORY_MANAGER_F_H -#define ICE_USER_EXCEPTION_FACTORY_MANAGER_F_H - -#include <Ice/Handle.h> - -namespace IceInternal -{ - -class UserExceptionFactoryManager; -void incRef(UserExceptionFactoryManager*); -void decRef(UserExceptionFactoryManager*); -typedef IceInternal::Handle<UserExceptionFactoryManager> UserExceptionFactoryManagerPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_USER_EXCEPTION_FACTORY_MANAGER_F_H
+#define ICE_USER_EXCEPTION_FACTORY_MANAGER_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class UserExceptionFactoryManager;
+void incRef(UserExceptionFactoryManager*);
+void decRef(UserExceptionFactoryManager*);
+typedef IceInternal::Handle<UserExceptionFactoryManager> UserExceptionFactoryManagerPtr;
+
+}
+
+#endif
diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp index 6269444b63b..0f526f2b594 100644 --- a/cpp/src/IceBox/Admin.cpp +++ b/cpp/src/IceBox/Admin.cpp @@ -57,19 +57,19 @@ Client::run(int argc, char* argv[]) vector<string> commands; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << appName() << ": unknown option `" << argv[idx] << "'" << endl; usage(); @@ -82,7 +82,7 @@ Client::run(int argc, char* argv[]) } } - if (commands.empty()) + if(commands.empty()) { usage(); return EXIT_SUCCESS; @@ -90,7 +90,7 @@ Client::run(int argc, char* argv[]) const char* managerEndpointsProperty = "IceBox.ServiceManager.Endpoints"; string managerEndpoints = properties->getProperty(managerEndpointsProperty); - if (managerEndpoints.empty()) + if(managerEndpoints.empty()) { cerr << appName() << ": property `" << managerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -98,16 +98,16 @@ Client::run(int argc, char* argv[]) ObjectPrx base = communicator()->stringToProxy("ServiceManager:" + managerEndpoints); IceBox::ServiceManagerPrx manager = IceBox::ServiceManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << appName() << ": `" << managerEndpoints << "' is not running" << endl; return EXIT_FAILURE; } vector<string>::const_iterator r; - for (r = commands.begin(); r != commands.end(); ++r) + for(r = commands.begin(); r != commands.end(); ++r) { - if ((*r) == "shutdown") + if((*r) == "shutdown") { manager->shutdown(); } diff --git a/cpp/src/IceBox/Server.cpp b/cpp/src/IceBox/Server.cpp index 6e3129d1969..032964a3627 100644 --- a/cpp/src/IceBox/Server.cpp +++ b/cpp/src/IceBox/Server.cpp @@ -42,19 +42,19 @@ main(int argc, char* argv[]) args = properties->parseCommandLineOptions("IceBox", args); stringSeqToArgs(args, argc, argv); - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strncmp(argv[i], "--", 2) != 0) + else if(strncmp(argv[i], "--", 2) != 0) { cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; usage(argv[0]); @@ -72,7 +72,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 428b65beb80..6139bbb81d0 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -23,12 +23,12 @@ IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc { _logger = _communicator->getLogger(); - if (argc > 0) + if(argc > 0) { _progName = argv[0]; } - for (int i = 1; i < argc; i++) + for(int i = 1; i < argc; i++) { _argv.push_back(argv[i]); } @@ -74,7 +74,7 @@ IceBox::ServiceManagerI::run() PropertiesPtr properties = _communicator->getProperties(); PropertyDict services = properties->getPropertiesForPrefix(prefix); PropertyDict::const_iterator p; - for (p = services.begin(); p != services.end(); ++p) + for(p = services.begin(); p != services.end(); ++p) { string name = p->first.substr(prefix.size()); const string& value = p->second; @@ -85,7 +85,7 @@ IceBox::ServiceManagerI::run() string entryPoint; StringSeq args; string::size_type pos = value.find_first_of(" \t\n"); - if (pos == string::npos) + if(pos == string::npos) { entryPoint = value; } @@ -93,10 +93,10 @@ IceBox::ServiceManagerI::run() { entryPoint = value.substr(0, pos); string::size_type beg = value.find_first_not_of(" \t\n", pos); - while (beg != string::npos) + while(beg != string::npos) { string::size_type end = value.find_first_of(" \t\n", beg); - if (end == string::npos) + if(end == string::npos) { args.push_back(value.substr(beg)); beg = end; @@ -116,7 +116,7 @@ IceBox::ServiceManagerI::run() // Invoke start() on the services. // map<string,ServiceInfo>::const_iterator r; - for (r = _services.begin(); r != _services.end(); ++r) + for(r = _services.begin(); r != _services.end(); ++r) { try { @@ -147,7 +147,7 @@ IceBox::ServiceManagerI::run() // services. // string bundleName = properties->getProperty("IceBox.PrintServicesReady"); - if (!bundleName.empty()) + if(!bundleName.empty()) { cout << bundleName << " ready" << endl; } @@ -199,20 +199,20 @@ IceBox::ServiceManagerI::init(const string& service, const string& entryPoint, c // StringSeq serviceArgs; StringSeq::size_type j; - for (j = 0; j < _options.size(); j++) + for(j = 0; j < _options.size(); j++) { - if (_options[j].find("--" + service + ".") == 0) + if(_options[j].find("--" + service + ".") == 0) { serviceArgs.push_back(_options[j]); } } - for (j = 0; j < args.size(); j++) + for(j = 0; j < args.size(); j++) { serviceArgs.push_back(args[j]); } - for (j = 0; j < _argv.size(); j++) + for(j = 0; j < _argv.size(); j++) { - if (_argv[j].find("--" + service + ".") == 0) + if(_argv[j].find("--" + service + ".") == 0) { serviceArgs.push_back(_argv[j]); } @@ -230,12 +230,12 @@ IceBox::ServiceManagerI::init(const string& service, const string& entryPoint, c // DynamicLibraryPtr library = new DynamicLibrary(); DynamicLibrary::symbol_type sym = library->loadEntryPoint(entryPoint); - if (sym == 0) + if(sym == 0) { string msg = library->getErrorMessage(); FailureException ex; ex.reason = "ServiceManager: unable to load entry point `" + entryPoint + "'"; - if (!msg.empty()) + if(!msg.empty()) { ex.reason += ": " + msg; } @@ -323,7 +323,7 @@ void IceBox::ServiceManagerI::stopAll() { map<string,ServiceInfo>::const_iterator r = _services.begin(); - while (r != _services.end()) + while(r != _services.end()) { try { diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h index cbfa5edd8b7..00a6de8a7b8 100644 --- a/cpp/src/IceBox/ServiceManagerI.h +++ b/cpp/src/IceBox/ServiceManagerI.h @@ -1,56 +1,56 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SERVICE_MANAGER_I_H -#define SERVICE_MANAGER_I_H - -#include <IceBox/IceBox.h> -#include <Ice/LoggerF.h> -#include <Ice/CommunicatorF.h> -#include <Ice/DynamicLibraryF.h> -#include <map> - -namespace IceBox -{ - -class ServiceManagerI : public ServiceManager -{ -public: - - ServiceManagerI(::Ice::CommunicatorPtr, int&, char*[]); - virtual ~ServiceManagerI(); - - virtual void shutdown(const ::Ice::Current&); - - int run(); - - struct ServiceInfo - { - ServicePtr service; - ::IceInternal::DynamicLibraryPtr library; - }; - -private: - - ServicePtr init(const std::string&, const std::string&, const ::Ice::StringSeq&); - void stop(const std::string&); - void stopAll(); - - ::Ice::CommunicatorPtr _communicator; - ::Ice::LoggerPtr _logger; - std::string _progName; // argv[0] - ::Ice::StringSeq _argv; // Filtered server argument vector, not including program name - ::Ice::StringSeq _options; // Server property set converted to command-line options - std::map<std::string, ServiceInfo> _services; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SERVICE_MANAGER_I_H
+#define SERVICE_MANAGER_I_H
+
+#include <IceBox/IceBox.h>
+#include <Ice/LoggerF.h>
+#include <Ice/CommunicatorF.h>
+#include <Ice/DynamicLibraryF.h>
+#include <map>
+
+namespace IceBox
+{
+
+class ServiceManagerI : public ServiceManager
+{
+public:
+
+ ServiceManagerI(::Ice::CommunicatorPtr, int&, char*[]);
+ virtual ~ServiceManagerI();
+
+ virtual void shutdown(const ::Ice::Current&);
+
+ int run();
+
+ struct ServiceInfo
+ {
+ ServicePtr service;
+ ::IceInternal::DynamicLibraryPtr library;
+ };
+
+private:
+
+ ServicePtr init(const std::string&, const std::string&, const ::Ice::StringSeq&);
+ void stop(const std::string&);
+ void stopAll();
+
+ ::Ice::CommunicatorPtr _communicator;
+ ::Ice::LoggerPtr _logger;
+ std::string _progName; // argv[0]
+ ::Ice::StringSeq _argv; // Filtered server argument vector, not including program name
+ ::Ice::StringSeq _options; // Server property set converted to command-line options
+ std::map<std::string, ServiceInfo> _services;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp index 821755e3821..0e80a0eeeaf 100644 --- a/cpp/src/IcePack/Activator.cpp +++ b/cpp/src/IcePack/Activator.cpp @@ -26,7 +26,7 @@ IcePack::Activator::Activator(const CommunicatorPtr& communicator) : _destroy(false) { int fds[2]; - if (pipe(fds) != 0) + if(pipe(fds) != 0) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -44,7 +44,7 @@ IcePack::Activator::~Activator() assert(_destroy); close(_fdIntrRead); close(_fdIntrWrite); - for (map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p) + for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p) { close(p->second.fd); } @@ -74,7 +74,7 @@ IcePack::Activator::destroy() { IceUtil::Mutex::Lock sync(*this); - if (_destroy) // Don't destroy twice. + if(_destroy) // Don't destroy twice. { return; } @@ -88,13 +88,13 @@ IcePack::Activator::activate(const ServerDescription& desc) { IceUtil::Mutex::Lock sync(*this); - if (_destroy) + if(_destroy) { return false; } string path = desc.path; - if (path.empty()) + if(path.empty()) { return false; } @@ -103,11 +103,11 @@ IcePack::Activator::activate(const ServerDescription& desc) // Normalize the pathname a bit. // string::size_type pos; - while ((pos = path.find("//")) != string::npos) + while((pos = path.find("//")) != string::npos) { path.erase(pos, 1); } - while ((pos = path.find("/./")) != string::npos) + while((pos = path.find("/./")) != string::npos) { path.erase(pos, 2); } @@ -115,7 +115,7 @@ IcePack::Activator::activate(const ServerDescription& desc) // // Do nothing if the process exists. // - if (_processes.count(path)) + if(_processes.count(path)) { return false; } @@ -124,20 +124,20 @@ IcePack::Activator::activate(const ServerDescription& desc) // Process does not exist, activate and create. // int fds[2]; - if (pipe(fds) != 0) + if(pipe(fds) != 0) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); throw ex; } pid_t pid = fork(); - if (pid == -1) + if(pid == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); throw ex; } - if (pid == 0) // Child process. + if(pid == 0) // Child process. { // // Close all filedescriptors, except for standard input, @@ -145,9 +145,9 @@ IcePack::Activator::activate(const ServerDescription& desc) // of the newly created pipe. // int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX)); - for (int fd = 3; fd < maxFd; ++fd) + for(int fd = 3; fd < maxFd; ++fd) { - if (fd != fds[1]) + if(fd != fds[1]) { close(fd); } @@ -156,13 +156,13 @@ IcePack::Activator::activate(const ServerDescription& desc) int argc = desc.args.size() + 2; char** argv = static_cast<char**>(malloc(argc * sizeof(char*))); argv[0] = strdup(path.c_str()); - for (unsigned int i = 0; i < desc.args.size(); ++i) + for(unsigned int i = 0; i < desc.args.size(); ++i) { argv[i + 1] = strdup(desc.args[i].c_str()); } argv[argc - 1] = 0; - if (execvp(argv[0], argv) == -1) + if(execvp(argv[0], argv) == -1) { // // Send any errors to the parent process, using the write @@ -199,7 +199,7 @@ IcePack::Activator::activate(const ServerDescription& desc) void IcePack::Activator::terminationListener() { - while (true) + while(true) { fd_set fdSet; int maxFd = _fdIntrRead; @@ -209,16 +209,16 @@ IcePack::Activator::terminationListener() { IceUtil::Mutex::Lock sync(*this); - if (_destroy) + if(_destroy) { return; } - for (map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p) + for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p) { int fd = p->second.fd; FD_SET(fd, &fdSet); - if (maxFd < fd) + if(maxFd < fd) { maxFd = fd; } @@ -229,9 +229,9 @@ IcePack::Activator::terminationListener() int ret = ::select(maxFd + 1, &fdSet, 0, 0, 0); assert(ret != 0); - if (ret == -1) + if(ret == -1) { - if (errno == EINTR || errno == EPROTO) + if(errno == EINTR || errno == EPROTO) { goto repeatSelect; } @@ -244,25 +244,25 @@ IcePack::Activator::terminationListener() { IceUtil::Mutex::Lock sync(*this); - if (FD_ISSET(_fdIntrRead, &fdSet)) + if(FD_ISSET(_fdIntrRead, &fdSet)) { clearInterrupt(); } - if (_destroy) + if(_destroy) { return; } map<string, Process>::iterator p = _processes.begin(); - while (p != _processes.end()) + while(p != _processes.end()) { int fd = p->second.fd; - if (FD_ISSET(fd, &fdSet)) + if(FD_ISSET(fd, &fdSet)) { char s[16]; int ret = read(fd, &s, 16); - if (ret == -1) + if(ret == -1) { SystemException ex(__FILE__, __LINE__); ex.error = getSystemErrno(); @@ -292,7 +292,7 @@ IcePack::Activator::terminationListener() err.append(s, ret); ret = read(fd, &s, 16); } - while (ret != 0); + while(ret != 0); Error out(_communicator->getLogger()); out << err; @@ -311,7 +311,7 @@ void IcePack::Activator::clearInterrupt() { char s[32]; // Clear up to 32 interrupts at once. - while (read(_fdIntrRead, s, 32) == 32) + while(read(_fdIntrRead, s, 32) == 32) { } } diff --git a/cpp/src/IcePack/Activator.h b/cpp/src/IcePack/Activator.h index c5bb6943c1b..764d3f85839 100644 --- a/cpp/src/IcePack/Activator.h +++ b/cpp/src/IcePack/Activator.h @@ -1,55 +1,55 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PACK_ACTIVATOR_H -#define ICE_PACK_ACTIVATOR_H - -#include <IceUtil/Thread.h> - -namespace IcePack -{ - -struct ServerDescription; - -class Activator : public IceUtil::Thread, public IceUtil::Mutex -{ -public: - - Activator(const Ice::CommunicatorPtr&); - virtual ~Activator(); - - virtual void run(); - void destroy(); - bool activate(const IcePack::ServerDescription&); - -private: - - void terminationListener(); - void clearInterrupt(); - void setInterrupt(); - - struct Process - { - pid_t pid; - int fd; - }; - - Ice::CommunicatorPtr _communicator; - std::map<std::string, Process> _processes; - bool _destroy; - int _fdIntrRead; - int _fdIntrWrite; -}; - -typedef IceUtil::Handle<Activator> ActivatorPtr; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PACK_ACTIVATOR_H
+#define ICE_PACK_ACTIVATOR_H
+
+#include <IceUtil/Thread.h>
+
+namespace IcePack
+{
+
+struct ServerDescription;
+
+class Activator : public IceUtil::Thread, public IceUtil::Mutex
+{
+public:
+
+ Activator(const Ice::CommunicatorPtr&);
+ virtual ~Activator();
+
+ virtual void run();
+ void destroy();
+ bool activate(const IcePack::ServerDescription&);
+
+private:
+
+ void terminationListener();
+ void clearInterrupt();
+ void setInterrupt();
+
+ struct Process
+ {
+ pid_t pid;
+ int fd;
+ };
+
+ Ice::CommunicatorPtr _communicator;
+ std::map<std::string, Process> _processes;
+ bool _destroy;
+ int _fdIntrRead;
+ int _fdIntrWrite;
+};
+
+typedef IceUtil::Handle<Activator> ActivatorPtr;
+
+}
+
+#endif
diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp index 5d35a30e3ba..c5b4e21713f 100644 --- a/cpp/src/IcePack/AdminI.cpp +++ b/cpp/src/IcePack/AdminI.cpp @@ -25,7 +25,7 @@ IcePack::AdminI::add(const ServerDescription& desc, const Ice::Current&) { IceUtil::Mutex::Lock sync(*this); - if (desc.object) + if(desc.object) { _serverDescriptions[desc.object->ice_getIdentity()] = desc; } @@ -44,7 +44,7 @@ IcePack::AdminI::find(const Identity& ident, const Ice::Current&) IceUtil::Mutex::Lock sync(*this); ServerDescriptions::iterator p = _serverDescriptions.find(ident); - if (p != _serverDescriptions.end()) + if(p != _serverDescriptions.end()) { return p->second; } diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h index 6c000d2cbcc..92d9c3e0fd8 100644 --- a/cpp/src/IcePack/AdminI.h +++ b/cpp/src/IcePack/AdminI.h @@ -1,38 +1,38 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PACK_ADMIN_I_H -#define ICE_PACK_ADMIN_I_H - -#include <IcePack/Admin.h> - -namespace IcePack -{ - -class AdminI : public Admin, public IceUtil::Mutex -{ -public: - - AdminI(const Ice::CommunicatorPtr&); - - virtual void add(const ServerDescription&, const Ice::Current&); - virtual void remove(const Ice::Identity&, const Ice::Current&); - virtual ServerDescription find(const Ice::Identity&, const Ice::Current&); - virtual ServerDescriptions getAll(const Ice::Current&); - virtual void shutdown(const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PACK_ADMIN_I_H
+#define ICE_PACK_ADMIN_I_H
+
+#include <IcePack/Admin.h>
+
+namespace IcePack
+{
+
+class AdminI : public Admin, public IceUtil::Mutex
+{
+public:
+
+ AdminI(const Ice::CommunicatorPtr&);
+
+ virtual void add(const ServerDescription&, const Ice::Current&);
+ virtual void remove(const Ice::Identity&, const Ice::Current&);
+ virtual ServerDescription find(const Ice::Identity&, const Ice::Current&);
+ virtual ServerDescriptions getAll(const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IcePack/Client.cpp b/cpp/src/IcePack/Client.cpp index 0d468109d10..fe379cae26e 100644 --- a/cpp/src/IcePack/Client.cpp +++ b/cpp/src/IcePack/Client.cpp @@ -62,43 +62,43 @@ Client::run(int argc, char* argv[]) stringSeqToArgs(args, argc, argv); int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-e") == 0) + else if(strcmp(argv[idx], "-e") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << appName() << ": argument expected for`" << argv[idx] << "'" << endl; usage(); @@ -108,22 +108,22 @@ Client::run(int argc, char* argv[]) commands += argv[idx + 1]; commands += ';'; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << appName() << ": unknown option `" << argv[idx] << "'" << endl; usage(); @@ -135,7 +135,7 @@ Client::run(int argc, char* argv[]) } } - if (argc >= 2 && !commands.empty()) + if(argc >= 2 && !commands.empty()) { cerr << appName() << ": `-e' option cannot be used if input files are given" << endl; usage(); @@ -144,7 +144,7 @@ Client::run(int argc, char* argv[]) const char* adminEndpointsProperty = "IcePack.Admin.Endpoints"; string adminEndpoints = properties->getProperty(adminEndpointsProperty); - if (adminEndpoints.empty()) + if(adminEndpoints.empty()) { cerr << appName() << ": property `" << adminEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -152,7 +152,7 @@ Client::run(int argc, char* argv[]) Ice::ObjectPrx base = communicator()->stringToProxy("admin:" + adminEndpoints); AdminPrx admin = AdminPrx::checkedCast(base); - if (!admin) + if(!admin) { cerr << appName() << ": `" << adminEndpoints << "' are no valid administrative endpoints" << endl; return EXIT_FAILURE; @@ -161,12 +161,12 @@ Client::run(int argc, char* argv[]) ParserPtr parser = Parser::createParser(communicator(), admin); int status = EXIT_SUCCESS; - if (argc < 2) // No files given + if(argc < 2) // No files given { - if (!commands.empty()) // Commands were given + if(!commands.empty()) // Commands were given { int parseStatus = parser->parse(commands, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -174,7 +174,7 @@ Client::run(int argc, char* argv[]) else // No commands, let's use standard input { int parseStatus = parser->parse(stdin, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -182,10 +182,10 @@ Client::run(int argc, char* argv[]) } else // Process files given on the command line { - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << appName() << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -198,7 +198,7 @@ Client::run(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == NULL) + if(cppHandle == NULL) { cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -212,7 +212,7 @@ Client::run(int argc, char* argv[]) pclose(cppHandle); #endif - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index 008b1b605db..e55f4b64f45 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -25,7 +25,7 @@ IcePack::Forward::Forward(const CommunicatorPtr& communicator, const AdminPtr& a _activator->start(); _waitTime = _communicator->getProperties()->getPropertyAsIntWithDefault("IcePack.Activator.WaitTime", 10); - if (_waitTime < 0) + if(_waitTime < 0) { _waitTime = 0; } @@ -48,7 +48,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const Current& current // If we didn't find a server description, we return null, meaning // that the client will get an "object not exist" exception. // - if (!desc.object) + if(!desc.object) { return 0; } @@ -60,13 +60,13 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const Current& current // // We only try to activate if we have a path for the server // - if (!desc.path.empty()) + if(!desc.path.empty()) { try { bool doSleep = false; int count = 0; - while (true) + while(true) { try { @@ -74,7 +74,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const Current& current // Activate the server. If the server is already // running, this operation does nothing. // - if (_activator->activate(desc)) + if(_activator->activate(desc)) { // // If we just activated the server, we sleep @@ -84,7 +84,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const Current& current doSleep = true; } - if (doSleep) + if(doSleep) { sleep(1); } @@ -120,7 +120,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const Current& current // to give the server more time before we try // again. // - if (++count >= _waitTime) + if(++count >= _waitTime) { throw; } diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h index ac2f2646238..3c73b5f10d3 100644 --- a/cpp/src/IcePack/Forward.h +++ b/cpp/src/IcePack/Forward.h @@ -1,46 +1,46 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PACK_FORWARD_H -#define ICE_PACK_FORWARD_H - -#include <IcePack/AdminF.h> -#ifndef _WIN32 -# include <IcePack/Activator.h> -#endif - -namespace IcePack -{ - -class Forward : public Ice::ServantLocator -{ -public: - - Forward(const Ice::CommunicatorPtr& communicator, const AdminPtr&); - virtual ~Forward(); - - virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const Ice::Current&, Ice::LocalObjectPtr&); - virtual void finished(const Ice::ObjectAdapterPtr&, const Ice::Current&, - const Ice::ObjectPtr&, const Ice::LocalObjectPtr&); - virtual void deactivate(); - -private: - - Ice::CommunicatorPtr _communicator; - AdminPtr _admin; -#ifndef _WIN32 - ActivatorPtr _activator; - int _waitTime; -#endif -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PACK_FORWARD_H
+#define ICE_PACK_FORWARD_H
+
+#include <IcePack/AdminF.h>
+#ifndef _WIN32
+# include <IcePack/Activator.h>
+#endif
+
+namespace IcePack
+{
+
+class Forward : public Ice::ServantLocator
+{
+public:
+
+ Forward(const Ice::CommunicatorPtr& communicator, const AdminPtr&);
+ virtual ~Forward();
+
+ virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const Ice::Current&, Ice::LocalObjectPtr&);
+ virtual void finished(const Ice::ObjectAdapterPtr&, const Ice::Current&,
+ const Ice::ObjectPtr&, const Ice::LocalObjectPtr&);
+ virtual void deactivate();
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+ AdminPtr _admin;
+#ifndef _WIN32
+ ActivatorPtr _activator;
+ int _waitTime;
+#endif
+};
+
+}
+
+#endif
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index 89292bf17e7..9e807e60991 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -51,7 +51,7 @@ IcePack::Parser::usage() void IcePack::Parser::add(const list<string>& args) { - if (args.empty()) + if(args.empty()) { error("`add' requires at least one argument (type `help' for more info)"); return; @@ -62,10 +62,10 @@ IcePack::Parser::add(const list<string>& args) ServerDescription desc; list<string>::const_iterator p = args.begin(); desc.object = _communicator->stringToProxy(*p); - if (++p != args.end()) + if(++p != args.end()) { desc.path = *p; - while (++p != args.end()) + while(++p != args.end()) { desc.args.push_back(*p); } @@ -84,7 +84,7 @@ IcePack::Parser::add(const list<string>& args) void IcePack::Parser::remove(const list<string>& args) { - if (args.size() != 1) + if(args.size() != 1) { error("`remove' requires exactly one argument (type `help' for more info)"); return; @@ -116,12 +116,12 @@ IcePack::Parser::listAll() cout << "host = " << p->second.host << endl; cout << "path = " << p->second.path << endl; cout << "args ="; - for (Args::iterator q = p->second.args.begin(); q != p->second.args.end(); ++q) + for(Args::iterator q = p->second.args.begin(); q != p->second.args.end(); ++q) { cout << ' ' << *q; } cout << endl; - if (++p != descriptions.end()) + if(++p != descriptions.end()) { cout << endl; } @@ -153,9 +153,9 @@ IcePack::Parser::shutdown() void IcePack::Parser::getInput(char* buf, int& result, int maxSize) { - if (!_commands.empty()) + if(!_commands.empty()) { - if (_commands == ";") + if(_commands == ";") { result = 0; } @@ -169,30 +169,30 @@ IcePack::Parser::getInput(char* buf, int& result, int maxSize) #endif strncpy(buf, _commands.c_str(), result); _commands.erase(0, result); - if (_commands.empty()) + if(_commands.empty()) { _commands = ";"; } } } - else if (isatty(fileno(yyin))) + else if(isatty(fileno(yyin))) { #ifdef HAVE_READLINE char* line = readline(parser->getPrompt()); - if (!line) + if(!line) { result = 0; } else { - if (*line) + if(*line) { add_history(line); } result = strlen(line) + 1; - if (result > maxSize) + if(result > maxSize) { free(line); error("input line too long"); @@ -211,12 +211,12 @@ IcePack::Parser::getInput(char* buf, int& result, int maxSize) cout << parser->getPrompt() << flush; string line; - while (true) + while(true) { char c = static_cast<char>(getc(yyin)); - if (c == EOF) + if(c == EOF) { - if (line.size()) + if(line.size()) { line += '\n'; } @@ -225,14 +225,14 @@ IcePack::Parser::getInput(char* buf, int& result, int maxSize) line += c; - if (c == '\n') + if(c == '\n') { break; } } result = line.length(); - if (result > maxSize) + if(result > maxSize) { error("input line too long"); buf[0] = EOF; @@ -247,7 +247,7 @@ IcePack::Parser::getInput(char* buf, int& result, int maxSize) } else { - if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; @@ -273,7 +273,7 @@ IcePack::Parser::getPrompt() { assert(_commands.empty() && isatty(fileno(yyin))); - if (_continue) + if(_continue) { _continue = false; return "(cont) "; @@ -291,13 +291,13 @@ IcePack::Parser::scanPosition(const char* s) string::size_type idx; idx = line.find("line"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx + 4); } idx = line.find_first_not_of(" \t\r#"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); } @@ -305,18 +305,18 @@ IcePack::Parser::scanPosition(const char* s) _currentLine = atoi(line.c_str()) - 1; idx = line.find_first_of(" \t\r"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); } idx = line.find_first_not_of(" \t\r\""); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); idx = line.find_first_of(" \t\r\""); - if (idx != string::npos) + if(idx != string::npos) { _currentFile = line.substr(0, idx); line.erase(0, idx + 1); @@ -331,7 +331,7 @@ IcePack::Parser::scanPosition(const char* s) void IcePack::Parser::error(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } @@ -351,7 +351,7 @@ IcePack::Parser::error(const string& s) void IcePack::Parser::warning(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } @@ -387,7 +387,7 @@ IcePack::Parser::parse(FILE* file, bool debug) nextLine(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } @@ -416,7 +416,7 @@ IcePack::Parser::parse(const std::string& commands, bool debug) nextLine(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h index cbb3fb058d0..3d284a203c4 100644 --- a/cpp/src/IcePack/Parser.h +++ b/cpp/src/IcePack/Parser.h @@ -1,107 +1,107 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PACK_PARSER_H -#define ICE_PACK_PARSER_H - -#include <IceUtil/Handle.h> -#include <IcePack/Admin.h> -#include <list> - -#ifdef _WIN32 -# include <io.h> -# define isatty _isatty -# define fileno _fileno -// '_isatty' : inconsistent dll linkage. dllexport assumed. -# pragma warning( disable : 4273 ) -#endif - -// -// Stuff for flex and bison -// - -#define YYSTYPE std::list<std::string> -#define YY_DECL int yylex(YYSTYPE* yylvalp) -YY_DECL; -int yyparse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) yyerror(a) - -namespace IcePack -{ - -class Parser; -typedef ::IceUtil::Handle<Parser> ParserPtr; - -} - -namespace IcePack -{ - -class Parser : public ::IceUtil::SimpleShared -{ -public: - - static ParserPtr createParser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&); - - void usage(); - - void add(const std::list<std::string>&); - void remove(const std::list<std::string>&); - void listAll(); - void shutdown(); - - void getInput(char*, int&, int); - void nextLine(); - void continueLine(); - char* getPrompt(); - void scanPosition(const char*); - - void error(const char*); - void error(const std::string&); - - void warning(const char*); - void warning(const std::string&); - - int parse(FILE*, bool); - int parse(const std::string&, bool); - -private: - - Parser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&); - - std::string _commands; - Ice::CommunicatorPtr _communicator; - IcePack::AdminPrx _admin; - bool _continue; - int _errors; - int _currentLine; - std::string _currentFile; -}; - -extern Parser* parser; // The current parser for bison/flex - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PACK_PARSER_H
+#define ICE_PACK_PARSER_H
+
+#include <IceUtil/Handle.h>
+#include <IcePack/Admin.h>
+#include <list>
+
+#ifdef _WIN32
+# include <io.h>
+# define isatty _isatty
+# define fileno _fileno
+// '_isatty' : inconsistent dll linkage. dllexport assumed.
+# pragma warning( disable : 4273 )
+#endif
+
+//
+// Stuff for flex and bison
+//
+
+#define YYSTYPE std::list<std::string>
+#define YY_DECL int yylex(YYSTYPE* yylvalp)
+YY_DECL;
+int yyparse();
+
+//
+// I must set the initial stack depth to the maximum stack depth to
+// disable bison stack resizing. The bison stack resizing routines use
+// simple malloc/alloc/memcpy calls, which do not work for the
+// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
+// assignment operator, etc.
+//
+#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum.
+#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
+
+//
+// Newer bison versions allow to disable stack resizing by defining
+// yyoverflow.
+//
+#define yyoverflow(a, b, c, d, e, f) yyerror(a)
+
+namespace IcePack
+{
+
+class Parser;
+typedef ::IceUtil::Handle<Parser> ParserPtr;
+
+}
+
+namespace IcePack
+{
+
+class Parser : public ::IceUtil::SimpleShared
+{
+public:
+
+ static ParserPtr createParser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&);
+
+ void usage();
+
+ void add(const std::list<std::string>&);
+ void remove(const std::list<std::string>&);
+ void listAll();
+ void shutdown();
+
+ void getInput(char*, int&, int);
+ void nextLine();
+ void continueLine();
+ char* getPrompt();
+ void scanPosition(const char*);
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void warning(const char*);
+ void warning(const std::string&);
+
+ int parse(FILE*, bool);
+ int parse(const std::string&, bool);
+
+private:
+
+ Parser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&);
+
+ std::string _commands;
+ Ice::CommunicatorPtr _communicator;
+ IcePack::AdminPrx _admin;
+ bool _continue;
+ int _errors;
+ int _currentLine;
+ std::string _currentFile;
+};
+
+extern Parser* parser; // The current parser for bison/flex
+
+}
+
+#endif
diff --git a/cpp/src/IcePack/Server.cpp b/cpp/src/IcePack/Server.cpp index 3697d74b263..5e3332f2ff0 100644 --- a/cpp/src/IcePack/Server.cpp +++ b/cpp/src/IcePack/Server.cpp @@ -78,19 +78,19 @@ Server::run(int argc, char* argv[]) stringSeqToArgs(args, argc, argv); bool nowarn = false; - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[i], "--nowarn") == 0) + else if(strcmp(argv[i], "--nowarn") == 0) { nowarn = true; } @@ -104,7 +104,7 @@ Server::run(int argc, char* argv[]) const char* adminEndpointsProperty = "IcePack.Admin.Endpoints"; string adminEndpoints = properties->getProperty(adminEndpointsProperty); - if (!adminEndpoints.empty() && !nowarn) + if(!adminEndpoints.empty() && !nowarn) { cerr << appName() << ": warning: administrative endpoints property `" << adminEndpointsProperty << "' enabled" << endl; @@ -112,7 +112,7 @@ Server::run(int argc, char* argv[]) const char* forwardEndpointsProperty = "IcePack.Forward.Endpoints"; string forwardEndpoints = properties->getProperty(forwardEndpointsProperty); - if (forwardEndpoints.empty()) + if(forwardEndpoints.empty()) { cerr << appName() << ": property `" << forwardEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -121,7 +121,7 @@ Server::run(int argc, char* argv[]) AdminPtr admin = new AdminI(communicator()); ServantLocatorPtr forward = new Forward(communicator(), admin); - if (adminEndpoints.length() != 0) + if(adminEndpoints.length() != 0) { ObjectAdapterPtr adminAdapter = communicator()->createObjectAdapterFromProperty("Admin", adminEndpointsProperty); diff --git a/cpp/src/IcePack/dummyinclude/unistd.h b/cpp/src/IcePack/dummyinclude/unistd.h index 92d53d10b9b..a5868056a35 100644 --- a/cpp/src/IcePack/dummyinclude/unistd.h +++ b/cpp/src/IcePack/dummyinclude/unistd.h @@ -1,4 +1,4 @@ -// -// Files generated by flex need unistd.h, which is not available on -// Windows. Thus this dummy file. -// +//
+// Files generated by flex need unistd.h, which is not available on
+// Windows. Thus this dummy file.
+//
diff --git a/cpp/src/IcePatch/Client.cpp b/cpp/src/IcePatch/Client.cpp index 2d7447b7497..eef4467867f 100644 --- a/cpp/src/IcePatch/Client.cpp +++ b/cpp/src/IcePatch/Client.cpp @@ -58,19 +58,19 @@ IcePatch::Client::run(int argc, char* argv[]) try { int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << appName() << ": unknown option `" << argv[idx] << "'" << endl; usage(); @@ -83,9 +83,9 @@ IcePatch::Client::run(int argc, char* argv[]) } vector<string> subdirs; - if (argc > 1) + if(argc > 1) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { subdirs.push_back(argv[i]); } @@ -102,11 +102,11 @@ IcePatch::Client::run(int argc, char* argv[]) // const char* glacierStarterEndpointsProperty = "Glacier.Starter.Endpoints"; string glacierStarterEndpoints = properties->getProperty(glacierStarterEndpointsProperty); - if (!glacierStarterEndpoints.empty()) + if(!glacierStarterEndpoints.empty()) { ObjectPrx starterBase = communicator()->stringToProxy("Glacier/starter:" + glacierStarterEndpoints); Glacier::StarterPrx starter = Glacier::StarterPrx::checkedCast(starterBase); - if (!starter) + if(!starter) { cerr << appName() << ": endpoints `" << glacierStarterEndpoints << "' do not refer to a glacier router starter" << endl; @@ -117,7 +117,7 @@ IcePatch::Client::run(int argc, char* argv[]) ByteSeq publicKey; ByteSeq routerCert; - while (!router) + while(!router) { string id; string pw; @@ -143,7 +143,7 @@ IcePatch::Client::run(int argc, char* argv[]) } string clientConfig = properties->getProperty("IceSSL.Client.Config"); - if (!clientConfig.empty()) + if(!clientConfig.empty()) { string privateKeyBase64 = IceUtil::Base64::encode(privateKey); string publicKeyBase64 = IceUtil::Base64::encode(publicKey); @@ -167,7 +167,7 @@ IcePatch::Client::run(int argc, char* argv[]) // const char* endpointsProperty = "IcePatch.Endpoints"; string endpoints = properties->getProperty(endpointsProperty); - if (endpoints.empty()) + if(endpoints.empty()) { cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -178,12 +178,12 @@ IcePatch::Client::run(int argc, char* argv[]) // const char* directoryProperty = "IcePatch.Directory"; string directory = properties->getProperty(directoryProperty); - if (!directory.empty()) + if(!directory.empty()) { #ifdef _WIN32 - if (_chdir(directory.c_str()) == -1) + if(_chdir(directory.c_str()) == -1) #else - if (chdir(directory.c_str()) == -1) + if(chdir(directory.c_str()) == -1) #endif { cerr << appName() << ": cannot change to directory `" << directory << "': " << strerror(errno) << endl; @@ -201,7 +201,7 @@ IcePatch::Client::run(int argc, char* argv[]) // // Patch all subdirectories. // - for (vector<string>::const_iterator p = subdirs.begin(); p != subdirs.end(); ++p) + for(vector<string>::const_iterator p = subdirs.begin(); p != subdirs.end(); ++p) { Identity identity = pathToIdentity(*p); ObjectPrx topObj = communicator()->stringToProxy(identityToString(identity) + ':' + endpoints); @@ -211,16 +211,16 @@ IcePatch::Client::run(int argc, char* argv[]) assert(topDesc); string path = identityToPath(topDesc->directory->ice_getIdentity()); string::size_type pos = 0; - while (pos < path.size()) + while(pos < path.size()) { string::size_type pos2 = path.find('/', pos); - if (pos2 == string::npos) + if(pos2 == string::npos) { pos2 = path.size(); } string subPath = path.substr(0, pos2); FileInfo subPathInfo = getFileInfo(subPath, false); - if (subPathInfo.type == FileTypeNotExist) + if(subPathInfo.type == FileTypeNotExist) { createDirectory(subPath); cout << subPath << ": created" << endl; @@ -236,7 +236,7 @@ IcePatch::Client::run(int argc, char* argv[]) { cout << endl; // There might still be a non-terminated line on cout. cerr << appName() << ": " << ex << ":\n" << ex.reason << endl; - if (router) + if(router) { router->shutdown(); } @@ -246,14 +246,14 @@ IcePatch::Client::run(int argc, char* argv[]) { cout << endl; // There might still be a non-terminated line on cout. cerr << appName() << ": patching service busy, try again later" << endl; - if (router) + if(router) { router->shutdown(); } return EXIT_FAILURE; } - if (router) + if(router) { router->shutdown(); } @@ -265,7 +265,7 @@ string IcePatch::Client::pathToName(const string& path) { string::size_type pos = path.rfind('/'); - if (pos == string::npos) + if(pos == string::npos) { return path; } @@ -318,12 +318,12 @@ public: void IcePatch::Client::patch(const FileDescSeq& fileDescSeq, const string& indent) { - for (unsigned int i = 0; i < fileDescSeq.size(); ++i) + for(unsigned int i = 0; i < fileDescSeq.size(); ++i) { string path; DirectoryDescPtr directoryDesc = DirectoryDescPtr::dynamicCast(fileDescSeq[i]); RegularDescPtr regularDesc; - if (directoryDesc) + if(directoryDesc) { path = identityToPath(directoryDesc->directory->ice_getIdentity()); } @@ -336,10 +336,10 @@ IcePatch::Client::patch(const FileDescSeq& fileDescSeq, const string& indent) bool last = (i == fileDescSeq.size() - 1); - if (directoryDesc) + if(directoryDesc) { string newIndent; - if (last) + if(last) { newIndent = indent + " "; } @@ -350,7 +350,7 @@ IcePatch::Client::patch(const FileDescSeq& fileDescSeq, const string& indent) cout << indent << "+-" << pathToName(path) << ":"; FileInfo info = getFileInfo(path, false); - switch (info.type) + switch(info.type) { case FileTypeNotExist: { @@ -393,7 +393,7 @@ IcePatch::Client::patch(const FileDescSeq& fileDescSeq, const string& indent) MyProgressCB progressCB; FileInfo info = getFileInfo(path, false); - switch (info.type) + switch(info.type) { case FileTypeNotExist: { @@ -414,12 +414,12 @@ IcePatch::Client::patch(const FileDescSeq& fileDescSeq, const string& indent) string pathMD5 = path + ".md5"; FileInfo infoMD5 = getFileInfo(pathMD5, false); - if (infoMD5.type == FileTypeRegular && infoMD5.time >= info.time) + if(infoMD5.type == FileTypeRegular && infoMD5.time >= info.time) { md5 = getMD5(path); } - if (md5 != regularDesc->md5) + if(md5 != regularDesc->md5) { removeRecursive(path); getRegular(regularDesc->regular, progressCB); @@ -440,7 +440,7 @@ IcePatch::Client::patch(const FileDescSeq& fileDescSeq, const string& indent) } } - if (last) + if(last) { cout << indent << endl; } diff --git a/cpp/src/IcePatch/FileDescFactory.cpp b/cpp/src/IcePatch/FileDescFactory.cpp index 76044fd700d..75627d27a74 100644 --- a/cpp/src/IcePatch/FileDescFactory.cpp +++ b/cpp/src/IcePatch/FileDescFactory.cpp @@ -17,12 +17,12 @@ using namespace IcePatch; ObjectPtr IcePatch::FileDescFactory::create(const std::string& type) { - if (type == "::IcePatch::DirectoryDesc") + if(type == "::IcePatch::DirectoryDesc") { return new DirectoryDesc; } - if (type == "::IcePatch::RegularDesc") + if(type == "::IcePatch::RegularDesc") { return new RegularDesc; } diff --git a/cpp/src/IcePatch/FileLocator.cpp b/cpp/src/IcePatch/FileLocator.cpp index bcf0a46cab7..140bb522fff 100644 --- a/cpp/src/IcePatch/FileLocator.cpp +++ b/cpp/src/IcePatch/FileLocator.cpp @@ -30,27 +30,27 @@ IcePatch::FileLocator::locate(const ObjectAdapterPtr& adapter, const Current& cu // string path = identityToPath(current.identity); - if (path.empty()) // Empty paths are not permissible. + if(path.empty()) // Empty paths are not permissible. { return 0; } - if (path[0] == '/') // Path must not start with '/'. + if(path[0] == '/') // Path must not start with '/'. { return 0; } - if (path.find("..") != string::npos) // Path must not contain '..'. + if(path.find("..") != string::npos) // Path must not contain '..'. { return 0; } - if (path.find(':') == 1) // Path cannot contain ':' as second character. + if(path.find(':') == 1) // Path cannot contain ':' as second character. { return 0; } - if (ignoreSuffix(path)) // Some suffixes are reserved. + if(ignoreSuffix(path)) // Some suffixes are reserved. { return 0; } @@ -67,7 +67,7 @@ IcePatch::FileLocator::locate(const ObjectAdapterPtr& adapter, const Current& cu return 0; } - switch (info.type) + switch(info.type) { case FileTypeDirectory: { diff --git a/cpp/src/IcePatch/FileLocator.h b/cpp/src/IcePatch/FileLocator.h index 83c77f15b0a..c8290ad761a 100644 --- a/cpp/src/IcePatch/FileLocator.h +++ b/cpp/src/IcePatch/FileLocator.h @@ -1,41 +1,41 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PATCH_FILE_LOCATOR_H -#define ICE_PATCH_FILE_LOCATOR_H - -#include <Ice/Ice.h> -#include <IcePatch/IcePatch.h> - -namespace IcePatch -{ - -class FileLocator: virtual public Ice::ServantLocator -{ -public: - - FileLocator(const Ice::ObjectAdapterPtr&); - - virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const Ice::Current&, Ice::LocalObjectPtr&); - - virtual void finished(const Ice::ObjectAdapterPtr&, const Ice::Current&, const Ice::ObjectPtr&, - const Ice::LocalObjectPtr&); - - virtual void deactivate(); - -private: - - DirectoryPtr _directory; // The stateless default servant for all directories. - RegularPtr _regular; // The stateless default servant for all regular files. -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PATCH_FILE_LOCATOR_H
+#define ICE_PATCH_FILE_LOCATOR_H
+
+#include <Ice/Ice.h>
+#include <IcePatch/IcePatch.h>
+
+namespace IcePatch
+{
+
+class FileLocator: virtual public Ice::ServantLocator
+{
+public:
+
+ FileLocator(const Ice::ObjectAdapterPtr&);
+
+ virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const Ice::Current&, Ice::LocalObjectPtr&);
+
+ virtual void finished(const Ice::ObjectAdapterPtr&, const Ice::Current&, const Ice::ObjectPtr&,
+ const Ice::LocalObjectPtr&);
+
+ virtual void deactivate();
+
+private:
+
+ DirectoryPtr _directory; // The stateless default servant for all directories.
+ RegularPtr _regular; // The stateless default servant for all regular files.
+};
+
+}
+
+#endif
diff --git a/cpp/src/IcePatch/IcePatchI.cpp b/cpp/src/IcePatch/IcePatchI.cpp index dd9de9b2c35..bdaa5a5b118 100644 --- a/cpp/src/IcePatch/IcePatchI.cpp +++ b/cpp/src/IcePatch/IcePatchI.cpp @@ -53,15 +53,15 @@ IcePatch::DirectoryI::getContents(const Ice::Current& current) string path = identityToPath(current.identity); StringSeq paths = readDirectory(path); filteredPaths.reserve(paths.size() / 3); - for (StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) + for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) { - if (ignoreSuffix(*p)) + if(ignoreSuffix(*p)) { pair<StringSeq::const_iterator, StringSeq::const_iterator> r = equal_range(paths.begin(), paths.end(), removeSuffix(*p)); - if (r.first == r.second) + if(r.first == r.second) { - if (!syncUpgraded) + if(!syncUpgraded) { sync.timedUpgrade(_busyTimeout); syncUpgraded = true; @@ -69,11 +69,11 @@ IcePatch::DirectoryI::getContents(const Ice::Current& current) StringSeq paths2 = readDirectory(path); pair<StringSeq::const_iterator, StringSeq::const_iterator> r2 = equal_range(paths2.begin(), paths2.end(), removeSuffix(*p)); - if (r2.first == r2.second) + if(r2.first == r2.second) { removeRecursive(*p); - if (_traceLevel > 0) + if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); out << "removed orphaned file `" << *p << "'"; @@ -98,7 +98,7 @@ IcePatch::DirectoryI::getContents(const Ice::Current& current) // FileDescSeq result; result.reserve(filteredPaths.size()); - for (StringSeq::const_iterator p = filteredPaths.begin(); p != filteredPaths.end(); ++p) + for(StringSeq::const_iterator p = filteredPaths.begin(); p != filteredPaths.end(); ++p) { FilePrx file = FilePrx::uncheckedCast(_adapter->createProxy(pathToIdentity(*p))); try @@ -131,15 +131,15 @@ IcePatch::RegularI::describe(const Ice::Current& current) FileInfo info = getFileInfo(path, true); FileInfo infoMD5 = getFileInfo(path + ".md5", false); - if (infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) + if(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) { sync.timedUpgrade(_busyTimeout); infoMD5 = getFileInfo(path + ".md5", false); - if (infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) + if(infoMD5.type != FileTypeRegular || infoMD5.time <= info.time) { createMD5(path); - if (_traceLevel > 0) + if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); out << "created .md5 file for `" << path << "'"; @@ -168,15 +168,15 @@ IcePatch::RegularI::getBZ2Size(const Ice::Current& current) FileInfo info = getFileInfo(path, true); FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); - if (infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) + if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); infoBZ2 = getFileInfo(path + ".bz2", false); - if (infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) + if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { createBZ2(path); - if (_traceLevel > 0) + if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); out << "created .bz2 file for `" << path << "'"; @@ -207,15 +207,15 @@ IcePatch::RegularI::getBZ2(Ice::Int pos, Ice::Int num, const Ice::Current& curre FileInfo info = getFileInfo(path, true); FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); - if (infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) + if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); infoBZ2 = getFileInfo(path + ".bz2", false); - if (infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) + if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { createBZ2(path); - if (_traceLevel > 0) + if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); out << "created .bz2 file for `" << path << "'"; @@ -241,15 +241,15 @@ IcePatch::RegularI::getBZ2MD5(Ice::Int size, const Ice::Current& current) FileInfo info = getFileInfo(path, true); FileInfo infoBZ2 = getFileInfo(path + ".bz2", false); - if (infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) + if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { sync.timedUpgrade(_busyTimeout); infoBZ2 = getFileInfo(path + ".bz2", false); - if (infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) + if(infoBZ2.type != FileTypeRegular || infoBZ2.time <= info.time) { createBZ2(path); - if (_traceLevel > 0) + if(_traceLevel > 0) { Trace out(_logger, "IcePatch"); out << "created .bz2 file for `" << path << "'"; diff --git a/cpp/src/IcePatch/IcePatchI.h b/cpp/src/IcePatch/IcePatchI.h index 040b7d9e9c8..fb9f636eca9 100644 --- a/cpp/src/IcePatch/IcePatchI.h +++ b/cpp/src/IcePatch/IcePatchI.h @@ -1,62 +1,62 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_PATCH_ICE_PATCH_I_H -#define ICE_PATCH_ICE_PATCH_I_H - -#include <Ice/Ice.h> -#include <IceUtil/RWRecMutex.h> -#include <IcePatch/IcePatch.h> - -namespace IcePatch -{ - -class FileI : virtual public File -{ -public: - - FileI(const Ice::ObjectAdapterPtr&); - -protected: - - Ice::ObjectAdapterPtr _adapter; - Ice::LoggerPtr _logger; - Ice::Int _traceLevel; - IceUtil::Time _busyTimeout; - static IceUtil::RWRecMutex _globalMutex; -}; - -class DirectoryI : virtual public Directory, - virtual public FileI -{ -public: - - DirectoryI(const Ice::ObjectAdapterPtr&); - - virtual FileDescPtr describe(const Ice::Current&); - virtual FileDescSeq getContents(const Ice::Current&); -}; - -class RegularI : virtual public Regular, - virtual public FileI -{ -public: - - RegularI(const Ice::ObjectAdapterPtr&); - - virtual FileDescPtr describe(const Ice::Current&); - virtual Ice::Int getBZ2Size(const Ice::Current&); - virtual Ice::ByteSeq getBZ2(Ice::Int, Ice::Int, const Ice::Current&); - virtual Ice::ByteSeq getBZ2MD5(Ice::Int, const Ice::Current&); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PATCH_ICE_PATCH_I_H
+#define ICE_PATCH_ICE_PATCH_I_H
+
+#include <Ice/Ice.h>
+#include <IceUtil/RWRecMutex.h>
+#include <IcePatch/IcePatch.h>
+
+namespace IcePatch
+{
+
+class FileI : virtual public File
+{
+public:
+
+ FileI(const Ice::ObjectAdapterPtr&);
+
+protected:
+
+ Ice::ObjectAdapterPtr _adapter;
+ Ice::LoggerPtr _logger;
+ Ice::Int _traceLevel;
+ IceUtil::Time _busyTimeout;
+ static IceUtil::RWRecMutex _globalMutex;
+};
+
+class DirectoryI : virtual public Directory,
+ virtual public FileI
+{
+public:
+
+ DirectoryI(const Ice::ObjectAdapterPtr&);
+
+ virtual FileDescPtr describe(const Ice::Current&);
+ virtual FileDescSeq getContents(const Ice::Current&);
+};
+
+class RegularI : virtual public Regular,
+ virtual public FileI
+{
+public:
+
+ RegularI(const Ice::ObjectAdapterPtr&);
+
+ virtual FileDescPtr describe(const Ice::Current&);
+ virtual Ice::Int getBZ2Size(const Ice::Current&);
+ virtual Ice::ByteSeq getBZ2(Ice::Int, Ice::Int, const Ice::Current&);
+ virtual Ice::ByteSeq getBZ2MD5(Ice::Int, const Ice::Current&);
+};
+
+}
+
+#endif
diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp index 5ced21f7d3b..e8b14415ad8 100644 --- a/cpp/src/IcePatch/Server.cpp +++ b/cpp/src/IcePatch/Server.cpp @@ -66,14 +66,14 @@ IcePatch::Server::usage() int IcePatch::Server::run(int argc, char* argv[]) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; @@ -93,7 +93,7 @@ IcePatch::Server::run(int argc, char* argv[]) // const char* endpointsProperty = "IcePatch.Endpoints"; string endpoints = properties->getProperty(endpointsProperty); - if (endpoints.empty()) + if(endpoints.empty()) { cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -104,12 +104,12 @@ IcePatch::Server::run(int argc, char* argv[]) // const char* directoryProperty = "IcePatch.Directory"; string directory = properties->getProperty(directoryProperty); - if (!directory.empty()) + if(!directory.empty()) { #ifdef _WIN32 - if (_chdir(directory.c_str()) == -1) + if(_chdir(directory.c_str()) == -1) #else - if (chdir(directory.c_str()) == -1) + if(chdir(directory.c_str()) == -1) #endif { cerr << appName() << ": cannot change to directory `" << directory << "': " << strerror(errno) << endl; @@ -161,12 +161,12 @@ IcePatch::Updater::run() PropertiesPtr properties = _adapter->getCommunicator()->getProperties(); IceUtil::Time updatePeriod = IceUtil::Time::seconds( properties->getPropertyAsIntWithDefault("IcePatch.UpdatePeriod", 60)); - if (updatePeriod < IceUtil::Time::seconds(10)) + if(updatePeriod < IceUtil::Time::seconds(10)) { updatePeriod = IceUtil::Time::seconds(10); } - while (!_destroy) + while(!_destroy) { try { @@ -204,7 +204,7 @@ IcePatch::Updater::run() out << "exception during update:\n" << ex; } - if (_destroy) + if(_destroy) { break; } @@ -224,15 +224,15 @@ IcePatch::Updater::destroy() void IcePatch::Updater::cleanup(const FileDescSeq& fileDescSeq) { - if (_destroy) + if(_destroy) { return; } - for (FileDescSeq::const_iterator p = fileDescSeq.begin(); p != fileDescSeq.end(); ++p) + for(FileDescSeq::const_iterator p = fileDescSeq.begin(); p != fileDescSeq.end(); ++p) { DirectoryDescPtr directoryDesc = DirectoryDescPtr::dynamicCast(*p); - if (directoryDesc) + if(directoryDesc) { // // Force .md5 files to be created and orphaned files to be diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index 8bc4e4c8f72..6e5369d543b 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -45,27 +45,27 @@ normalizePath(const string& path) string::size_type pos; - for (pos = 0; pos < result.size(); ++pos) + for(pos = 0; pos < result.size(); ++pos) { - if (result[pos] == '\\') + if(result[pos] == '\\') { result[pos] = '/'; } } pos = 0; - while ((pos = result.find("//", pos)) != string::npos) + while((pos = result.find("//", pos)) != string::npos) { result.erase(pos, 1); } pos = 0; - while ((pos = result.find("/./", pos)) != string::npos) + while((pos = result.find("/./", pos)) != string::npos) { result.erase(pos, 2); } - if (result.substr(0, 2) == "./") + if(result.substr(0, 2) == "./") { result.erase(0, 2); } @@ -93,7 +93,7 @@ string IcePatch::getSuffix(const string& path) { string::size_type pos = path.rfind('.'); - if (pos == string::npos) + if(pos == string::npos) { return string(); } @@ -114,7 +114,7 @@ string IcePatch::removeSuffix(const string& path) { string::size_type pos = path.rfind('.'); - if (pos == string::npos) + if(pos == string::npos) { return path; } @@ -128,9 +128,9 @@ FileInfo IcePatch::getFileInfo(const string& path, bool exceptionIfNotExist) { struct stat buf; - if (::stat(path.c_str(), &buf) == -1) + if(::stat(path.c_str(), &buf) == -1) { - if (!exceptionIfNotExist && errno == ENOENT) + if(!exceptionIfNotExist && errno == ENOENT) { FileInfo result; result.size = 0; @@ -150,11 +150,11 @@ IcePatch::getFileInfo(const string& path, bool exceptionIfNotExist) result.size = buf.st_size; result.time = buf.st_mtime; - if (S_ISDIR(buf.st_mode)) + if(S_ISDIR(buf.st_mode)) { result.type = FileTypeDirectory; } - else if (S_ISREG(buf.st_mode)) + else if(S_ISREG(buf.st_mode)) { result.type = FileTypeRegular; } @@ -169,16 +169,16 @@ IcePatch::getFileInfo(const string& path, bool exceptionIfNotExist) void IcePatch::removeRecursive(const string& path) { - if (getFileInfo(path, true).type == FileTypeDirectory) + if(getFileInfo(path, true).type == FileTypeDirectory) { StringSeq paths = readDirectory(path); - for (StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) + for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p) { removeRecursive(*p); } } - if (::remove(path.c_str()) == -1) + if(::remove(path.c_str()) == -1) { FileAccessException ex; ex.reason = "cannot remove file `" + path + "': " + strerror(errno); @@ -193,7 +193,7 @@ IcePatch::readDirectory(const string& path) struct _finddata_t data; long h = _findfirst((path + "/*").c_str(), &data); - if (h == -1) + if(h == -1) { FileAccessException ex; ex.reason = "cannot read directory `" + path + "': " + strerror(errno); @@ -202,18 +202,18 @@ IcePatch::readDirectory(const string& path) StringSeq result; - while (true) + while(true) { string name = data.name; - if (name != ".." && name != ".") + if(name != ".." && name != ".") { result.push_back(normalizePath(path + '/' + name)); } - if (_findnext(h, &data) == -1) + if(_findnext(h, &data) == -1) { - if (errno == ENOENT) + if(errno == ENOENT) { break; } @@ -235,7 +235,7 @@ IcePatch::readDirectory(const string& path) struct dirent **namelist; int n = ::scandir(path.c_str(), &namelist, 0, alphasort); - if (n < 0) + if(n < 0) { FileAccessException ex; ex.reason = "cannot read directory `" + path + "': " + strerror(errno); @@ -245,13 +245,13 @@ IcePatch::readDirectory(const string& path) StringSeq result; result.reserve(n - 2); - for (int i = 0; i < n; ++i) + for(int i = 0; i < n; ++i) { string name = namelist[i]->d_name; free(namelist[i]); - if (name != ".." && name != ".") + if(name != ".." && name != ".") { result.push_back(normalizePath(path + '/' + name)); } @@ -267,9 +267,9 @@ void IcePatch::createDirectory(const string& path) { #ifdef _WIN32 - if (::_mkdir(path.c_str()) == -1) + if(::_mkdir(path.c_str()) == -1) #else - if (::mkdir(path.c_str(), 00777) == -1) + if(::mkdir(path.c_str(), 00777) == -1) #endif { FileAccessException ex; @@ -283,7 +283,7 @@ IcePatch::getMD5(const string& path) { string pathMD5 = path + ".md5"; ifstream fileMD5(pathMD5.c_str(), ios::binary); - if (!fileMD5) + if(!fileMD5) { FileAccessException ex; ex.reason = "cannot open `" + pathMD5 + "' for reading: " + strerror(errno); @@ -292,13 +292,13 @@ IcePatch::getMD5(const string& path) ByteSeq bytesMD5; bytesMD5.resize(16); fileMD5.read(&bytesMD5[0], 16); - if (!fileMD5) + if(!fileMD5) { FileAccessException ex; ex.reason = "cannot read `" + pathMD5 + "': " + strerror(errno); throw ex; } - if (fileMD5.gcount() < 16) + if(fileMD5.gcount() < 16) { FileAccessException ex; ex.reason = "could not read 16 bytes from `" + pathMD5 + "'"; @@ -311,7 +311,7 @@ IcePatch::getMD5(const string& path) ByteSeq IcePatch::getPartialMD5(const string& path, Int size) { - if (size < 0) + if(size < 0) { FileAccessException ex; ex.reason = "negative file size is illegal"; @@ -324,7 +324,7 @@ IcePatch::getPartialMD5(const string& path, Int size) FileInfo info = getFileInfo(path, true); size = std::min(size, static_cast<Int>(info.size)); ifstream file(path.c_str(), ios::binary); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno); @@ -333,13 +333,13 @@ IcePatch::getPartialMD5(const string& path, Int size) ByteSeq bytes; bytes.resize(size); file.read(&bytes[0], bytes.size()); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot read `" + path + "': " + strerror(errno); throw ex; } - if (file.gcount() < static_cast<int>(bytes.size())) + if(file.gcount() < static_cast<int>(bytes.size())) { FileAccessException ex; ex.reason = "could not read all bytes from `" + path + "'"; @@ -365,7 +365,7 @@ IcePatch::createMD5(const string& path) // FileInfo info = getFileInfo(path, true); ifstream file(path.c_str(), ios::binary); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno); @@ -374,13 +374,13 @@ IcePatch::createMD5(const string& path) ByteSeq bytes; bytes.resize(info.size); file.read(&bytes[0], bytes.size()); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot read `" + path + "': " + strerror(errno); throw ex; } - if (file.gcount() < static_cast<int>(bytes.size())) + if(file.gcount() < static_cast<int>(bytes.size())) { FileAccessException ex; ex.reason = "could not read all bytes from `" + path + "'"; @@ -401,14 +401,14 @@ IcePatch::createMD5(const string& path) string pathMD5 = path + ".md5"; string pathMD5Temp = path + ".md5temp"; ofstream fileMD5(pathMD5Temp.c_str(), ios::binary); - if (!fileMD5) + if(!fileMD5) { FileAccessException ex; ex.reason = "cannot open `" + pathMD5Temp + "' for writing: " + strerror(errno); throw ex; } fileMD5.write(&bytesMD5[0], 16); - if (!fileMD5) + if(!fileMD5) { FileAccessException ex; ex.reason = "cannot write `" + pathMD5Temp + "': " + strerror(errno); @@ -422,7 +422,7 @@ IcePatch::createMD5(const string& path) // abortive application termination. // ::remove(pathMD5.c_str()); - if (::rename(pathMD5Temp.c_str(), pathMD5.c_str()) == -1) + if(::rename(pathMD5Temp.c_str(), pathMD5.c_str()) == -1) { FileAccessException ex; ex.reason = "cannot rename `" + pathMD5Temp + "' to `" + pathMD5 + "': " + strerror(errno); @@ -433,21 +433,21 @@ IcePatch::createMD5(const string& path) ByteSeq IcePatch::getBZ2(const string& path, Int pos, Int num) { - if (pos < 0) + if(pos < 0) { FileAccessException ex; ex.reason = "negative read offset is illegal"; throw ex; } - if (num < 0) + if(num < 0) { FileAccessException ex; ex.reason = "negative data segment size is illegal"; throw ex; } - if (num > 1024 * 1024) + if(num > 1024 * 1024) { FileAccessException ex; ex.reason = "maxium data segment size exceeded"; @@ -456,14 +456,14 @@ IcePatch::getBZ2(const string& path, Int pos, Int num) string pathBZ2 = path + ".bz2"; ifstream fileBZ2(pathBZ2.c_str(), ios::binary); - if (!fileBZ2) + if(!fileBZ2) { FileAccessException ex; ex.reason = "cannot open `" + pathBZ2 + "' for reading: " + strerror(errno); throw ex; } fileBZ2.seekg(pos); - if (!fileBZ2) + if(!fileBZ2) { FileAccessException ex; ostringstream out; @@ -474,7 +474,7 @@ IcePatch::getBZ2(const string& path, Int pos, Int num) ByteSeq bytesBZ2; bytesBZ2.resize(num); fileBZ2.read(&bytesBZ2[0], bytesBZ2.size()); - if (!fileBZ2 && !fileBZ2.eof()) + if(!fileBZ2 && !fileBZ2.eof()) { FileAccessException ex; ex.reason = "cannot read `" + pathBZ2 + "': " + strerror(errno); @@ -493,7 +493,7 @@ IcePatch::createBZ2(const string& path) // file. // ifstream file(path.c_str(), ios::binary); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno); @@ -503,7 +503,7 @@ IcePatch::createBZ2(const string& path) string pathBZ2 = path + ".bz2"; string pathBZ2Temp = path + ".bz2temp"; FILE* stdioFileBZ2 = fopen(pathBZ2Temp.c_str(), "wb"); - if (!stdioFileBZ2) + if(!stdioFileBZ2) { FileAccessException ex; ex.reason = "cannot open `" + pathBZ2Temp + "' for writing: " + strerror(errno); @@ -512,11 +512,11 @@ IcePatch::createBZ2(const string& path) int bzError; BZFILE* bzFile = BZ2_bzWriteOpen(&bzError, stdioFileBZ2, 5, 0, 0); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { FileAccessException ex; ex.reason = "BZ2_bzWriteOpen failed"; - if (bzError == BZ_IO_ERROR) + if(bzError == BZ_IO_ERROR) { ex.reason += string(": ") + strerror(errno); } @@ -527,10 +527,10 @@ IcePatch::createBZ2(const string& path) static const Int num = 64 * 1024; Byte bytes[num]; - while (!file.eof()) + while(!file.eof()) { file.read(bytes, num); - if (!file && !file.eof()) + if(!file && !file.eof()) { FileAccessException ex; ex.reason = "cannot read `" + path + "': " + strerror(errno); @@ -539,14 +539,14 @@ IcePatch::createBZ2(const string& path) throw ex; } - if (file.gcount() > 0) + if(file.gcount() > 0) { BZ2_bzWrite(&bzError, bzFile, bytes, file.gcount()); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { FileAccessException ex; ex.reason = "BZ2_bzWrite failed"; - if (bzError == BZ_IO_ERROR) + if(bzError == BZ_IO_ERROR) { ex.reason += string(": ") + strerror(errno); } @@ -558,11 +558,11 @@ IcePatch::createBZ2(const string& path) } BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { FileAccessException ex; ex.reason = "BZ2_bzWriteClose failed"; - if (bzError == BZ_IO_ERROR) + if(bzError == BZ_IO_ERROR) { ex.reason += string(": ") + strerror(errno); } @@ -579,7 +579,7 @@ IcePatch::createBZ2(const string& path) // abortive application termination. // ::remove(pathBZ2.c_str()); - if (::rename(pathBZ2Temp.c_str(), pathBZ2.c_str()) == -1) + if(::rename(pathBZ2Temp.c_str(), pathBZ2.c_str()) == -1) { FileAccessException ex; ex.reason = "cannot rename `" + pathBZ2Temp + "' to `" + pathBZ2 + "': " + strerror(errno); @@ -599,12 +599,12 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) // Check for partial BZ2 file. // FileInfo infoBZ2 = getFileInfo(pathBZ2, false); - if (infoBZ2.type == FileTypeRegular) + if(infoBZ2.type == FileTypeRegular) { ByteSeq remoteBZ2MD5 = regular->getBZ2MD5(infoBZ2.size); ByteSeq localBZ2MD5 = getPartialMD5(pathBZ2, infoBZ2.size); - if (remoteBZ2MD5 == localBZ2MD5) + if(remoteBZ2MD5 == localBZ2MD5) { posBZ2 = infoBZ2.size; } @@ -616,7 +616,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) progressCB.startDownload(totalBZ2, posBZ2); ofstream fileBZ2(pathBZ2.c_str(), ios::binary | (posBZ2 ? ios::app : 0)); - if (!fileBZ2) + if(!fileBZ2) { FileAccessException ex; ex.reason = "cannot open `" + pathBZ2 + "' for writing: " + strerror(errno); @@ -628,7 +628,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) static const Int numBZ2 = 64 * 1024; ByteSeq bytesBZ2 = regular->getBZ2(posBZ2, numBZ2); - if (bytesBZ2.empty()) + if(bytesBZ2.empty()) { break; } @@ -636,14 +636,14 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) posBZ2 += bytesBZ2.size(); fileBZ2.write(&bytesBZ2[0], bytesBZ2.size()); - if (!fileBZ2) + if(!fileBZ2) { FileAccessException ex; ex.reason = "cannot write `" + pathBZ2 + "': " + strerror(errno); throw ex; } - if (static_cast<Int>(bytesBZ2.size()) < numBZ2) + if(static_cast<Int>(bytesBZ2.size()) < numBZ2) { break; } @@ -659,7 +659,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) // Read the BZ2 file in blocks and write the original file. // ofstream file(path.c_str(), ios::binary); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot open `" + path + "' for writing: " + strerror(errno); @@ -667,7 +667,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) } FILE* stdioFileBZ2 = fopen(pathBZ2.c_str(), "rb"); - if (!stdioFileBZ2) + if(!stdioFileBZ2) { FileAccessException ex; ex.reason = "cannot open `" + pathBZ2 + "' for reading: " + strerror(errno); @@ -676,11 +676,11 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) int bzError; BZFILE* bzFile = BZ2_bzReadOpen(&bzError, stdioFileBZ2, 0, 0, 0, 0); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { FileAccessException ex; ex.reason = "BZ2_bzReadOpen failed"; - if (bzError == BZ_IO_ERROR) + if(bzError == BZ_IO_ERROR) { ex.reason += string(": ") + strerror(errno); } @@ -693,14 +693,14 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) progressCB.startUncompress(totalBZ2, 0); - while (bzError != BZ_STREAM_END) + while(bzError != BZ_STREAM_END) { int sz = BZ2_bzRead(&bzError, bzFile, bytesBZ2, numBZ2); - if (bzError != BZ_OK && bzError != BZ_STREAM_END) + if(bzError != BZ_OK && bzError != BZ_STREAM_END) { FileAccessException ex; ex.reason = "BZ2_bzRead failed"; - if (bzError == BZ_IO_ERROR) + if(bzError == BZ_IO_ERROR) { ex.reason += string(": ") + strerror(errno); } @@ -709,10 +709,10 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) throw ex; } - if (sz > 0) + if(sz > 0) { long pos = ftell(stdioFileBZ2); - if (pos == -1) + if(pos == -1) { FileAccessException ex; ex.reason = "cannot get read position for `" + pathBZ2 + "': " + strerror(errno); @@ -724,7 +724,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) progressCB.updateUncompress(totalBZ2, pos); file.write(bytesBZ2, sz); - if (!file) + if(!file) { FileAccessException ex; ex.reason = "cannot write `" + path + "': " + strerror(errno); @@ -738,11 +738,11 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) progressCB.finishedUncompress(totalBZ2); BZ2_bzReadClose(&bzError, bzFile); - if (bzError != BZ_OK) + if(bzError != BZ_OK) { FileAccessException ex; ex.reason = "BZ2_bzReadClose failed"; - if (bzError == BZ_IO_ERROR) + if(bzError == BZ_IO_ERROR) { ex.reason += string(": ") + strerror(errno); } @@ -756,7 +756,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB) // // Remove the BZ2 file, it is not needed anymore. // - if (::remove(pathBZ2.c_str()) == -1) + if(::remove(pathBZ2.c_str()) == -1) { FileAccessException ex; ex.reason = "cannot remove file `" + pathBZ2 + "': " + strerror(errno); diff --git a/cpp/src/IceSSL/BaseCerts.h b/cpp/src/IceSSL/BaseCerts.h index f431ba8a3c2..86b30e01790 100644 --- a/cpp/src/IceSSL/BaseCerts.h +++ b/cpp/src/IceSSL/BaseCerts.h @@ -1,68 +1,68 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_BASE_CERTS_H -#define ICE_SSL_BASE_CERTS_H - -#include <IceSSL/CertificateDesc.h> - -namespace IceSSL -{ - -class BaseCertificates -{ -public: - - BaseCertificates(); - BaseCertificates(CertificateDesc&, CertificateDesc&, DiffieHellmanParamsFile&); - BaseCertificates(BaseCertificates&); - - const CertificateDesc& getRSACert() const; - const CertificateDesc& getDSACert() const; - - const DiffieHellmanParamsFile& getDHParams() const; - -protected: - - CertificateDesc _rsaCert; - CertificateDesc _dsaCert; - DiffieHellmanParamsFile _dhParams; -}; - -template<class Stream> -inline Stream& operator << (Stream& target, const BaseCertificates& baseCerts) -{ - if (baseCerts.getRSACert().getKeySize() != 0) - { - target << "RSA\n{" << std::endl; - target << baseCerts.getRSACert(); - target << "}\n" << std::endl; - } - - if (baseCerts.getDSACert().getKeySize() != 0) - { - target << "DSA\n{" << std::endl; - target << baseCerts.getDSACert(); - target << "}\n" << std::endl; - } - - if (baseCerts.getDHParams().getKeySize() != 0) - { - target << "DH\n{" << std::endl; - target << baseCerts.getDHParams(); - target << "}\n" << std::endl; - } - - return target; -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_BASE_CERTS_H
+#define ICE_SSL_BASE_CERTS_H
+
+#include <IceSSL/CertificateDesc.h>
+
+namespace IceSSL
+{
+
+class BaseCertificates
+{
+public:
+
+ BaseCertificates();
+ BaseCertificates(CertificateDesc&, CertificateDesc&, DiffieHellmanParamsFile&);
+ BaseCertificates(BaseCertificates&);
+
+ const CertificateDesc& getRSACert() const;
+ const CertificateDesc& getDSACert() const;
+
+ const DiffieHellmanParamsFile& getDHParams() const;
+
+protected:
+
+ CertificateDesc _rsaCert;
+ CertificateDesc _dsaCert;
+ DiffieHellmanParamsFile _dhParams;
+};
+
+template<class Stream>
+inline Stream& operator << (Stream& target, const BaseCertificates& baseCerts)
+{
+ if(baseCerts.getRSACert().getKeySize() != 0)
+ {
+ target << "RSA\n{" << std::endl;
+ target << baseCerts.getRSACert();
+ target << "}\n" << std::endl;
+ }
+
+ if(baseCerts.getDSACert().getKeySize() != 0)
+ {
+ target << "DSA\n{" << std::endl;
+ target << baseCerts.getDSACert();
+ target << "}\n" << std::endl;
+ }
+
+ if(baseCerts.getDHParams().getKeySize() != 0)
+ {
+ target << "DH\n{" << std::endl;
+ target << baseCerts.getDHParams();
+ target << "}\n" << std::endl;
+ }
+
+ return target;
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/CertificateAuthority.h b/cpp/src/IceSSL/CertificateAuthority.h index 5447aa2140e..058c9a6b02d 100644 --- a/cpp/src/IceSSL/CertificateAuthority.h +++ b/cpp/src/IceSSL/CertificateAuthority.h @@ -1,41 +1,41 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CERTIFICATE_AUTHORITY_H -#define ICE_SSL_CERTIFICATE_AUTHORITY_H - -#include <IceUtil/Config.h> - -namespace IceSSL -{ - -class CertificateAuthority -{ -public: - - CertificateAuthority(); - CertificateAuthority(std::string&, std::string&); - CertificateAuthority(CertificateAuthority&); - - void setCAFileName(std::string&); - void setCAPath(std::string&); - - const std::string& getCAFileName() const; - const std::string& getCAPath() const; - -private: - - std::string _fileName; - std::string _path; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CERTIFICATE_AUTHORITY_H
+#define ICE_SSL_CERTIFICATE_AUTHORITY_H
+
+#include <IceUtil/Config.h>
+
+namespace IceSSL
+{
+
+class CertificateAuthority
+{
+public:
+
+ CertificateAuthority();
+ CertificateAuthority(std::string&, std::string&);
+ CertificateAuthority(CertificateAuthority&);
+
+ void setCAFileName(std::string&);
+ void setCAPath(std::string&);
+
+ const std::string& getCAFileName() const;
+ const std::string& getCAPath() const;
+
+private:
+
+ std::string _fileName;
+ std::string _path;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/CertificateDesc.h b/cpp/src/IceSSL/CertificateDesc.h index bd4bb931c28..d7e758bfd66 100644 --- a/cpp/src/IceSSL/CertificateDesc.h +++ b/cpp/src/IceSSL/CertificateDesc.h @@ -1,119 +1,119 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CERTIFICATE_DESC_H -#define ICE_SSL_CERTIFICATE_DESC_H - -#include <IceUtil/Config.h> -#include <openssl/ssl.h> -#include <vector> - -namespace IceSSL -{ - -class CertificateFile -{ -public: - - CertificateFile(); - CertificateFile(const std::string&, const int); - CertificateFile(const CertificateFile&); - - std::string getFileName() const; - int getEncoding() const; - -protected: - - std::string _fileName; - int _encoding; -}; - -class DiffieHellmanParamsFile : public CertificateFile -{ -public: - - DiffieHellmanParamsFile(); - DiffieHellmanParamsFile(const int, const std::string&, const int); - DiffieHellmanParamsFile(const DiffieHellmanParamsFile&); - - int getKeySize() const; - -protected: - - int _keySize; -}; - -class CertificateDesc -{ -public: - - CertificateDesc(); - CertificateDesc(const int, const CertificateFile&, const CertificateFile&); - CertificateDesc(const CertificateDesc&); - - int getKeySize() const; - - const CertificateFile& getPublic() const; - const CertificateFile& getPrivate() const; - -protected: - - int _keySize; - CertificateFile _public; - CertificateFile _private; -}; - -typedef std::vector<CertificateDesc> RSAVector; -typedef std::vector<CertificateDesc> DSAVector; -typedef std::vector<DiffieHellmanParamsFile> DHVector; - -template<class Stream> -inline Stream& operator << (Stream& target, const CertificateFile& certFile) -{ - if (certFile.getEncoding() == SSL_FILETYPE_PEM) - { - target << "[PEM]: " << certFile.getFileName(); - } - else if (certFile.getEncoding() == SSL_FILETYPE_ASN1) - { - target << "[ASN1]: " << certFile.getFileName(); - } - - return target; -} - -template<class Stream> -inline Stream& operator << (Stream& target, const DiffieHellmanParamsFile& dhParams) -{ - if (dhParams.getKeySize() != 0) - { - target << "Keysize: " << dhParams.getKeySize() << std::endl; - target << "File: " << ((CertificateFile&)dhParams) << std::endl; - } - - return target; -} - -template<class Stream> -inline Stream& operator << (Stream& target, const CertificateDesc& certDesc) -{ - if (certDesc.getKeySize() != 0) - { - target << "Keysize: " << certDesc.getKeySize() << std::endl; - target << "Public: " << certDesc.getPublic() << std::endl; - target << "Private: " << certDesc.getPrivate() << std::endl; - } - - return target; -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CERTIFICATE_DESC_H
+#define ICE_SSL_CERTIFICATE_DESC_H
+
+#include <IceUtil/Config.h>
+#include <openssl/ssl.h>
+#include <vector>
+
+namespace IceSSL
+{
+
+class CertificateFile
+{
+public:
+
+ CertificateFile();
+ CertificateFile(const std::string&, const int);
+ CertificateFile(const CertificateFile&);
+
+ std::string getFileName() const;
+ int getEncoding() const;
+
+protected:
+
+ std::string _fileName;
+ int _encoding;
+};
+
+class DiffieHellmanParamsFile : public CertificateFile
+{
+public:
+
+ DiffieHellmanParamsFile();
+ DiffieHellmanParamsFile(const int, const std::string&, const int);
+ DiffieHellmanParamsFile(const DiffieHellmanParamsFile&);
+
+ int getKeySize() const;
+
+protected:
+
+ int _keySize;
+};
+
+class CertificateDesc
+{
+public:
+
+ CertificateDesc();
+ CertificateDesc(const int, const CertificateFile&, const CertificateFile&);
+ CertificateDesc(const CertificateDesc&);
+
+ int getKeySize() const;
+
+ const CertificateFile& getPublic() const;
+ const CertificateFile& getPrivate() const;
+
+protected:
+
+ int _keySize;
+ CertificateFile _public;
+ CertificateFile _private;
+};
+
+typedef std::vector<CertificateDesc> RSAVector;
+typedef std::vector<CertificateDesc> DSAVector;
+typedef std::vector<DiffieHellmanParamsFile> DHVector;
+
+template<class Stream>
+inline Stream& operator << (Stream& target, const CertificateFile& certFile)
+{
+ if(certFile.getEncoding() == SSL_FILETYPE_PEM)
+ {
+ target << "[PEM]: " << certFile.getFileName();
+ }
+ else if(certFile.getEncoding() == SSL_FILETYPE_ASN1)
+ {
+ target << "[ASN1]: " << certFile.getFileName();
+ }
+
+ return target;
+}
+
+template<class Stream>
+inline Stream& operator << (Stream& target, const DiffieHellmanParamsFile& dhParams)
+{
+ if(dhParams.getKeySize() != 0)
+ {
+ target << "Keysize: " << dhParams.getKeySize() << std::endl;
+ target << "File: " << ((CertificateFile&)dhParams) << std::endl;
+ }
+
+ return target;
+}
+
+template<class Stream>
+inline Stream& operator << (Stream& target, const CertificateDesc& certDesc)
+{
+ if(certDesc.getKeySize() != 0)
+ {
+ target << "Keysize: " << certDesc.getKeySize() << std::endl;
+ target << "Public: " << certDesc.getPublic() << std::endl;
+ target << "Private: " << certDesc.getPrivate() << std::endl;
+ }
+
+ return target;
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/ConfigParser.cpp b/cpp/src/IceSSL/ConfigParser.cpp index 2d6a66717da..9ce7ccbaf1f 100644 --- a/cpp/src/IceSSL/ConfigParser.cpp +++ b/cpp/src/IceSSL/ConfigParser.cpp @@ -47,7 +47,7 @@ IceSSL::ConfigParser::ConfigParser(const string& configFile, const string& confi } IceSSL::ConfigParser::~ConfigParser() -{
+{ XMLPlatformUtils::Terminate(); } @@ -89,9 +89,9 @@ IceSSL::ConfigParser::process() try { - if (*(_configFile.begin()) != '/') + if(*(_configFile.begin()) != '/') { - if (*(_configPath.rbegin()) != '/') + if(*(_configPath.rbegin()) != '/') { _configPath += "/"; } @@ -115,7 +115,7 @@ IceSSL::ConfigParser::process() errorCount = parser.getErrorCount(); - if (errorCount == 0) + if(errorCount == 0) { // Get the root of the parse tree. _root = parser.getDocument(); @@ -155,7 +155,7 @@ IceSSL::ConfigParser::process() throw configEx; } - if (errorCount) + if(errorCount) { ConfigParseException configEx(__FILE__, __LINE__); @@ -167,7 +167,7 @@ IceSSL::ConfigParser::process() string reporterErrors = errReporter->getErrors(); - if (!reporterErrors.empty()) + if(!reporterErrors.empty()) { configEx._message += "\n"; configEx._message += reporterErrors; @@ -188,7 +188,7 @@ IceSSL::ConfigParser::loadClientConfig(GeneralConfig& general, try { // If we actually have a client section. - if (clientSection != 0) + if(clientSection != 0) { getGeneral(clientSection, general); getCertAuth(clientSection, certAuth); @@ -225,7 +225,7 @@ IceSSL::ConfigParser::loadServerConfig(GeneralConfig& general, try { // If we actually have a client section. - if (serverSection != 0) + if(serverSection != 0) { getGeneral(serverSection, general); getCertAuth(serverSection, certAuth); @@ -285,7 +285,7 @@ IceSSL::ConfigParser::popRoot(string& path, string& root, string& tail) { string::size_type pos = path.find_first_of(':'); - if (pos != string::npos) + if(pos != string::npos) { root = path.substr(0,pos); tail = path.substr(pos+1); @@ -309,7 +309,7 @@ IceSSL::ConfigParser::find(DOM_Node rootNode, string& nodePath) // The target node that we're looking for. DOM_Node tNode; - if (rootNode == 0) + if(rootNode == 0) { return tNode; } @@ -322,17 +322,17 @@ IceSSL::ConfigParser::find(DOM_Node rootNode, string& nodePath) DOM_Node child = rootNode.getFirstChild(); - while (child != 0) + while(child != 0) { // Ignore any other node types - we're only interested in ELEMENT_NODEs. - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) + if(child.getNodeType() == DOM_Node::ELEMENT_NODE) { string nodeName = toString(child.getNodeName()); - if (nodeName.compare(rootNodeName) == 0) + if(nodeName.compare(rootNodeName) == 0) { // No further to recurse, this must be it. - if (tailNodes.empty()) + if(tailNodes.empty()) { tNode = child; } @@ -353,7 +353,7 @@ IceSSL::ConfigParser::find(DOM_Node rootNode, string& nodePath) void IceSSL::ConfigParser::getGeneral(DOM_Node rootNode, GeneralConfig& generalConfig) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -365,7 +365,7 @@ IceSSL::ConfigParser::getGeneral(DOM_Node rootNode, GeneralConfig& generalConfig int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string nodeName = toString(attribute.getNodeName()); @@ -379,7 +379,7 @@ IceSSL::ConfigParser::getGeneral(DOM_Node rootNode, GeneralConfig& generalConfig void IceSSL::ConfigParser::getCertAuth(DOM_Node rootNode, CertificateAuthority& certAuth) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -387,7 +387,7 @@ IceSSL::ConfigParser::getCertAuth(DOM_Node rootNode, CertificateAuthority& certA string nodeName = "certauthority"; DOM_Node certAuthNode = find(rootNode, nodeName); - if (certAuthNode == 0) + if(certAuthNode == 0) { return; } @@ -396,25 +396,25 @@ IceSSL::ConfigParser::getCertAuth(DOM_Node rootNode, CertificateAuthority& certA int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string nodeName = toString(attribute.getNodeName()); string nodeValue = toString(attribute.getNodeValue()); - if (nodeName.compare("file") == 0) + if(nodeName.compare("file") == 0) { string filename = nodeValue; // Just a filename, no path component, append path. - if ((filename.find("/") == string::npos) && (filename.find("\\") == string::npos)) + if((filename.find("/") == string::npos) && (filename.find("\\") == string::npos)) { filename = _configPath + filename; } certAuth.setCAFileName(filename); } - else if (nodeName.compare("path") == 0) + else if(nodeName.compare("path") == 0) { certAuth.setCAPath(nodeValue); } @@ -424,7 +424,7 @@ IceSSL::ConfigParser::getCertAuth(DOM_Node rootNode, CertificateAuthority& certA void IceSSL::ConfigParser::getBaseCerts(DOM_Node rootNode, BaseCertificates& baseCerts) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -432,7 +432,7 @@ IceSSL::ConfigParser::getBaseCerts(DOM_Node rootNode, BaseCertificates& baseCert string nodeName = "basecerts"; DOM_Node baseCertsRoot = find(rootNode, nodeName); - if (baseCertsRoot == 0) + if(baseCertsRoot == 0) { return; } @@ -456,7 +456,7 @@ IceSSL::ConfigParser::getBaseCerts(DOM_Node rootNode, BaseCertificates& baseCert void IceSSL::ConfigParser::getTempCerts(DOM_Node rootNode, TempCertificates& tempCerts) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -464,23 +464,23 @@ IceSSL::ConfigParser::getTempCerts(DOM_Node rootNode, TempCertificates& tempCert string nodeName = "tempcerts"; DOM_Node tempCertsRoot = find(rootNode, nodeName); - if (tempCertsRoot == 0) + if(tempCertsRoot == 0) { return; } DOM_Node child = tempCertsRoot.getFirstChild(); - while (child != 0) + while(child != 0) { DOMString nodeName = child.getNodeName(); string name = toString(nodeName); - if (name.compare("dhparams") == 0) + if(name.compare("dhparams") == 0) { loadDHParams(child, tempCerts); } - else if (name.compare("rsacert") == 0) + else if(name.compare("rsacert") == 0) { loadRSACert(child, tempCerts); } @@ -512,7 +512,7 @@ IceSSL::ConfigParser::loadRSACert(DOM_Node rootNode, TempCertificates& tempCerts void IceSSL::ConfigParser::getCert(DOM_Node rootNode, CertificateDesc& certDesc) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -524,13 +524,13 @@ IceSSL::ConfigParser::getCert(DOM_Node rootNode, CertificateDesc& certDesc) DOM_NamedNodeMap attributes = rootNode.getAttributes(); int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string nodeName = toString(attribute.getNodeName()); string nodeValue = toString(attribute.getNodeValue()); - if (nodeName.compare("keysize") == 0) + if(nodeName.compare("keysize") == 0) { keySize = atoi(nodeValue.c_str()); } @@ -549,7 +549,7 @@ IceSSL::ConfigParser::getCert(DOM_Node rootNode, CertificateDesc& certDesc) void IceSSL::ConfigParser::getDHParams(DOM_Node rootNode, DiffieHellmanParamsFile& dhParams) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -561,13 +561,13 @@ IceSSL::ConfigParser::getDHParams(DOM_Node rootNode, DiffieHellmanParamsFile& dh int keySize = 0; int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string nodeName = toString(attribute.getNodeName()); string nodeValue = toString(attribute.getNodeValue()); - if (nodeName.compare("keysize") == 0) + if(nodeName.compare("keysize") == 0) { keySize = atoi(nodeValue.c_str()); } @@ -579,7 +579,7 @@ IceSSL::ConfigParser::getDHParams(DOM_Node rootNode, DiffieHellmanParamsFile& dh void IceSSL::ConfigParser::loadCertificateFile(DOM_Node rootNode, CertificateFile& certFile) { - if (rootNode == 0) + if(rootNode == 0) { return; } @@ -590,22 +590,22 @@ IceSSL::ConfigParser::loadCertificateFile(DOM_Node rootNode, CertificateFile& ce DOM_NamedNodeMap attributes = rootNode.getAttributes(); int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string nodeName = toString(attribute.getNodeName()); string nodeValue = toString(attribute.getNodeValue()); - if (nodeName.compare("encoding") == 0) + if(nodeName.compare("encoding") == 0) { encoding = parseEncoding(nodeValue); } - else if (nodeName.compare("filename") == 0) + else if(nodeName.compare("filename") == 0) { filename = nodeValue; // Just a filename, no path component, append path. - if ((filename.find("/") == string::npos) && (filename.find("\\") == string::npos)) + if((filename.find("/") == string::npos) && (filename.find("\\") == string::npos)) { filename = _configPath + filename; } @@ -620,11 +620,11 @@ IceSSL::ConfigParser::parseEncoding(string& encodingString) { int encoding = 0; - if (encodingString.compare("PEM") == 0) + if(encodingString.compare("PEM") == 0) { encoding = SSL_FILETYPE_PEM; } - else if (encodingString.compare("ASN1") == 0) + else if(encodingString.compare("ASN1") == 0) { encoding = SSL_FILETYPE_ASN1; } diff --git a/cpp/src/IceSSL/ConfigParser.h b/cpp/src/IceSSL/ConfigParser.h index c88201b0019..bbe6158ac65 100644 --- a/cpp/src/IceSSL/ConfigParser.h +++ b/cpp/src/IceSSL/ConfigParser.h @@ -1,89 +1,89 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONFIG_H -#define ICE_SSL_CONFIG_H - -#include <Ice/LoggerF.h> -#include <IceSSL/CertificateDesc.h> -#include <IceSSL/GeneralConfig.h> -#include <IceSSL/CertificateAuthority.h> -#include <IceSSL/BaseCerts.h> -#include <IceSSL/TempCerts.h> -#include <IceSSL/TraceLevelsF.h> -#include <dom/DOM.hpp> - -namespace IceSSL -{ - -class ConfigParser -{ -public: - - // Construction based on the indicated config file, or config file and - // certificate path. - ConfigParser(const std::string&); - ConfigParser(const std::string&, const std::string&); - ~ConfigParser(); - - // Performs a complete parsing of the file. - void process(); - - // Loads the Client/Server portions of the config file. - bool loadClientConfig(GeneralConfig&, CertificateAuthority&, BaseCertificates&); - bool loadServerConfig(GeneralConfig&, CertificateAuthority&, BaseCertificates&, TempCertificates&); - - void setTrace(const TraceLevelsPtr&); - bool isTraceSet() const; - - void setLogger(const Ice::LoggerPtr&); - bool isLoggerSet() const; - -private: - - DOM_Node _root; - std::string _configFile; - std::string _configPath; - - TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; - - // Parse tree walking utility methods. - void popRoot(std::string&, std::string&, std::string&); - DOM_Node find(std::string&); - DOM_Node find(DOM_Node, std::string&); - - // Loading of the base elements of the file. - void getGeneral(DOM_Node, GeneralConfig&); - void getCertAuth(DOM_Node, CertificateAuthority&); - void getBaseCerts(DOM_Node, BaseCertificates&); - void getTempCerts(DOM_Node, TempCertificates&); - - // Loading of temporary certificates/params (Ephemeral Keys). - void loadDHParams(DOM_Node, TempCertificates&); - void loadRSACert(DOM_Node, TempCertificates&); - - // Populate with information from the indicated node in the parse tree. - void getCert(DOM_Node, CertificateDesc&); - void getDHParams(DOM_Node, DiffieHellmanParamsFile&); - - // Populate a certificate file object, basis of all certificates. - void loadCertificateFile(DOM_Node, CertificateFile&); - - // Parses the certificate encoding format from a string representation - // to the proper integer value used by the underlying SSL framework. - int parseEncoding(std::string&); - - std::string toString(const DOMString&); -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONFIG_H
+#define ICE_SSL_CONFIG_H
+
+#include <Ice/LoggerF.h>
+#include <IceSSL/CertificateDesc.h>
+#include <IceSSL/GeneralConfig.h>
+#include <IceSSL/CertificateAuthority.h>
+#include <IceSSL/BaseCerts.h>
+#include <IceSSL/TempCerts.h>
+#include <IceSSL/TraceLevelsF.h>
+#include <dom/DOM.hpp>
+
+namespace IceSSL
+{
+
+class ConfigParser
+{
+public:
+
+ // Construction based on the indicated config file, or config file and
+ // certificate path.
+ ConfigParser(const std::string&);
+ ConfigParser(const std::string&, const std::string&);
+ ~ConfigParser();
+
+ // Performs a complete parsing of the file.
+ void process();
+
+ // Loads the Client/Server portions of the config file.
+ bool loadClientConfig(GeneralConfig&, CertificateAuthority&, BaseCertificates&);
+ bool loadServerConfig(GeneralConfig&, CertificateAuthority&, BaseCertificates&, TempCertificates&);
+
+ void setTrace(const TraceLevelsPtr&);
+ bool isTraceSet() const;
+
+ void setLogger(const Ice::LoggerPtr&);
+ bool isLoggerSet() const;
+
+private:
+
+ DOM_Node _root;
+ std::string _configFile;
+ std::string _configPath;
+
+ TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+
+ // Parse tree walking utility methods.
+ void popRoot(std::string&, std::string&, std::string&);
+ DOM_Node find(std::string&);
+ DOM_Node find(DOM_Node, std::string&);
+
+ // Loading of the base elements of the file.
+ void getGeneral(DOM_Node, GeneralConfig&);
+ void getCertAuth(DOM_Node, CertificateAuthority&);
+ void getBaseCerts(DOM_Node, BaseCertificates&);
+ void getTempCerts(DOM_Node, TempCertificates&);
+
+ // Loading of temporary certificates/params (Ephemeral Keys).
+ void loadDHParams(DOM_Node, TempCertificates&);
+ void loadRSACert(DOM_Node, TempCertificates&);
+
+ // Populate with information from the indicated node in the parse tree.
+ void getCert(DOM_Node, CertificateDesc&);
+ void getDHParams(DOM_Node, DiffieHellmanParamsFile&);
+
+ // Populate a certificate file object, basis of all certificates.
+ void loadCertificateFile(DOM_Node, CertificateFile&);
+
+ // Parses the certificate encoding format from a string representation
+ // to the proper integer value used by the underlying SSL framework.
+ int parseEncoding(std::string&);
+
+ std::string toString(const DOMString&);
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/ConfigParserErrorReporter.cpp b/cpp/src/IceSSL/ConfigParserErrorReporter.cpp index 9a0fb2e4576..0f30587055d 100644 --- a/cpp/src/IceSSL/ConfigParserErrorReporter.cpp +++ b/cpp/src/IceSSL/ConfigParserErrorReporter.cpp @@ -37,7 +37,7 @@ IceSSL::ConfigParserErrorReporter::~ConfigParserErrorReporter() void IceSSL::ConfigParserErrorReporter::warning(const SAXParseException& toCatch) { - if (_traceLevels->security >= IceSSL::SECURITY_PARSE_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_PARSE_WARNINGS) { ostringstream s; diff --git a/cpp/src/IceSSL/ConfigParserErrorReporter.h b/cpp/src/IceSSL/ConfigParserErrorReporter.h index 2b94b4c1d74..192917fd2d8 100644 --- a/cpp/src/IceSSL/ConfigParserErrorReporter.h +++ b/cpp/src/IceSSL/ConfigParserErrorReporter.h @@ -1,63 +1,63 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONFIG_ERROR_REPORTER_H -#define ICE_SSL_CONFIG_ERROR_REPORTER_H - -#include <Ice/LoggerF.h> -#include <IceSSL/TraceLevelsF.h> -#include <util/XercesDefs.hpp> -#include <dom/DOMString.hpp> -#include <sax/ErrorHandler.hpp> - -namespace IceSSL -{ - -class ConfigParserErrorReporter : public ErrorHandler, public IceUtil::Shared -{ -public: - - ConfigParserErrorReporter(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&); - ~ConfigParserErrorReporter(); - - // Implementation of the error handler interface. - void warning(const SAXParseException& toCatch); - void error(const SAXParseException& toCatch); - void fatalError(const SAXParseException& toCatch); - void resetErrors(); - - bool getSawErrors() const; - std::string getErrors() const; - -private: - - IceSSL::TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; - - // Any errors that are encountered will be output to this stream. - std::ostringstream _errors; - int _errorCount; -}; - -typedef IceInternal::Handle<ConfigParserErrorReporter> ConfigParserErrorReporterPtr; - -std::ostream& operator << (std::ostream& target, const DOMString& s); - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::ConfigParserErrorReporter*); -void decRef(::IceSSL::ConfigParserErrorReporter*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONFIG_ERROR_REPORTER_H
+#define ICE_SSL_CONFIG_ERROR_REPORTER_H
+
+#include <Ice/LoggerF.h>
+#include <IceSSL/TraceLevelsF.h>
+#include <util/XercesDefs.hpp>
+#include <dom/DOMString.hpp>
+#include <sax/ErrorHandler.hpp>
+
+namespace IceSSL
+{
+
+class ConfigParserErrorReporter : public ErrorHandler, public IceUtil::Shared
+{
+public:
+
+ ConfigParserErrorReporter(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&);
+ ~ConfigParserErrorReporter();
+
+ // Implementation of the error handler interface.
+ void warning(const SAXParseException& toCatch);
+ void error(const SAXParseException& toCatch);
+ void fatalError(const SAXParseException& toCatch);
+ void resetErrors();
+
+ bool getSawErrors() const;
+ std::string getErrors() const;
+
+private:
+
+ IceSSL::TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+
+ // Any errors that are encountered will be output to this stream.
+ std::ostringstream _errors;
+ int _errorCount;
+};
+
+typedef IceInternal::Handle<ConfigParserErrorReporter> ConfigParserErrorReporterPtr;
+
+std::ostream& operator << (std::ostream& target, const DOMString& s);
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::ConfigParserErrorReporter*);
+void decRef(::IceSSL::ConfigParserErrorReporter*);
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/ContextOpenSSL.cpp b/cpp/src/IceSSL/ContextOpenSSL.cpp index af94d715f7f..20ba1eca7b9 100644 --- a/cpp/src/IceSSL/ContextOpenSSL.cpp +++ b/cpp/src/IceSSL/ContextOpenSSL.cpp @@ -34,7 +34,7 @@ void ::IceInternal::decRef(::IceSSL::OpenSSL::Context* p) { p->__decRef(); } IceSSL::OpenSSL::Context::~Context() { - if (_sslContext != 0) + if(_sslContext != 0) { SSL_CTX_free(_sslContext); @@ -74,7 +74,7 @@ void IceSSL::OpenSSL::Context::setRSAKeysBase64(const string& privateKey, const string& publicKey) { - if (privateKey.empty()) + if(privateKey.empty()) { IceSSL::PrivateKeyException privateKeyEx(__FILE__, __LINE__); @@ -89,7 +89,7 @@ IceSSL::OpenSSL::Context::setRSAKeysBase64(const string& privateKey, void IceSSL::OpenSSL::Context::setRSAKeys(const Ice::ByteSeq& privateKey, const Ice::ByteSeq& publicKey) { - if (privateKey.empty()) + if(privateKey.empty()) { IceSSL::PrivateKeyException privateKeyEx(__FILE__, __LINE__); @@ -132,7 +132,7 @@ IceSSL::OpenSSL::Context::configure(const GeneralConfig& generalConfig, setKeyCert(baseCertificates.getDSACert(), _dsaPrivateKeyProperty, _dsaPublicKeyProperty); // Set the DH key agreement parameters. - if (baseCertificates.getDHParams().getKeySize() != 0) + if(baseCertificates.getDHParams().getKeySize() != 0) { setDHParams(baseCertificates); } @@ -159,7 +159,7 @@ IceSSL::OpenSSL::Context::getSslMethod(SslProtocol sslVersion) { SSL_METHOD* sslMethod = 0; - switch (sslVersion) + switch(sslVersion) { case SSL_V2 : { @@ -187,7 +187,7 @@ IceSSL::OpenSSL::Context::getSslMethod(SslProtocol sslVersion) default : { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { string errorString; @@ -207,7 +207,7 @@ IceSSL::OpenSSL::Context::getSslMethod(SslProtocol sslVersion) void IceSSL::OpenSSL::Context::createContext(SslProtocol sslProtocol) { - if (_sslContext != 0) + if(_sslContext != 0) { SSL_CTX_free(_sslContext); _sslContext = 0; @@ -215,7 +215,7 @@ IceSSL::OpenSSL::Context::createContext(SslProtocol sslProtocol) _sslContext = SSL_CTX_new(getSslMethod(sslProtocol)); - if (_sslContext == 0) + if(_sslContext == 0) { ContextInitializationException contextInitEx(__FILE__, __LINE__); @@ -242,12 +242,12 @@ IceSSL::OpenSSL::Context::loadCertificateAuthority(const CertificateAuthority& c // The following checks are required to send the expected values to the OpenSSL library. // It does not like receiving "", but prefers NULLs. - if (!fileName.empty()) + if(!fileName.empty()) { caFile = fileName.c_str(); } - if (!certPath.length()) + if(!certPath.length()) { caPath = certPath.c_str(); } @@ -257,9 +257,9 @@ IceSSL::OpenSSL::Context::loadCertificateAuthority(const CertificateAuthority& c // Check the Certificate Authority file(s). int loadVerifyRet = SSL_CTX_load_verify_locations(_sslContext, caFile, caPath); - if (!loadVerifyRet) + if(!loadVerifyRet) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { _logger->trace(_traceLevels->securityCat, "WRN unable to load certificate authorities."); } @@ -269,7 +269,7 @@ IceSSL::OpenSSL::Context::loadCertificateAuthority(const CertificateAuthority& c int setDefaultVerifyPathsRet = SSL_CTX_set_default_verify_paths(_sslContext); - if (!setDefaultVerifyPathsRet && (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)) + if(!setDefaultVerifyPathsRet && (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)) { _logger->trace(_traceLevels->securityCat, "WRN unable to verify certificate authorities."); } @@ -277,7 +277,7 @@ IceSSL::OpenSSL::Context::loadCertificateAuthority(const CertificateAuthority& c // Now we add whatever override/addition that we wish to put into the trusted certificates list string caCertBase64 = _properties->getProperty(_caCertificateProperty); - if (!caCertBase64.empty()) + if(!caCertBase64.empty()) { addTrustedCertificateBase64(caCertBase64); } @@ -291,21 +291,21 @@ IceSSL::OpenSSL::Context::setKeyCert(const CertificateDesc& certDesc, string privateKey; string publicKey; - if (!privateProperty.empty()) + if(!privateProperty.empty()) { privateKey = _properties->getProperty(privateProperty); } - if (!publicProperty.empty()) + if(!publicProperty.empty()) { publicKey = _properties->getProperty(publicProperty); } - if (!privateKey.empty() && !publicKey.empty()) + if(!privateKey.empty() && !publicKey.empty()) { addKeyCert(privateKey, publicKey); } - else if (certDesc.getKeySize() != 0) + else if(certDesc.getKeySize() != 0) { const CertificateFile& privateKey = certDesc.getPrivate(); const CertificateFile& publicKey = certDesc.getPublic(); @@ -321,14 +321,14 @@ IceSSL::OpenSSL::Context::checkKeyCert() // Check to see if the Private and Public keys that have been // set against the SSL context match up. - if (!SSL_CTX_check_private_key(_sslContext)) + if(!SSL_CTX_check_private_key(_sslContext)) { CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__); certKeyMatchEx._message = "private key does not match the certificate public key"; string sslError = sslGetErrors(); - if (!sslError.empty()) + if(!sslError.empty()) { certKeyMatchEx._message += "\n"; certKeyMatchEx._message += sslError; @@ -341,7 +341,7 @@ IceSSL::OpenSSL::Context::checkKeyCert() void IceSSL::OpenSSL::Context::addTrustedCertificate(const RSAPublicKey& trustedCertificate) { - if (_sslContext == 0) + if(_sslContext == 0) { ContextNotConfiguredException contextConfigEx(__FILE__, __LINE__); @@ -354,7 +354,7 @@ IceSSL::OpenSSL::Context::addTrustedCertificate(const RSAPublicKey& trustedCerti assert(certStore != 0); - if (X509_STORE_add_cert(certStore, trustedCertificate.getX509PublicKey()) == 0) + if(X509_STORE_add_cert(certStore, trustedCertificate.getX509PublicKey()) == 0) { TrustedCertificateAddException trustEx(__FILE__, __LINE__); @@ -369,7 +369,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce { assert(_sslContext != 0); - if (!publicCert.getFileName().empty()) + if(!publicCert.getFileName().empty()) { string publicCertFile = publicCert.getFileName(); const char* publicFile = publicCertFile.c_str(); @@ -380,7 +380,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce int privKeyFileType = privateKey.getEncoding(); // Set which Public Key file to use. - if (SSL_CTX_use_certificate_file(_sslContext, publicFile, publicEncoding) <= 0) + if(SSL_CTX_use_certificate_file(_sslContext, publicFile, publicEncoding) <= 0) { CertificateLoadException certLoadEx(__FILE__, __LINE__); @@ -392,9 +392,9 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce throw certLoadEx; } - if (privateKey.getFileName().empty()) + if(privateKey.getFileName().empty()) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { _logger->trace(_traceLevels->securityCat, "WRN no private key specified -- using the certificate"); } @@ -407,7 +407,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce int pkLoadResult; int errCode = 0; - while (retryCount != _maxPassphraseTries) + while(retryCount != _maxPassphraseTries) { // We ignore the errors and remove them from the stack. string errorString = sslGetErrors(); @@ -415,7 +415,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce // Set which Private Key file to use. pkLoadResult = SSL_CTX_use_PrivateKey_file(_sslContext, privKeyFile, privKeyFileType); - if (pkLoadResult <= 0) + if(pkLoadResult <= 0) { errCode = ERR_GET_REASON(ERR_peek_error()); } @@ -426,7 +426,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce } // PEM errors, most likely related to a bad passphrase. - if (errCode != PEM_R_BAD_PASSWORD_READ && + if(errCode != PEM_R_BAD_PASSWORD_READ && errCode != PEM_R_BAD_DECRYPT && errCode != PEM_R_BAD_BASE64_DECODE) { @@ -439,20 +439,20 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce retryCount++; } - if (pkLoadResult <= 0) + if(pkLoadResult <= 0) { int errCode = ERR_GET_REASON(ERR_peek_error()); // Note: Because OpenSSL currently (V0.9.6b) performs a check to see if the // key matches the private key when calling SSL_CTX_use_PrivateKey_file(). - if (errCode == X509_R_KEY_VALUES_MISMATCH || errCode == X509_R_KEY_TYPE_MISMATCH) + if(errCode == X509_R_KEY_VALUES_MISMATCH || errCode == X509_R_KEY_TYPE_MISMATCH) { CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__); certKeyMatchEx._message = "private key does not match the certificate public key"; string sslError = sslGetErrors(); - if (!sslError.empty()) + if(!sslError.empty()) { certKeyMatchEx._message += "\n"; certKeyMatchEx._message += sslError; @@ -480,7 +480,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce void IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) { - if (_sslContext == 0) + if(_sslContext == 0) { ContextNotConfiguredException contextConfigEx(__FILE__, __LINE__); @@ -495,14 +495,14 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) // certificate/key memory regardless if the call succeeded. // Set which Public Key file to use. - if (SSL_CTX_use_certificate(_sslContext, keyPair.getX509PublicKey()) <= 0) + if(SSL_CTX_use_certificate(_sslContext, keyPair.getX509PublicKey()) <= 0) { CertificateLoadException certLoadEx(__FILE__, __LINE__); certLoadEx._message = "unable to set certificate from memory"; string sslError = sslGetErrors(); - if (!sslError.empty()) + if(!sslError.empty()) { certLoadEx._message += "\n"; certLoadEx._message += sslError; @@ -512,20 +512,20 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) } // Set which Private Key file to use. - if (SSL_CTX_use_RSAPrivateKey(_sslContext, keyPair.getRSAPrivateKey()) <= 0) + if(SSL_CTX_use_RSAPrivateKey(_sslContext, keyPair.getRSAPrivateKey()) <= 0) { int errCode = ERR_GET_REASON(ERR_peek_error()); // Note: Because OpenSSL currently (V0.9.6b) performs a check to see if the // key matches the private key when calling SSL_CTX_use_PrivateKey_file(). - if (errCode == X509_R_KEY_VALUES_MISMATCH || errCode == X509_R_KEY_TYPE_MISMATCH) + if(errCode == X509_R_KEY_VALUES_MISMATCH || errCode == X509_R_KEY_TYPE_MISMATCH) { CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__); certKeyMatchEx._message = "private key does not match the certificate public key"; string sslError = sslGetErrors(); - if (!sslError.empty()) + if(!sslError.empty()) { certKeyMatchEx._message += "\n"; certKeyMatchEx._message += sslError; @@ -540,7 +540,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) pklEx._message = "unable to set private key from memory"; string sslError = sslGetErrors(); - if (!sslError.empty()) + if(!sslError.empty()) { pklEx._message += "\n"; pklEx._message += sslError; @@ -558,9 +558,9 @@ IceSSL::OpenSSL::Context::addKeyCert(const Ice::ByteSeq& privateKey, const Ice:: { Ice::ByteSeq privKey = privateKey; - if (privKey.empty()) + if(privKey.empty()) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { _logger->trace(_traceLevels->securityCat, "WRN no private key specified -- using the certificate"); } @@ -577,9 +577,9 @@ IceSSL::OpenSSL::Context::addKeyCert(const string& privateKey, const string& pub { string privKey = privateKey; - if (privKey.empty()) + if(privKey.empty()) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { _logger->trace(_traceLevels->securityCat, "WRN no private key specified -- using the certificate"); } @@ -620,7 +620,7 @@ IceSSL::OpenSSL::Context::setCipherList(const string& cipherList) { assert(_sslContext != 0); - if (!cipherList.empty() && (!SSL_CTX_set_cipher_list(_sslContext, cipherList.c_str())) && + if(!cipherList.empty() && (!SSL_CTX_set_cipher_list(_sslContext, cipherList.c_str())) && (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)) { string errorString = "WRN error setting cipher list " + cipherList + " -- using default list\n"; @@ -638,14 +638,14 @@ IceSSL::OpenSSL::Context::setDHParams(const BaseCertificates& baseCerts) int encoding = baseCerts.getDHParams().getEncoding(); // File type must be PEM - that's the only way we can load DH Params, apparently. - if ((!dhFile.empty()) && (encoding == SSL_FILETYPE_PEM)) + if((!dhFile.empty()) && (encoding == SSL_FILETYPE_PEM)) { dh = loadDHParam(dhFile.c_str()); } - if (dh == 0) + if(dh == 0) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { _logger->trace(_traceLevels->securityCat, "WRN Could not load Diffie-Hellman params, generating a temporary 512bit key."); @@ -654,7 +654,7 @@ IceSSL::OpenSSL::Context::setDHParams(const BaseCertificates& baseCerts) dh = getTempDH512(); } - if (dh != 0) + if(dh != 0) { SSL_CTX_set_tmp_dh(_sslContext, dh); diff --git a/cpp/src/IceSSL/ContextOpenSSL.h b/cpp/src/IceSSL/ContextOpenSSL.h index b8933cbb69e..0d885c0ffdb 100644 --- a/cpp/src/IceSSL/ContextOpenSSL.h +++ b/cpp/src/IceSSL/ContextOpenSSL.h @@ -1,120 +1,120 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONTEXT_OPENSSL_H -#define ICE_SSL_CONTEXT_OPENSSL_H - -#include <Ice/LoggerF.h> -#include <Ice/PropertiesF.h> -#include <Ice/BuiltinSequences.h> -#include <IceSSL/OpenSSL.h> -#include <IceSSL/TraceLevelsF.h> -#include <IceSSL/CertificateVerifierOpenSSL.h> -#include <IceSSL/GeneralConfig.h> -#include <IceSSL/CertificateAuthority.h> -#include <IceSSL/BaseCerts.h> -#include <IceSSL/TempCerts.h> -#include <IceSSL/SslConnectionF.h> -#include <IceSSL/SslConnectionOpenSSLF.h> -#include <IceSSL/ContextOpenSSLF.h> -#include <IceSSL/RSAPublicKey.h> -#include <IceSSL/RSAKeyPairF.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class PluginI; - -class Context : public IceUtil::Shared -{ -public: - - virtual ~Context(); - - bool isConfigured(); - - virtual void setCertificateVerifier(const CertificateVerifierPtr&); - - virtual void addTrustedCertificateBase64(const std::string&); - - virtual void addTrustedCertificate(const Ice::ByteSeq&); - - virtual void setRSAKeysBase64(const std::string&, const std::string&); - - virtual void setRSAKeys(const Ice::ByteSeq&, const Ice::ByteSeq&); - - virtual void configure(const IceSSL::GeneralConfig&, - const IceSSL::CertificateAuthority&, - const IceSSL::BaseCertificates&); - - // Takes a socket fd as the first parameter. - virtual ::IceSSL::ConnectionPtr createConnection(int, const IceSSL::PluginBaseIPtr&) = 0; - -protected: - - Context(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&, const Ice::PropertiesPtr&); - - SSL_METHOD* getSslMethod(SslProtocol); - void createContext(SslProtocol); - - virtual void loadCertificateAuthority(const CertificateAuthority&); - - void setKeyCert(const IceSSL::CertificateDesc&, const std::string&, const std::string&); - - void checkKeyCert(); - - void addTrustedCertificate(const IceSSL::OpenSSL::RSAPublicKey&); - - void addKeyCert(const IceSSL::CertificateFile&, const IceSSL::CertificateFile&); - - void addKeyCert(const RSAKeyPair&); - - void addKeyCert(const Ice::ByteSeq&, const Ice::ByteSeq&); - - void addKeyCert(const std::string&, const std::string&); - - SSL* createSSLConnection(int); - - void connectionSetup(const IceSSL::OpenSSL::ConnectionPtr& connection); - - void setCipherList(const std::string&); - - void setDHParams(const IceSSL::BaseCertificates&); - - IceSSL::TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; - Ice::PropertiesPtr _properties; - - std::string _rsaPrivateKeyProperty; - std::string _rsaPublicKeyProperty; - std::string _dsaPrivateKeyProperty; - std::string _dsaPublicKeyProperty; - std::string _caCertificateProperty; - std::string _handshakeTimeoutProperty; - std::string _passphraseRetriesProperty; - std::string _maxPassphraseRetriesDefault; - - IceSSL::CertificateVerifierPtr _certificateVerifier; - - SSL_CTX* _sslContext; - - int _maxPassphraseTries; - - friend class IceSSL::OpenSSL::PluginI; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONTEXT_OPENSSL_H
+#define ICE_SSL_CONTEXT_OPENSSL_H
+
+#include <Ice/LoggerF.h>
+#include <Ice/PropertiesF.h>
+#include <Ice/BuiltinSequences.h>
+#include <IceSSL/OpenSSL.h>
+#include <IceSSL/TraceLevelsF.h>
+#include <IceSSL/CertificateVerifierOpenSSL.h>
+#include <IceSSL/GeneralConfig.h>
+#include <IceSSL/CertificateAuthority.h>
+#include <IceSSL/BaseCerts.h>
+#include <IceSSL/TempCerts.h>
+#include <IceSSL/SslConnectionF.h>
+#include <IceSSL/SslConnectionOpenSSLF.h>
+#include <IceSSL/ContextOpenSSLF.h>
+#include <IceSSL/RSAPublicKey.h>
+#include <IceSSL/RSAKeyPairF.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class PluginI;
+
+class Context : public IceUtil::Shared
+{
+public:
+
+ virtual ~Context();
+
+ bool isConfigured();
+
+ virtual void setCertificateVerifier(const CertificateVerifierPtr&);
+
+ virtual void addTrustedCertificateBase64(const std::string&);
+
+ virtual void addTrustedCertificate(const Ice::ByteSeq&);
+
+ virtual void setRSAKeysBase64(const std::string&, const std::string&);
+
+ virtual void setRSAKeys(const Ice::ByteSeq&, const Ice::ByteSeq&);
+
+ virtual void configure(const IceSSL::GeneralConfig&,
+ const IceSSL::CertificateAuthority&,
+ const IceSSL::BaseCertificates&);
+
+ // Takes a socket fd as the first parameter.
+ virtual ::IceSSL::ConnectionPtr createConnection(int, const IceSSL::PluginBaseIPtr&) = 0;
+
+protected:
+
+ Context(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&, const Ice::PropertiesPtr&);
+
+ SSL_METHOD* getSslMethod(SslProtocol);
+ void createContext(SslProtocol);
+
+ virtual void loadCertificateAuthority(const CertificateAuthority&);
+
+ void setKeyCert(const IceSSL::CertificateDesc&, const std::string&, const std::string&);
+
+ void checkKeyCert();
+
+ void addTrustedCertificate(const IceSSL::OpenSSL::RSAPublicKey&);
+
+ void addKeyCert(const IceSSL::CertificateFile&, const IceSSL::CertificateFile&);
+
+ void addKeyCert(const RSAKeyPair&);
+
+ void addKeyCert(const Ice::ByteSeq&, const Ice::ByteSeq&);
+
+ void addKeyCert(const std::string&, const std::string&);
+
+ SSL* createSSLConnection(int);
+
+ void connectionSetup(const IceSSL::OpenSSL::ConnectionPtr& connection);
+
+ void setCipherList(const std::string&);
+
+ void setDHParams(const IceSSL::BaseCertificates&);
+
+ IceSSL::TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+ Ice::PropertiesPtr _properties;
+
+ std::string _rsaPrivateKeyProperty;
+ std::string _rsaPublicKeyProperty;
+ std::string _dsaPrivateKeyProperty;
+ std::string _dsaPublicKeyProperty;
+ std::string _caCertificateProperty;
+ std::string _handshakeTimeoutProperty;
+ std::string _passphraseRetriesProperty;
+ std::string _maxPassphraseRetriesDefault;
+
+ IceSSL::CertificateVerifierPtr _certificateVerifier;
+
+ SSL_CTX* _sslContext;
+
+ int _maxPassphraseTries;
+
+ friend class IceSSL::OpenSSL::PluginI;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/ContextOpenSSLClient.cpp b/cpp/src/IceSSL/ContextOpenSSLClient.cpp index a16406bcfb7..185da70b4b5 100644 --- a/cpp/src/IceSSL/ContextOpenSSLClient.cpp +++ b/cpp/src/IceSSL/ContextOpenSSLClient.cpp @@ -30,7 +30,7 @@ IceSSL::OpenSSL::ClientContext::configure(const GeneralConfig& generalConfig, loadCertificateAuthority(certificateAuthority); - if (_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) + if(_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) { ostringstream s; @@ -55,7 +55,7 @@ IceSSL::OpenSSL::ClientContext::configure(const GeneralConfig& generalConfig, IceSSL::ConnectionPtr IceSSL::OpenSSL::ClientContext::createConnection(int socket, const PluginBaseIPtr& plugin) { - if (_sslContext == 0) + if(_sslContext == 0) { IceSSL::OpenSSL::ContextNotConfiguredException contextEx(__FILE__, __LINE__); diff --git a/cpp/src/IceSSL/ContextOpenSSLClient.h b/cpp/src/IceSSL/ContextOpenSSLClient.h index 263078a53e9..8c4036db20e 100644 --- a/cpp/src/IceSSL/ContextOpenSSLClient.h +++ b/cpp/src/IceSSL/ContextOpenSSLClient.h @@ -1,44 +1,44 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONTEXT_OPENSSL_CLIENT_H -#define ICE_SSL_CONTEXT_OPENSSL_CLIENT_H - -#include <IceSSL/ContextOpenSSL.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ClientContext : public Context -{ -public: - - virtual void configure(const IceSSL::GeneralConfig&, - const IceSSL::CertificateAuthority&, - const IceSSL::BaseCertificates&); - - // Takes a socket fd as the first parameter. - virtual IceSSL::ConnectionPtr createConnection(int, const IceSSL::PluginBaseIPtr&); - -protected: - - ClientContext(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&, const Ice::PropertiesPtr&); - - friend class IceSSL::OpenSSL::PluginI; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONTEXT_OPENSSL_CLIENT_H
+#define ICE_SSL_CONTEXT_OPENSSL_CLIENT_H
+
+#include <IceSSL/ContextOpenSSL.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ClientContext : public Context
+{
+public:
+
+ virtual void configure(const IceSSL::GeneralConfig&,
+ const IceSSL::CertificateAuthority&,
+ const IceSSL::BaseCertificates&);
+
+ // Takes a socket fd as the first parameter.
+ virtual IceSSL::ConnectionPtr createConnection(int, const IceSSL::PluginBaseIPtr&);
+
+protected:
+
+ ClientContext(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&, const Ice::PropertiesPtr&);
+
+ friend class IceSSL::OpenSSL::PluginI;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/ContextOpenSSLF.h b/cpp/src/IceSSL/ContextOpenSSLF.h index fd338e10a58..322c3d0b5aa 100644 --- a/cpp/src/IceSSL/ContextOpenSSLF.h +++ b/cpp/src/IceSSL/ContextOpenSSLF.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONTEXT_OPENSSL_F_H -#define ICE_SSL_CONTEXT_OPENSSL_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class Context; -typedef IceInternal::Handle<Context> ContextPtr; - -} - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::OpenSSL::Context*); -void decRef(::IceSSL::OpenSSL::Context*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONTEXT_OPENSSL_F_H
+#define ICE_SSL_CONTEXT_OPENSSL_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class Context;
+typedef IceInternal::Handle<Context> ContextPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::OpenSSL::Context*);
+void decRef(::IceSSL::OpenSSL::Context*);
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/ContextOpenSSLServer.cpp b/cpp/src/IceSSL/ContextOpenSSLServer.cpp index 462b50bd520..90f571b2c92 100644 --- a/cpp/src/IceSSL/ContextOpenSSLServer.cpp +++ b/cpp/src/IceSSL/ContextOpenSSLServer.cpp @@ -51,7 +51,7 @@ IceSSL::OpenSSL::ServerContext::configure(const GeneralConfig& generalConfig, reinterpret_cast<const unsigned char *>(connectionContext.c_str()), connectionContext.size()); - if (_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) + if(_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) { ostringstream s; @@ -74,7 +74,7 @@ IceSSL::OpenSSL::ServerContext::configure(const GeneralConfig& generalConfig, IceSSL::ConnectionPtr IceSSL::OpenSSL::ServerContext::createConnection(int socket, const PluginBaseIPtr& plugin) { - if (_sslContext == 0) + if(_sslContext == 0) { ContextNotConfiguredException contextEx(__FILE__, __LINE__); @@ -114,16 +114,16 @@ IceSSL::OpenSSL::ServerContext::loadCertificateAuthority(const CertificateAuthor string caFile = certAuth.getCAFileName(); - if (caFile.empty()) + if(caFile.empty()) { return; } STACK_OF(X509_NAME)* certNames = SSL_load_client_CA_file(caFile.c_str()); - if (certNames == 0) + if(certNames == 0) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { string errorString = "unable to load certificate authorities certificate names from " + caFile + "\n"; errorString += sslGetErrors(); diff --git a/cpp/src/IceSSL/ContextOpenSSLServer.h b/cpp/src/IceSSL/ContextOpenSSLServer.h index 4818d0bfc82..66fa31d13c3 100644 --- a/cpp/src/IceSSL/ContextOpenSSLServer.h +++ b/cpp/src/IceSSL/ContextOpenSSLServer.h @@ -1,46 +1,46 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONTEXT_OPENSSL_SERVER_H -#define ICE_SSL_CONTEXT_OPENSSL_SERVER_H - -#include <IceSSL/ContextOpenSSL.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ServerContext : public Context -{ -public: - - virtual void configure(const IceSSL::GeneralConfig&, - const IceSSL::CertificateAuthority&, - const IceSSL::BaseCertificates&); - - // Takes a socket fd as the first parameter. - virtual IceSSL::ConnectionPtr createConnection(int, const IceSSL::PluginBaseIPtr&); - -protected: - - ServerContext(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&, const Ice::PropertiesPtr&); - - virtual void loadCertificateAuthority(const IceSSL::CertificateAuthority& certAuth); - - friend class IceSSL::OpenSSL::PluginI; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONTEXT_OPENSSL_SERVER_H
+#define ICE_SSL_CONTEXT_OPENSSL_SERVER_H
+
+#include <IceSSL/ContextOpenSSL.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ServerContext : public Context
+{
+public:
+
+ virtual void configure(const IceSSL::GeneralConfig&,
+ const IceSSL::CertificateAuthority&,
+ const IceSSL::BaseCertificates&);
+
+ // Takes a socket fd as the first parameter.
+ virtual IceSSL::ConnectionPtr createConnection(int, const IceSSL::PluginBaseIPtr&);
+
+protected:
+
+ ServerContext(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&, const Ice::PropertiesPtr&);
+
+ virtual void loadCertificateAuthority(const IceSSL::CertificateAuthority& certAuth);
+
+ friend class IceSSL::OpenSSL::PluginI;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/Convert.h b/cpp/src/IceSSL/Convert.h index a4bce9fdbd9..ea5e2452d6f 100644 --- a/cpp/src/IceSSL/Convert.h +++ b/cpp/src/IceSSL/Convert.h @@ -1,26 +1,26 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONVERT_H -#define ICE_SSL_CONVERT_H - -#include <Ice/BuiltinSequences.h> - -namespace IceSSL -{ - -void ucharToByteSeq(unsigned char*, int, Ice::ByteSeq&); - -unsigned char* byteSeqToUChar(const Ice::ByteSeq&); - -} - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONVERT_H
+#define ICE_SSL_CONVERT_H
+
+#include <Ice/BuiltinSequences.h>
+
+namespace IceSSL
+{
+
+void ucharToByteSeq(unsigned char*, int, Ice::ByteSeq&);
+
+unsigned char* byteSeqToUChar(const Ice::ByteSeq&);
+
+}
+
+#endif
+
diff --git a/cpp/src/IceSSL/DHParams.cpp b/cpp/src/IceSSL/DHParams.cpp index bde584bf7ff..6980487d179 100644 --- a/cpp/src/IceSSL/DHParams.cpp +++ b/cpp/src/IceSSL/DHParams.cpp @@ -21,7 +21,7 @@ IceSSL::OpenSSL::DHParams::DHParams(DH* dhParams) : IceSSL::OpenSSL::DHParams::~DHParams() { - if (_dhParams != 0) + if(_dhParams != 0) { DH_free(_dhParams); } diff --git a/cpp/src/IceSSL/DHParams.h b/cpp/src/IceSSL/DHParams.h index 446917a1c09..1981d2dae8d 100644 --- a/cpp/src/IceSSL/DHParams.h +++ b/cpp/src/IceSSL/DHParams.h @@ -1,45 +1,45 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DH_PARAMS_H -#define ICE_DH_PARAMS_H - -#include <IceUtil/Shared.h> -#include <IceSSL/DHParamsF.h> -#include <openssl/ssl.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class DHParams : public IceUtil::Shared -{ -public: - - // Construction from DH Params structure (simple initialization). - DHParams(DH*); - - ~DHParams(); - - // Get the internal key structure as per the OpenSSL implementation. - DH* get() const; - -private: - - DH* _dhParams; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DH_PARAMS_H
+#define ICE_DH_PARAMS_H
+
+#include <IceUtil/Shared.h>
+#include <IceSSL/DHParamsF.h>
+#include <openssl/ssl.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class DHParams : public IceUtil::Shared
+{
+public:
+
+ // Construction from DH Params structure (simple initialization).
+ DHParams(DH*);
+
+ ~DHParams();
+
+ // Get the internal key structure as per the OpenSSL implementation.
+ DH* get() const;
+
+private:
+
+ DH* _dhParams;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/DHParamsF.h b/cpp/src/IceSSL/DHParamsF.h index abe97b9f4e6..b8b8274ec88 100644 --- a/cpp/src/IceSSL/DHParamsF.h +++ b/cpp/src/IceSSL/DHParamsF.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_DH_PARAMS_F_H -#define ICE_DH_PARAMS_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class DHParams; -typedef IceInternal::Handle<DHParams> DHParamsPtr; - -} - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::OpenSSL::DHParams*); -void decRef(::IceSSL::OpenSSL::DHParams*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DH_PARAMS_F_H
+#define ICE_DH_PARAMS_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class DHParams;
+typedef IceInternal::Handle<DHParams> DHParamsPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::OpenSSL::DHParams*);
+void decRef(::IceSSL::OpenSSL::DHParams*);
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/DefaultCertificateVerifier.cpp b/cpp/src/IceSSL/DefaultCertificateVerifier.cpp index 3df5f085e98..4fd1789cd62 100644 --- a/cpp/src/IceSSL/DefaultCertificateVerifier.cpp +++ b/cpp/src/IceSSL/DefaultCertificateVerifier.cpp @@ -38,11 +38,11 @@ IceSSL::OpenSSL::DefaultCertificateVerifier::verify(int preVerifyOkay, X509_STOR int verifyDepth = SSL_get_verify_depth(sslConnection); // A verify error has been encountered. - if (verifyError != X509_V_OK) + if(verifyError != X509_V_OK) { // We have a limited verify depth, and we have had to delve too deeply // into the certificate chain to find an acceptable root certificate. - if ((verifyDepth != -1) && (verifyDepth < errorDepth)) + if((verifyDepth != -1) && (verifyDepth < errorDepth)) { verifyError = X509_V_ERR_CERT_CHAIN_TOO_LONG; X509_STORE_CTX_set_error(x509StoreContext, verifyError); @@ -53,7 +53,7 @@ IceSSL::OpenSSL::DefaultCertificateVerifier::verify(int preVerifyOkay, X509_STOR } // Only if ICE_PROTOCOL level logging is on do we worry about this. - if (_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) + if(_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) { char buf[256]; @@ -65,14 +65,14 @@ IceSSL::OpenSSL::DefaultCertificateVerifier::verify(int preVerifyOkay, X509_STOR outStringStream << "depth = " << dec << errorDepth << ":" << buf << std::endl; - if (!preVerifyOkay) + if(!preVerifyOkay) { outStringStream << "verify error: num = " << verifyError << " : " << X509_verify_cert_error_string(verifyError) << endl; } - switch (verifyError) + switch(verifyError) { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: { diff --git a/cpp/src/IceSSL/DefaultCertificateVerifier.h b/cpp/src/IceSSL/DefaultCertificateVerifier.h index 05e99716105..c465cd52be4 100644 --- a/cpp/src/IceSSL/DefaultCertificateVerifier.h +++ b/cpp/src/IceSSL/DefaultCertificateVerifier.h @@ -1,42 +1,42 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_DEFAULT_CERTIFICATE_VERIFIER_H -#define ICE_SSL_DEFAULT_CERTIFICATE_VERIFIER_H - -#include <Ice/LoggerF.h> -#include <IceSSL/TraceLevelsF.h> -#include <IceSSL/CertificateVerifierOpenSSL.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class DefaultCertificateVerifier : public IceSSL::OpenSSL::CertificateVerifier -{ -public: - - DefaultCertificateVerifier(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&); - - virtual int verify(int, X509_STORE_CTX*, SSL*); - -private: - - IceSSL::TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_DEFAULT_CERTIFICATE_VERIFIER_H
+#define ICE_SSL_DEFAULT_CERTIFICATE_VERIFIER_H
+
+#include <Ice/LoggerF.h>
+#include <IceSSL/TraceLevelsF.h>
+#include <IceSSL/CertificateVerifierOpenSSL.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class DefaultCertificateVerifier : public IceSSL::OpenSSL::CertificateVerifier
+{
+public:
+
+ DefaultCertificateVerifier(const IceSSL::TraceLevelsPtr&, const Ice::LoggerPtr&);
+
+ virtual int verify(int, X509_STORE_CTX*, SSL*);
+
+private:
+
+ IceSSL::TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/GeneralConfig.cpp b/cpp/src/IceSSL/GeneralConfig.cpp index 541614d8ad4..f33230c0455 100644 --- a/cpp/src/IceSSL/GeneralConfig.cpp +++ b/cpp/src/IceSSL/GeneralConfig.cpp @@ -68,27 +68,27 @@ IceSSL::GeneralConfig::getRandomBytesFiles() const void IceSSL::GeneralConfig::set(string& name, string& value) { - if (name.compare("version") == 0) + if(name.compare("version") == 0) { parseVersion(value); } - else if (name.compare("cipherlist") == 0) + else if(name.compare("cipherlist") == 0) { _cipherList = value; } - else if (name.compare("context") == 0) + else if(name.compare("context") == 0) { _context = value; } - else if (name.compare("verifymode") == 0) + else if(name.compare("verifymode") == 0) { parseVerifyMode(value); } - else if (name.compare("verifydepth") == 0) + else if(name.compare("verifydepth") == 0) { _verifyDepth = atoi(value.c_str()); } - else if (name.compare("randombytes") == 0) + else if(name.compare("randombytes") == 0) { _randomBytesFiles = value; } @@ -102,19 +102,19 @@ IceSSL::GeneralConfig::set(string& name, string& value) void IceSSL::GeneralConfig::parseVersion(string& value) { - if (value.compare("SSLv2") == 0) + if(value.compare("SSLv2") == 0) { _sslVersion = SSL_V2; } - else if (value.compare("SSLv23") == 0) + else if(value.compare("SSLv23") == 0) { _sslVersion = SSL_V23; } - else if (value.compare("SSLv3") == 0) + else if(value.compare("SSLv3") == 0) { _sslVersion = SSL_V3; } - else if (value.compare("TLSv1") == 0) + else if(value.compare("TLSv1") == 0) { _sslVersion = TLS_V1; } @@ -133,37 +133,37 @@ IceSSL::GeneralConfig::parseVerifyMode(string& value) string::size_type beg; string::size_type end = 0; - while (true) + while(true) { beg = s.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } end = s.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = s.length(); } string option = s.substr(beg, end - beg); - if (option.compare("none") == 0) + if(option.compare("none") == 0) { _verifyMode |= SSL_VERIFY_NONE; } - else if (option.compare("peer") == 0) + else if(option.compare("peer") == 0) { _verifyMode |= SSL_VERIFY_PEER; } - else if (option.compare("fail_no_cert") == 0) + else if(option.compare("fail_no_cert") == 0) { _verifyMode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; } - else if (option.compare("client_once") == 0) + else if(option.compare("client_once") == 0) { _verifyMode |= SSL_VERIFY_CLIENT_ONCE; } @@ -171,7 +171,7 @@ IceSSL::GeneralConfig::parseVerifyMode(string& value) // Both SSL_VERIFY_FAIL_IF_NO_PEER_CERT and SSL_VERIFY_CLIENT_ONCE require // that SSL_VERIFY_PEER be set, otherwise it's an error. - if ((_verifyMode != SSL_VERIFY_NONE) && !(_verifyMode & SSL_VERIFY_PEER)) + if((_verifyMode != SSL_VERIFY_NONE) && !(_verifyMode & SSL_VERIFY_PEER)) { _verifyMode = SSL_VERIFY_NONE; } diff --git a/cpp/src/IceSSL/GeneralConfig.h b/cpp/src/IceSSL/GeneralConfig.h index c9bca2c9090..967347adf29 100644 --- a/cpp/src/IceSSL/GeneralConfig.h +++ b/cpp/src/IceSSL/GeneralConfig.h @@ -1,66 +1,66 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_GENERAL_CONFIG_H -#define ICE_SSL_GENERAL_CONFIG_H - -#include <IceSSL/OpenSSL.h> - -namespace IceSSL -{ - -class GeneralConfig -{ -public: - - GeneralConfig(); - - SslProtocol getProtocol() const; - int getVerifyMode() const; - int getVerifyDepth() const; - - std::string getContext() const; - std::string getCipherList() const; - std::string getRandomBytesFiles() const; - - // General method - it will figure out how to properly parse the data. - void set(std::string&, std::string&); - -protected: - - SslProtocol _sslVersion; - - int _verifyMode; - int _verifyDepth; - - std::string _context; - std::string _cipherList; - std::string _randomBytesFiles; - - void parseVersion(std::string&); - void parseVerifyMode(std::string&); -}; - -template<class Stream> inline -Stream& operator << (Stream& target, const GeneralConfig& generalConfig) -{ - target << "Protocol: " << generalConfig.getProtocol() << std::endl; - target << "Verify Mode: " << generalConfig.getVerifyMode() << std::endl; - target << "Verify Depth: " << generalConfig.getVerifyDepth() << std::endl; - target << "Context: " << generalConfig.getContext() << std::endl; - target << "Cipher List: " << generalConfig.getCipherList() << std::endl; - target << "Random Bytes: " << generalConfig.getRandomBytesFiles() << std::endl; - - return target; -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_GENERAL_CONFIG_H
+#define ICE_SSL_GENERAL_CONFIG_H
+
+#include <IceSSL/OpenSSL.h>
+
+namespace IceSSL
+{
+
+class GeneralConfig
+{
+public:
+
+ GeneralConfig();
+
+ SslProtocol getProtocol() const;
+ int getVerifyMode() const;
+ int getVerifyDepth() const;
+
+ std::string getContext() const;
+ std::string getCipherList() const;
+ std::string getRandomBytesFiles() const;
+
+ // General method - it will figure out how to properly parse the data.
+ void set(std::string&, std::string&);
+
+protected:
+
+ SslProtocol _sslVersion;
+
+ int _verifyMode;
+ int _verifyDepth;
+
+ std::string _context;
+ std::string _cipherList;
+ std::string _randomBytesFiles;
+
+ void parseVersion(std::string&);
+ void parseVerifyMode(std::string&);
+};
+
+template<class Stream> inline
+Stream& operator << (Stream& target, const GeneralConfig& generalConfig)
+{
+ target << "Protocol: " << generalConfig.getProtocol() << std::endl;
+ target << "Verify Mode: " << generalConfig.getVerifyMode() << std::endl;
+ target << "Verify Depth: " << generalConfig.getVerifyDepth() << std::endl;
+ target << "Context: " << generalConfig.getContext() << std::endl;
+ target << "Cipher List: " << generalConfig.getCipherList() << std::endl;
+ target << "Random Bytes: " << generalConfig.getRandomBytesFiles() << std::endl;
+
+ return target;
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/OpenSSL.h b/cpp/src/IceSSL/OpenSSL.h index 978f2c85ce8..463c036247d 100644 --- a/cpp/src/IceSSL/OpenSSL.h +++ b/cpp/src/IceSSL/OpenSSL.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_OPENSSL_H -#define ICE_OPENSSL_H - -#include <IceUtil/Config.h> -#include <openssl/ssl.h> - -namespace IceSSL -{ - -typedef enum -{ - NO_SECURITY_TRACE = 0, - SECURITY_WARNINGS, - SECURITY_PARSE_WARNINGS, - SECURITY_PROTOCOL, - SECURITY_PROTOCOL_DEBUG -} SecurityTraceLevel; - -enum SslProtocol -{ - SSL_V2 = 1, // Only speak SSLv2 - SSL_V23, // Speak SSLv2 and SSLv3 - SSL_V3, // Only speak SSLv3 - TLS_V1 // Only speak TLSv1 -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_OPENSSL_H
+#define ICE_OPENSSL_H
+
+#include <IceUtil/Config.h>
+#include <openssl/ssl.h>
+
+namespace IceSSL
+{
+
+typedef enum
+{
+ NO_SECURITY_TRACE = 0,
+ SECURITY_WARNINGS,
+ SECURITY_PARSE_WARNINGS,
+ SECURITY_PROTOCOL,
+ SECURITY_PROTOCOL_DEBUG
+} SecurityTraceLevel;
+
+enum SslProtocol
+{
+ SSL_V2 = 1, // Only speak SSLv2
+ SSL_V23, // Speak SSLv2 and SSLv3
+ SSL_V3, // Only speak SSLv3
+ TLS_V1 // Only speak TLSv1
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/OpenSSLJanitors.cpp b/cpp/src/IceSSL/OpenSSLJanitors.cpp index 7779f3a0959..dda448e67ed 100644 --- a/cpp/src/IceSSL/OpenSSLJanitors.cpp +++ b/cpp/src/IceSSL/OpenSSLJanitors.cpp @@ -18,7 +18,7 @@ IceSSL::OpenSSL::RSAJanitor::RSAJanitor(RSA* rsa) : IceSSL::OpenSSL::RSAJanitor::~RSAJanitor() { - if (_rsa) + if(_rsa) { RSA_free(_rsa); } @@ -44,7 +44,7 @@ IceSSL::OpenSSL::EVP_PKEYJanitor::EVP_PKEYJanitor(EVP_PKEY* evp_pkey) : IceSSL::OpenSSL::EVP_PKEYJanitor::~EVP_PKEYJanitor() { - if (_evp_pkey) + if(_evp_pkey) { EVP_PKEY_free(_evp_pkey); } @@ -70,7 +70,7 @@ IceSSL::OpenSSL::X509_REQJanitor::X509_REQJanitor(X509_REQ* x509_req) : IceSSL::OpenSSL::X509_REQJanitor::~X509_REQJanitor() { - if (_x509_req) + if(_x509_req) { X509_REQ_free(_x509_req); } @@ -96,7 +96,7 @@ IceSSL::OpenSSL::X509Janitor::X509Janitor(X509* x509) : IceSSL::OpenSSL::X509Janitor::~X509Janitor() { - if (_x509) + if(_x509) { X509_free(_x509); } @@ -122,7 +122,7 @@ IceSSL::OpenSSL::BIOJanitor::BIOJanitor(BIO* bio) : IceSSL::OpenSSL::BIOJanitor::~BIOJanitor() { - if (_bio) + if(_bio) { BIO_free(_bio); } diff --git a/cpp/src/IceSSL/OpenSSLJanitors.h b/cpp/src/IceSSL/OpenSSLJanitors.h index 63802ae50ba..1140d2bc6c7 100644 --- a/cpp/src/IceSSL/OpenSSLJanitors.h +++ b/cpp/src/IceSSL/OpenSSLJanitors.h @@ -1,102 +1,102 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_JANITORS_H -#define ICE_SSL_JANITORS_H - -#include <IceUtil/Config.h> -#include <openssl/ssl.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class RSAJanitor -{ -public: - - RSAJanitor(RSA*); - ~RSAJanitor(); - - void clear(); - RSA* get() const; - -private: - - RSA* _rsa; -}; - -class EVP_PKEYJanitor -{ -public: - - EVP_PKEYJanitor(EVP_PKEY*); - ~EVP_PKEYJanitor(); - - void clear(); - EVP_PKEY* get() const; - -private: - - EVP_PKEY* _evp_pkey; -}; - -class X509_REQJanitor -{ -public: - - X509_REQJanitor(X509_REQ*); - ~X509_REQJanitor(); - - void clear(); - X509_REQ* get() const; - -private: - - X509_REQ* _x509_req; -}; - -class X509Janitor -{ -public: - - X509Janitor(X509*); - ~X509Janitor(); - - void clear(); - X509* get() const; - -private: - - X509* _x509; -}; - -class BIOJanitor -{ -public: - - BIOJanitor(BIO*); - ~BIOJanitor(); - - void clear(); - BIO* get() const; - -private: - - BIO* _bio; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_JANITORS_H
+#define ICE_SSL_JANITORS_H
+
+#include <IceUtil/Config.h>
+#include <openssl/ssl.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class RSAJanitor
+{
+public:
+
+ RSAJanitor(RSA*);
+ ~RSAJanitor();
+
+ void clear();
+ RSA* get() const;
+
+private:
+
+ RSA* _rsa;
+};
+
+class EVP_PKEYJanitor
+{
+public:
+
+ EVP_PKEYJanitor(EVP_PKEY*);
+ ~EVP_PKEYJanitor();
+
+ void clear();
+ EVP_PKEY* get() const;
+
+private:
+
+ EVP_PKEY* _evp_pkey;
+};
+
+class X509_REQJanitor
+{
+public:
+
+ X509_REQJanitor(X509_REQ*);
+ ~X509_REQJanitor();
+
+ void clear();
+ X509_REQ* get() const;
+
+private:
+
+ X509_REQ* _x509_req;
+};
+
+class X509Janitor
+{
+public:
+
+ X509Janitor(X509*);
+ ~X509Janitor();
+
+ void clear();
+ X509* get() const;
+
+private:
+
+ X509* _x509;
+};
+
+class BIOJanitor
+{
+public:
+
+ BIOJanitor(BIO*);
+ ~BIOJanitor();
+
+ void clear();
+ BIO* get() const;
+
+private:
+
+ BIO* _bio;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/OpenSSLPluginI.cpp b/cpp/src/IceSSL/OpenSSLPluginI.cpp index 3c913d40016..a869dd09c05 100644 --- a/cpp/src/IceSSL/OpenSSLPluginI.cpp +++ b/cpp/src/IceSSL/OpenSSLPluginI.cpp @@ -110,7 +110,7 @@ SslLockKeeper lockKeeper; void IceSSL::lockingCallback(int mode, int type, const char *file, int line) { - if (mode & CRYPTO_LOCK) + if(mode & CRYPTO_LOCK) { lockKeeper.sslLocks[type].lock(); } @@ -138,7 +138,7 @@ IceSSL::OpenSSL::PluginI::createConnection(ContextType connectionType, int socke { IceUtil::RecMutex::Lock sync(_configMutex); - if (connectionType == ClientServer) + if(connectionType == ClientServer) { UnsupportedContextException unsupportedException(__FILE__, __LINE__); @@ -148,18 +148,18 @@ IceSSL::OpenSSL::PluginI::createConnection(ContextType connectionType, int socke } // Configure the context if need be. - if (!isConfigured(connectionType)) + if(!isConfigured(connectionType)) { configure(connectionType); } IceSSL::ConnectionPtr connection; - if (connectionType == Client) + if(connectionType == Client) { connection = _clientContext.createConnection(socket, this); } - else if (connectionType == Server) + else if(connectionType == Server) { connection = _serverContext.createConnection(socket, this); } @@ -174,7 +174,7 @@ IceSSL::OpenSSL::PluginI::isConfigured(ContextType contextType) bool retCode = false; - switch (contextType) + switch(contextType) { case Client : { @@ -207,15 +207,15 @@ IceSSL::OpenSSL::PluginI::configure() bool clientConfig = (clientConfigFile.empty() ? false : true); bool serverConfig = (serverConfigFile.empty() ? false : true); - if (clientConfig && serverConfig) + if(clientConfig && serverConfig) { configure(ClientServer); } - else if (clientConfig) + else if(clientConfig) { configure(Client); } - else if (serverConfig) + else if(serverConfig) { configure(Server); } @@ -226,7 +226,7 @@ IceSSL::OpenSSL::PluginI::configure(ContextType contextType) { IceUtil::RecMutex::Lock sync(_configMutex); - switch (contextType) + switch(contextType) { case Client : { @@ -252,7 +252,7 @@ IceSSL::OpenSSL::PluginI::configure(ContextType contextType) string serverCertPath = _properties->getProperty("IceSSL.Server.CertPath"); // Short cut, so that we only have to load the file once. - if ((clientConfigFile == serverConfigFile) && (clientCertPath == serverCertPath)) + if((clientConfigFile == serverConfigFile) && (clientCertPath == serverCertPath)) { loadConfig(ClientServer, clientConfigFile, clientCertPath); } @@ -271,13 +271,13 @@ IceSSL::OpenSSL::PluginI::loadConfig(ContextType contextType, const std::string& configFile, const std::string& certPath) { - if (configFile.empty()) + if(configFile.empty()) { ConfigurationLoadingException configEx(__FILE__, __LINE__); string contextString; - switch (contextType) + switch(contextType) { case Client : { @@ -312,14 +312,14 @@ IceSSL::OpenSSL::PluginI::loadConfig(ContextType contextType, // Actually parse the file now. sslConfig.process(); - if ((contextType == Client || contextType == ClientServer)) + if((contextType == Client || contextType == ClientServer)) { GeneralConfig clientGeneral; CertificateAuthority clientCertAuth; BaseCertificates clientBaseCerts; // Walk the parse tree, get the Client configuration. - if (sslConfig.loadClientConfig(clientGeneral, clientCertAuth, clientBaseCerts)) + if(sslConfig.loadClientConfig(clientGeneral, clientCertAuth, clientBaseCerts)) { initRandSystem(clientGeneral.getRandomBytesFiles()); @@ -327,7 +327,7 @@ IceSSL::OpenSSL::PluginI::loadConfig(ContextType contextType, } } - if ((contextType == Server || contextType == ClientServer)) + if((contextType == Server || contextType == ClientServer)) { GeneralConfig serverGeneral; CertificateAuthority serverCertAuth; @@ -335,7 +335,7 @@ IceSSL::OpenSSL::PluginI::loadConfig(ContextType contextType, TempCertificates serverTempCerts; // Walk the parse tree, get the Server configuration. - if (sslConfig.loadServerConfig(serverGeneral, serverCertAuth, serverBaseCerts, serverTempCerts)) + if(sslConfig.loadServerConfig(serverGeneral, serverCertAuth, serverBaseCerts, serverTempCerts)) { initRandSystem(serverGeneral.getRandomBytesFiles()); @@ -343,7 +343,7 @@ IceSSL::OpenSSL::PluginI::loadConfig(ContextType contextType, _serverContext.configure(serverGeneral, serverCertAuth, serverBaseCerts); - if (_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) + if(_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) { ostringstream s; @@ -367,7 +367,7 @@ IceSSL::OpenSSL::PluginI::getRSAKey(int isExport, int keyLength) RSAMap::iterator retVal = _tempRSAKeys.find(keyLength); // Does the key already exist? - if (retVal != _tempRSAKeys.end()) + if(retVal != _tempRSAKeys.end()) { // Yes! Use it. rsa_tmp = (*retVal).second->get(); @@ -379,7 +379,7 @@ IceSSL::OpenSSL::PluginI::getRSAKey(int isExport, int keyLength) const RSACertMap::iterator& it = _tempRSAFileMap.find(keyLength); // First we try to load a private and public key from specified files - if (it != _tempRSAFileMap.end()) + if(it != _tempRSAFileMap.end()) { CertificateDesc& rsaKeyCert = (*it).second; @@ -390,16 +390,16 @@ IceSSL::OpenSSL::PluginI::getRSAKey(int isExport, int keyLength) RSA* rsaKey = 0; BIO* bio = 0; - if ((bio = BIO_new_file(pubCertFile.c_str(), "r")) != 0) + if((bio = BIO_new_file(pubCertFile.c_str(), "r")) != 0) { BIOJanitor bioJanitor(bio); rsaCert = PEM_read_bio_RSAPublicKey(bio, 0, 0, 0); } - if (rsaCert != 0) + if(rsaCert != 0) { - if ((bio = BIO_new_file(privKeyFile.c_str(), "r")) != 0) + if((bio = BIO_new_file(privKeyFile.c_str(), "r")) != 0) { BIOJanitor bioJanitor(bio); @@ -411,13 +411,13 @@ IceSSL::OpenSSL::PluginI::getRSAKey(int isExport, int keyLength) // rsaCert. We check to ensure that both are not 0, because if either are, // one of the reads failed. - if ((rsaCert != 0) && (rsaKey != 0)) + if((rsaCert != 0) && (rsaKey != 0)) { rsa_tmp = rsaCert; } else { - if (rsaCert != 0) + if(rsaCert != 0) { RSA_free(rsaCert); rsaCert = 0; @@ -426,17 +426,17 @@ IceSSL::OpenSSL::PluginI::getRSAKey(int isExport, int keyLength) } // Couldn't load file, last ditch effort - generate a key on the fly. - if (rsa_tmp == 0) + if(rsa_tmp == 0) { rsa_tmp = RSA_generate_key(keyLength, RSA_F4, 0, 0); } // Save in our temporary key cache. - if (rsa_tmp != 0) + if(rsa_tmp != 0) { _tempRSAKeys[keyLength] = new RSAPrivateKey(rsa_tmp); } - else if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + else if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { ostringstream errorMsg; @@ -460,7 +460,7 @@ IceSSL::OpenSSL::PluginI::getDHParams(int isExport, int keyLength) const DHMap::iterator& retVal = _tempDHKeys.find(keyLength); // Does the key already exist? - if (retVal != _tempDHKeys.end()) + if(retVal != _tempDHKeys.end()) { // Yes! Use it. dh_tmp = (*retVal).second->get(); @@ -470,7 +470,7 @@ IceSSL::OpenSSL::PluginI::getDHParams(int isExport, int keyLength) const DHParamsMap::iterator& it = _tempDHParamsFileMap.find(keyLength); // First we try to load params from specified files - if (it != _tempDHParamsFileMap.end()) + if(it != _tempDHParamsFileMap.end()) { DiffieHellmanParamsFile& dhParamsFile = (*it).second; @@ -480,9 +480,9 @@ IceSSL::OpenSSL::PluginI::getDHParams(int isExport, int keyLength) } // If that doesn't work, use a compiled-in group. - if (dh_tmp == 0) + if(dh_tmp == 0) { - switch (keyLength) + switch(keyLength) { case 512 : { @@ -510,13 +510,13 @@ IceSSL::OpenSSL::PluginI::getDHParams(int isExport, int keyLength) } } - if (dh_tmp != 0) + if(dh_tmp != 0) { // Cache the dh params for quick lookup - no // extra processing required then. _tempDHKeys[keyLength] = new DHParams(dh_tmp); } - else if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + else if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { ostringstream errorMsg; @@ -539,18 +539,18 @@ IceSSL::OpenSSL::PluginI::setCertificateVerifier(ContextType contextType, IceSSL::OpenSSL::CertificateVerifierPtr castVerifier; castVerifier = IceSSL::OpenSSL::CertificateVerifierPtr::dynamicCast(verifier); - if (!castVerifier.get()) + if(!castVerifier.get()) { IceSSL::CertificateVerifierTypeException cvtEx(__FILE__, __LINE__); throw cvtEx; } - if (contextType == Client || contextType == ClientServer) + if(contextType == Client || contextType == ClientServer) { _clientContext.setCertificateVerifier(castVerifier); } - if (contextType == Server || contextType == ClientServer) + if(contextType == Server || contextType == ClientServer) { _serverContext.setCertificateVerifier(castVerifier); } @@ -561,12 +561,12 @@ IceSSL::OpenSSL::PluginI::addTrustedCertificateBase64(ContextType contextType, c { IceUtil::RecMutex::Lock sync(_configMutex); - if (contextType == Client || contextType == ClientServer) + if(contextType == Client || contextType == ClientServer) { _clientContext.addTrustedCertificateBase64(certString); } - if (contextType == Server || contextType == ClientServer) + if(contextType == Server || contextType == ClientServer) { _serverContext.addTrustedCertificateBase64(certString); } @@ -577,12 +577,12 @@ IceSSL::OpenSSL::PluginI::addTrustedCertificate(ContextType contextType, const I { IceUtil::RecMutex::Lock sync(_configMutex); - if (contextType == Client || contextType == ClientServer) + if(contextType == Client || contextType == ClientServer) { _clientContext.addTrustedCertificate(certSeq); } - if (contextType == Server || contextType == ClientServer) + if(contextType == Server || contextType == ClientServer) { _serverContext.addTrustedCertificate(certSeq); } @@ -595,12 +595,12 @@ IceSSL::OpenSSL::PluginI::setRSAKeysBase64(ContextType contextType, { IceUtil::RecMutex::Lock sync(_configMutex); - if (contextType == Client || contextType == ClientServer) + if(contextType == Client || contextType == ClientServer) { _clientContext.setRSAKeysBase64(privateKey, publicKey); } - if (contextType == Server || contextType == ClientServer) + if(contextType == Server || contextType == ClientServer) { _serverContext.setRSAKeysBase64(privateKey, publicKey); } @@ -613,12 +613,12 @@ IceSSL::OpenSSL::PluginI::setRSAKeys(ContextType contextType, { IceUtil::RecMutex::Lock sync(_configMutex); - if (contextType == Client || contextType == ClientServer) + if(contextType == Client || contextType == ClientServer) { _clientContext.setRSAKeys(privateKey, publicKey); } - if (contextType == Server || contextType == ClientServer) + if(contextType == Server || contextType == ClientServer) { _serverContext.setRSAKeys(privateKey, publicKey); } @@ -675,7 +675,7 @@ IceSSL::OpenSSL::PluginI::seedRand() char buffer[1024]; const char* file = RAND_file_name(buffer, sizeof(buffer)); - if (file == 0) + if(file == 0) { return 0; } @@ -686,7 +686,7 @@ IceSSL::OpenSSL::PluginI::seedRand() long IceSSL::OpenSSL::PluginI::loadRandFiles(const string& names) { - if (!names.empty()) + if(!names.empty()) { return 0; } @@ -706,11 +706,11 @@ IceSSL::OpenSSL::PluginI::loadRandFiles(const string& names) char* token = strtok(namesString, seps); - while (token != 0) + while(token != 0) { egd = RAND_egd(token); - if (egd > 0) + if(egd > 0) { tot += egd; } @@ -722,7 +722,7 @@ IceSSL::OpenSSL::PluginI::loadRandFiles(const string& names) token = strtok(0, seps); } - if (tot > 512) + if(tot > 512) { _randSeeded = 1; } @@ -735,19 +735,19 @@ IceSSL::OpenSSL::PluginI::loadRandFiles(const string& names) void IceSSL::OpenSSL::PluginI::initRandSystem(const string& randBytesFiles) { - if (_randSeeded) + if(_randSeeded) { return; } long randBytesLoaded = seedRand(); - if (!randBytesFiles.empty()) + if(!randBytesFiles.empty()) { randBytesLoaded += loadRandFiles(randBytesFiles); } - if (!randBytesLoaded && !RAND_status() && (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)) + if(!randBytesLoaded && !RAND_status() && (_traceLevels->security >= IceSSL::SECURITY_WARNINGS)) { // In this case, there are two options open to us - specify a random data file using the // RANDFILE environment variable, or specify additional random data files in the @@ -765,7 +765,7 @@ IceSSL::OpenSSL::PluginI::loadTempCerts(TempCertificates& tempCerts) RSAVector::iterator iRSA = tempCerts.getRSACerts().begin(); RSAVector::iterator eRSA = tempCerts.getRSACerts().end(); - while (iRSA != eRSA) + while(iRSA != eRSA) { _tempRSAFileMap[(*iRSA).getKeySize()] = *iRSA; iRSA++; @@ -774,7 +774,7 @@ IceSSL::OpenSSL::PluginI::loadTempCerts(TempCertificates& tempCerts) DHVector::iterator iDHP = tempCerts.getDHParams().begin(); DHVector::iterator eDHP = tempCerts.getDHParams().end(); - while (iDHP != eDHP) + while(iDHP != eDHP) { _tempDHParamsFileMap[(*iDHP).getKeySize()] = *iDHP; iDHP++; diff --git a/cpp/src/IceSSL/OpenSSLPluginI.h b/cpp/src/IceSSL/OpenSSLPluginI.h index 2aac3e8c179..d18dfbe3e83 100644 --- a/cpp/src/IceSSL/OpenSSLPluginI.h +++ b/cpp/src/IceSSL/OpenSSLPluginI.h @@ -1,118 +1,118 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_OPENSSL_PLUGIN_I_H -#define ICE_SSL_OPENSSL_PLUGIN_I_H - -#include <IceUtil/RecMutex.h> -#include <IceSSL/PluginBaseI.h> -#include <IceSSL/CertificateDesc.h> -#include <IceSSL/CertificateAuthority.h> -#include <IceSSL/BaseCerts.h> -#include <IceSSL/TempCerts.h> -#include <IceSSL/ContextOpenSSLServer.h> -#include <IceSSL/ContextOpenSSLClient.h> -#include <IceSSL/RSAPrivateKeyF.h> -#include <IceSSL/DHParamsF.h> -#include <openssl/ssl.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -typedef std::map<int,RSAPrivateKeyPtr> RSAMap; -typedef std::map<int,DHParamsPtr> DHMap; - -typedef std::map<int,CertificateDesc> RSACertMap; -typedef std::map<int,DiffieHellmanParamsFile> DHParamsMap; - -class PluginI : public PluginBaseI -{ -public: - - PluginI(const IceInternal::ProtocolPluginFacadePtr&); - ~PluginI(); - - virtual IceSSL::ConnectionPtr createConnection(ContextType, int); - - virtual bool isConfigured(ContextType); - virtual void configure(); - virtual void configure(ContextType); - virtual void loadConfig(ContextType, const std::string&, const std::string&); - - // Returns the desired RSA Key, or creates it if not already created. - // This is public because the tmpRSACallback must be able to access it. - RSA* getRSAKey(int, int); - - // Returns the desired DH Params. If the Params do not already exist, and the key - // requested is a 512bit or 1024bit key, we use the compiled-in temporary params. - // If the key is some other length, we read the desired key, based on length, - // from a DH Param file. - // This is public because the tmpDHCallback must be able to access it. - DH* getDHParams(int, int); - - virtual void setCertificateVerifier(ContextType, const IceSSL::CertificateVerifierPtr&); - - virtual void addTrustedCertificateBase64(ContextType, const std::string&); - - virtual void addTrustedCertificate(ContextType, const Ice::ByteSeq&); - - virtual void setRSAKeysBase64(ContextType, const std::string&, const std::string&); - - virtual void setRSAKeys(ContextType, const Ice::ByteSeq&, const Ice::ByteSeq&); - - virtual IceSSL::CertificateVerifierPtr getDefaultCertVerifier(); - - virtual IceSSL::CertificateVerifierPtr getSingleCertVerifier(const Ice::ByteSeq&); - - virtual void destroy(); - -private: - - ServerContext _serverContext; - ClientContext _clientContext; - - // Mutex to ensure synchronization of calls to configure - // the contexts and calls to create connections. - IceUtil::RecMutex _configMutex; - - // Keep a cache of all temporary RSA keys. - RSAMap _tempRSAKeys; - IceUtil::Mutex _tempRSAKeysMutex; - - // Keep a cache of all temporary Diffie-Hellman keys. - DHMap _tempDHKeys; - IceUtil::Mutex _tempDHKeysMutex; - - // Maps of all temporary keying information. - // The files themselves will not be loaded until - // needed. - RSACertMap _tempRSAFileMap; - DHParamsMap _tempDHParamsFileMap; - - // Flag as to whether the Random Number system has been seeded. - int _randSeeded; - - // Cryptographic Random Number System related routines. - int seedRand(); - long loadRandFiles(const std::string&); - void initRandSystem(const std::string&); - - // Load the temporary (ephemeral) certificates for Server operations. - void loadTempCerts(TempCertificates&); -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_OPENSSL_PLUGIN_I_H
+#define ICE_SSL_OPENSSL_PLUGIN_I_H
+
+#include <IceUtil/RecMutex.h>
+#include <IceSSL/PluginBaseI.h>
+#include <IceSSL/CertificateDesc.h>
+#include <IceSSL/CertificateAuthority.h>
+#include <IceSSL/BaseCerts.h>
+#include <IceSSL/TempCerts.h>
+#include <IceSSL/ContextOpenSSLServer.h>
+#include <IceSSL/ContextOpenSSLClient.h>
+#include <IceSSL/RSAPrivateKeyF.h>
+#include <IceSSL/DHParamsF.h>
+#include <openssl/ssl.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+typedef std::map<int,RSAPrivateKeyPtr> RSAMap;
+typedef std::map<int,DHParamsPtr> DHMap;
+
+typedef std::map<int,CertificateDesc> RSACertMap;
+typedef std::map<int,DiffieHellmanParamsFile> DHParamsMap;
+
+class PluginI : public PluginBaseI
+{
+public:
+
+ PluginI(const IceInternal::ProtocolPluginFacadePtr&);
+ ~PluginI();
+
+ virtual IceSSL::ConnectionPtr createConnection(ContextType, int);
+
+ virtual bool isConfigured(ContextType);
+ virtual void configure();
+ virtual void configure(ContextType);
+ virtual void loadConfig(ContextType, const std::string&, const std::string&);
+
+ // Returns the desired RSA Key, or creates it if not already created.
+ // This is public because the tmpRSACallback must be able to access it.
+ RSA* getRSAKey(int, int);
+
+ // Returns the desired DH Params. If the Params do not already exist, and the key
+ // requested is a 512bit or 1024bit key, we use the compiled-in temporary params.
+ // If the key is some other length, we read the desired key, based on length,
+ // from a DH Param file.
+ // This is public because the tmpDHCallback must be able to access it.
+ DH* getDHParams(int, int);
+
+ virtual void setCertificateVerifier(ContextType, const IceSSL::CertificateVerifierPtr&);
+
+ virtual void addTrustedCertificateBase64(ContextType, const std::string&);
+
+ virtual void addTrustedCertificate(ContextType, const Ice::ByteSeq&);
+
+ virtual void setRSAKeysBase64(ContextType, const std::string&, const std::string&);
+
+ virtual void setRSAKeys(ContextType, const Ice::ByteSeq&, const Ice::ByteSeq&);
+
+ virtual IceSSL::CertificateVerifierPtr getDefaultCertVerifier();
+
+ virtual IceSSL::CertificateVerifierPtr getSingleCertVerifier(const Ice::ByteSeq&);
+
+ virtual void destroy();
+
+private:
+
+ ServerContext _serverContext;
+ ClientContext _clientContext;
+
+ // Mutex to ensure synchronization of calls to configure
+ // the contexts and calls to create connections.
+ IceUtil::RecMutex _configMutex;
+
+ // Keep a cache of all temporary RSA keys.
+ RSAMap _tempRSAKeys;
+ IceUtil::Mutex _tempRSAKeysMutex;
+
+ // Keep a cache of all temporary Diffie-Hellman keys.
+ DHMap _tempDHKeys;
+ IceUtil::Mutex _tempDHKeysMutex;
+
+ // Maps of all temporary keying information.
+ // The files themselves will not be loaded until
+ // needed.
+ RSACertMap _tempRSAFileMap;
+ DHParamsMap _tempDHParamsFileMap;
+
+ // Flag as to whether the Random Number system has been seeded.
+ int _randSeeded;
+
+ // Cryptographic Random Number System related routines.
+ int seedRand();
+ long loadRandFiles(const std::string&);
+ void initRandSystem(const std::string&);
+
+ // Load the temporary (ephemeral) certificates for Server operations.
+ void loadTempCerts(TempCertificates&);
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/OpenSSLUtils.cpp b/cpp/src/IceSSL/OpenSSLUtils.cpp index 2767ce97aba..682a632ad52 100644 --- a/cpp/src/IceSSL/OpenSSLUtils.cpp +++ b/cpp/src/IceSSL/OpenSSLUtils.cpp @@ -156,19 +156,19 @@ IceSSL::OpenSSL::getGeneralizedTime(ASN1_GENERALIZEDTIME *tm) char* v = (char *) tm->data; - if (i < 12) + if(i < 12) { goto err; } - if (v[i-1] == 'Z') + if(v[i-1] == 'Z') { gmt=1; } - for (i=0; i<12; i++) + for(i=0; i<12; i++) { - if ((v[i] > '9') || (v[i] < '0')) + if((v[i] > '9') || (v[i] < '0')) { goto err; } @@ -177,7 +177,7 @@ IceSSL::OpenSSL::getGeneralizedTime(ASN1_GENERALIZEDTIME *tm) y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + (v[2] - '0') * 10 + (v[3] - '0'); M = (v[4] - '0') * 10 + (v[5] - '0'); - if ((M > 12) || (M < 1)) + if((M > 12) || (M < 1)) { goto err; } @@ -186,7 +186,7 @@ IceSSL::OpenSSL::getGeneralizedTime(ASN1_GENERALIZEDTIME *tm) h = (v[8] - '0') * 10 + (v[9] - '0'); m = (v[10] - '0') * 10 + (v[11] - '0'); - if ((v[12] >= '0') && (v[12] <= '9') && + if((v[12] >= '0') && (v[12] <= '9') && (v[13] >= '0') && (v[13] <= '9')) { s = (v[12] - '0') * 10 + (v[13] - '0'); @@ -210,19 +210,19 @@ IceSSL::OpenSSL::getUTCTime(ASN1_UTCTIME *tm) int i = tm->length; char* v = (char *) tm->data; - if (i < 10) + if(i < 10) { goto err; } - if (v[i-1] == 'Z') + if(v[i-1] == 'Z') { gmt=1; } - for (i = 0; i < 10; i++) + for(i = 0; i < 10; i++) { - if ((v[i] > '9') || (v[i] < '0')) + if((v[i] > '9') || (v[i] < '0')) { goto err; } @@ -230,14 +230,14 @@ IceSSL::OpenSSL::getUTCTime(ASN1_UTCTIME *tm) y = (v[0] - '0') * 10 + (v[1] - '0'); - if (y < 50) + if(y < 50) { y+=100; } M = (v[2] - '0') * 10 + (v[3] - '0'); - if ((M > 12) || (M < 1)) + if((M > 12) || (M < 1)) { goto err; } @@ -246,7 +246,7 @@ IceSSL::OpenSSL::getUTCTime(ASN1_UTCTIME *tm) h = (v[6] - '0') * 10 + (v[7] - '0'); m = (v[8] - '0') * 10 + (v[9] - '0'); - if ((v[10] >= '0') && (v[10] <= '9') && (v[11] >= '0') && (v[11] <= '9')) + if((v[10] >= '0') && (v[10] <= '9') && (v[11] >= '0') && (v[11] <= '9')) { s = (v[10] - '0') * 10 + (v[11] - '0'); } @@ -265,7 +265,7 @@ IceSSL::OpenSSL::getASN1time(ASN1_TIME *tm) string theTime; - switch (tm->type) + switch(tm->type) { case V_ASN1_UTCTIME : { @@ -297,7 +297,7 @@ IceSSL::OpenSSL::loadDHParam(const char* dhfile) DH* ret = 0; BIO* bio = BIO_new_file(dhfile,"r"); - if (bio != 0) + if(bio != 0) { ret = PEM_read_bio_DHparams(bio, 0, 0, 0); BIO_free(bio); @@ -314,13 +314,13 @@ IceSSL::OpenSSL::getTempDH(unsigned char* p, int plen, unsigned char* g, int gle DH* dh = DH_new(); - if (dh != 0) + if(dh != 0) { dh->p = BN_bin2bn(p, plen, 0); dh->g = BN_bin2bn(g, glen, 0); - if ((dh->p == 0) || (dh->g == 0)) + if((dh->p == 0) || (dh->g == 0)) { DH_free(dh); dh = 0; @@ -379,7 +379,7 @@ IceSSL::OpenSSL::sslGetErrors() unsigned long es = CRYPTO_thread_id(); - while ((errorCode = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) + while((errorCode = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) { sprintf(bigBuffer,"%6d - Thread ID: %lu\n", errorNum, es); errorMessage += bigBuffer; @@ -395,7 +395,7 @@ IceSSL::OpenSSL::sslGetErrors() sprintf(bigBuffer,"%6d - Location: %s, %d\n", errorNum, file, line); errorMessage += bigBuffer; - if (flags & ERR_TXT_STRING) + if(flags & ERR_TXT_STRING) { sprintf(bigBuffer,"%6d - Data: %s\n", errorNum, data); errorMessage += bigBuffer; diff --git a/cpp/src/IceSSL/OpenSSLUtils.h b/cpp/src/IceSSL/OpenSSLUtils.h index 9e75f8fac02..7dc57afee56 100644 --- a/cpp/src/IceSSL/OpenSSLUtils.h +++ b/cpp/src/IceSSL/OpenSSLUtils.h @@ -1,52 +1,52 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#include <IceUtil/Config.h> -#include <openssl/ssl.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -std::string getGeneralizedTime(ASN1_GENERALIZEDTIME*); - -std::string getUTCTime(ASN1_UTCTIME*); - -std::string getASN1time(ASN1_TIME*); - -DH* loadDHParam(const char*); - -DH* getTempDH(unsigned char*, int, unsigned char*, int); - -DH* getTempDH512(); -DH* getTempDH1024(); -DH* getTempDH2048(); -DH* getTempDH4096(); - -std::string sslGetErrors(); - -} - -} - -extern "C" -{ - -RSA* tmpRSACallback(SSL*, int, int); - -DH* tmpDHCallback(SSL*, int, int); - -int verifyCallback(int, X509_STORE_CTX*); - -int passwordCallback(char*, int, int, void*); - -} +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <IceUtil/Config.h>
+#include <openssl/ssl.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+std::string getGeneralizedTime(ASN1_GENERALIZEDTIME*);
+
+std::string getUTCTime(ASN1_UTCTIME*);
+
+std::string getASN1time(ASN1_TIME*);
+
+DH* loadDHParam(const char*);
+
+DH* getTempDH(unsigned char*, int, unsigned char*, int);
+
+DH* getTempDH512();
+DH* getTempDH1024();
+DH* getTempDH2048();
+DH* getTempDH4096();
+
+std::string sslGetErrors();
+
+}
+
+}
+
+extern "C"
+{
+
+RSA* tmpRSACallback(SSL*, int, int);
+
+DH* tmpDHCallback(SSL*, int, int);
+
+int verifyCallback(int, X509_STORE_CTX*);
+
+int passwordCallback(char*, int, int, void*);
+
+}
diff --git a/cpp/src/IceSSL/PluginBaseI.h b/cpp/src/IceSSL/PluginBaseI.h index 42b6a6d1aa2..9f9a180003d 100644 --- a/cpp/src/IceSSL/PluginBaseI.h +++ b/cpp/src/IceSSL/PluginBaseI.h @@ -1,71 +1,71 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_PLUGIN_I_H -#define ICE_SSL_PLUGIN_I_H - -#include <Ice/LoggerF.h> -#include <Ice/PropertiesF.h> -#include <Ice/ProtocolPluginFacadeF.h> -#include <IceSSL/Plugin.h> -#include <IceSSL/PluginBaseIF.h> -#include <IceSSL/SslConnectionF.h> -#include <IceSSL/CertificateVerifierF.h> -#include <IceSSL/TraceLevelsF.h> - -namespace IceSSL -{ - -class PluginBaseI : public IceSSL::Plugin -{ -public: - - virtual ConnectionPtr createConnection(ContextType, int) = 0; - - virtual bool isConfigured(ContextType) = 0; - - virtual void configure() = 0; - - virtual void configure(ContextType) = 0; - - virtual void loadConfig(ContextType, const ::std::string&, const ::std::string&) = 0; - - virtual void setCertificateVerifier(ContextType, const CertificateVerifierPtr&) = 0; - - virtual void addTrustedCertificateBase64(ContextType, const std::string&) = 0; - - virtual void addTrustedCertificate(ContextType, const Ice::ByteSeq&) = 0; - - virtual void setRSAKeysBase64(ContextType, const std::string&, const std::string&) = 0; - - virtual void setRSAKeys(ContextType, const ::Ice::ByteSeq&, const ::Ice::ByteSeq&) = 0; - - TraceLevelsPtr getTraceLevels() const; - - Ice::LoggerPtr getLogger() const; - - Ice::PropertiesPtr getProperties() const; - - IceInternal::ProtocolPluginFacadePtr getProtocolPluginFacade() const; - -protected: - - PluginBaseI(const IceInternal::ProtocolPluginFacadePtr&); - virtual ~PluginBaseI(); - - IceInternal::ProtocolPluginFacadePtr _protocolPluginFacade; - TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; - Ice::PropertiesPtr _properties; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_PLUGIN_I_H
+#define ICE_SSL_PLUGIN_I_H
+
+#include <Ice/LoggerF.h>
+#include <Ice/PropertiesF.h>
+#include <Ice/ProtocolPluginFacadeF.h>
+#include <IceSSL/Plugin.h>
+#include <IceSSL/PluginBaseIF.h>
+#include <IceSSL/SslConnectionF.h>
+#include <IceSSL/CertificateVerifierF.h>
+#include <IceSSL/TraceLevelsF.h>
+
+namespace IceSSL
+{
+
+class PluginBaseI : public IceSSL::Plugin
+{
+public:
+
+ virtual ConnectionPtr createConnection(ContextType, int) = 0;
+
+ virtual bool isConfigured(ContextType) = 0;
+
+ virtual void configure() = 0;
+
+ virtual void configure(ContextType) = 0;
+
+ virtual void loadConfig(ContextType, const ::std::string&, const ::std::string&) = 0;
+
+ virtual void setCertificateVerifier(ContextType, const CertificateVerifierPtr&) = 0;
+
+ virtual void addTrustedCertificateBase64(ContextType, const std::string&) = 0;
+
+ virtual void addTrustedCertificate(ContextType, const Ice::ByteSeq&) = 0;
+
+ virtual void setRSAKeysBase64(ContextType, const std::string&, const std::string&) = 0;
+
+ virtual void setRSAKeys(ContextType, const ::Ice::ByteSeq&, const ::Ice::ByteSeq&) = 0;
+
+ TraceLevelsPtr getTraceLevels() const;
+
+ Ice::LoggerPtr getLogger() const;
+
+ Ice::PropertiesPtr getProperties() const;
+
+ IceInternal::ProtocolPluginFacadePtr getProtocolPluginFacade() const;
+
+protected:
+
+ PluginBaseI(const IceInternal::ProtocolPluginFacadePtr&);
+ virtual ~PluginBaseI();
+
+ IceInternal::ProtocolPluginFacadePtr _protocolPluginFacade;
+ TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+ Ice::PropertiesPtr _properties;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/PluginBaseIF.h b/cpp/src/IceSSL/PluginBaseIF.h index 1f7cf16bd6e..e145fe32230 100644 --- a/cpp/src/IceSSL/PluginBaseIF.h +++ b/cpp/src/IceSSL/PluginBaseIF.h @@ -1,32 +1,32 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_PLUGIN_BASE_I_F_H -#define ICE_SSL_PLUGIN_BASE_I_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -class PluginBaseI; -typedef IceInternal::Handle<PluginBaseI> PluginBaseIPtr; - -} - -namespace IceInternal -{ - -void incRef(IceSSL::PluginBaseI*); -void decRef(IceSSL::PluginBaseI*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_PLUGIN_BASE_I_F_H
+#define ICE_SSL_PLUGIN_BASE_I_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+class PluginBaseI;
+typedef IceInternal::Handle<PluginBaseI> PluginBaseIPtr;
+
+}
+
+namespace IceInternal
+{
+
+void incRef(IceSSL::PluginBaseI*);
+void decRef(IceSSL::PluginBaseI*);
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/RSACertificateGen.cpp b/cpp/src/IceSSL/RSACertificateGen.cpp index 173e18a1017..8b1ef2b722a 100644 --- a/cpp/src/IceSSL/RSACertificateGen.cpp +++ b/cpp/src/IceSSL/RSACertificateGen.cpp @@ -252,13 +252,13 @@ IceSSL::OpenSSL::RSACertificateGen::generate(const RSACertificateGenContext& con X509_set_pubkey(x509SelfSigned, pkey); // Sign the public key using an MD5 digest. - if (!X509_sign(x509SelfSigned, pkey, EVP_md5())) + if(!X509_sign(x509SelfSigned, pkey, EVP_md5())) { throw IceSSL::CertificateSigningException(__FILE__, __LINE__); } // Verify the Signature (paranoia). - if (!X509_REQ_verify(signingRequest, pkey)) + if(!X509_REQ_verify(signingRequest, pkey)) { throw IceSSL::CertificateSignatureException(__FILE__, __LINE__); } @@ -284,7 +284,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons // Read in the X509 Certificate Structure // BIOJanitor certBIO(BIO_new_file(certFile.c_str(), "r")); - if (certBIO.get() == 0) + if(certBIO.get() == 0) { IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__); @@ -298,7 +298,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons X509Janitor x509Janitor(PEM_read_bio_X509(certBIO.get(), 0, 0, 0)); - if (x509Janitor.get() == 0) + if(x509Janitor.get() == 0) { IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__); @@ -314,7 +314,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons // Read in the RSA Private Key Structure // BIOJanitor keyBIO(BIO_new_file(keyFile.c_str(), "r")); - if (keyBIO.get() == 0) + if(keyBIO.get() == 0) { IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__); @@ -328,7 +328,7 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons RSAJanitor rsaJanitor(PEM_read_bio_RSAPrivateKey(keyBIO.get(), 0, 0, 0)); - if (rsaJanitor.get() == 0) + if(rsaJanitor.get() == 0) { IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__); diff --git a/cpp/src/IceSSL/RSAPrivateKey.cpp b/cpp/src/IceSSL/RSAPrivateKey.cpp index 7499c69ecdc..90e07cc87b4 100644 --- a/cpp/src/IceSSL/RSAPrivateKey.cpp +++ b/cpp/src/IceSSL/RSAPrivateKey.cpp @@ -52,7 +52,7 @@ IceSSL::OpenSSL::RSAPrivateKey::RSAPrivateKey(RSA* rsa) : IceSSL::OpenSSL::RSAPrivateKey::~RSAPrivateKey() { - if (_privateKey != 0) + if(_privateKey != 0) { RSA_free(_privateKey); } @@ -106,9 +106,9 @@ IceSSL::OpenSSL::RSAPrivateKey::byteSeqToKey(const ByteSeq& keySeq) _privateKey = d2i_RSAPrivateKey(rsapp, privKeyBuffpp, (long)keySeq.size()); - delete [] privateKeyBuffer;
-
- if (_privateKey == 0) + delete [] privateKeyBuffer; + + if(_privateKey == 0) { IceSSL::PrivateKeyParseException pkParseException(__FILE__, __LINE__); diff --git a/cpp/src/IceSSL/RSAPublicKey.cpp b/cpp/src/IceSSL/RSAPublicKey.cpp index 70ddadeb1bd..1e3ead9ef64 100644 --- a/cpp/src/IceSSL/RSAPublicKey.cpp +++ b/cpp/src/IceSSL/RSAPublicKey.cpp @@ -46,7 +46,7 @@ IceSSL::OpenSSL::RSAPublicKey::RSAPublicKey(const ByteSeq& certSeq) IceSSL::OpenSSL::RSAPublicKey::~RSAPublicKey() { - if (_publicKey != 0) + if(_publicKey != 0) { X509_free(_publicKey); } @@ -107,7 +107,7 @@ IceSSL::OpenSSL::RSAPublicKey::byteSeqToCert(const ByteSeq& certSeq) _publicKey = d2i_X509(x509pp, pubKeyBuffpp, (long)certSeq.size()); - if (_publicKey == 0) + if(_publicKey == 0) { IceSSL::CertificateParseException certParseException(__FILE__, __LINE__); diff --git a/cpp/src/IceSSL/SingleCertificateVerifier.cpp b/cpp/src/IceSSL/SingleCertificateVerifier.cpp index 80198f5341f..9ef833690f3 100644 --- a/cpp/src/IceSSL/SingleCertificateVerifier.cpp +++ b/cpp/src/IceSSL/SingleCertificateVerifier.cpp @@ -35,7 +35,7 @@ IceSSL::OpenSSL::SingleCertificateVerifier::verify(int preVerifyOkay, X509* peerCertificate = x509StoreContext->cert; // We only bother to do the rest of this if we have something to verify. - if (peerCertificate) + if(peerCertificate) { // Get the subject name (Not a memory leak, this is how this is used). X509_NAME* peerCertName = X509_get_subject_name(peerCertificate); @@ -46,7 +46,7 @@ IceSSL::OpenSSL::SingleCertificateVerifier::verify(int preVerifyOkay, peerCertName, &trustedObject); - switch (retCode) + switch(retCode) { case X509_LU_X509: { @@ -74,7 +74,7 @@ IceSSL::OpenSSL::SingleCertificateVerifier::verify(int preVerifyOkay, } // Compare, only if we have both. - if (trustedCert) + if(trustedCert) { ByteSeq peerByteSeq = toByteSeq(peerCertificate); ByteSeq trustedByteSeq = toByteSeq(trustedCert); diff --git a/cpp/src/IceSSL/SingleCertificateVerifier.h b/cpp/src/IceSSL/SingleCertificateVerifier.h index 89753b620e9..c524311c119 100644 --- a/cpp/src/IceSSL/SingleCertificateVerifier.h +++ b/cpp/src/IceSSL/SingleCertificateVerifier.h @@ -1,43 +1,43 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_SINGLE_CERTIFICATE_VERIFIER_H -#define ICE_SSL_SINGLE_CERTIFICATE_VERIFIER_H - -#include <Ice/BuiltinSequences.h> -#include <IceSSL/CertificateVerifierOpenSSL.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class SingleCertificateVerifier : public IceSSL::OpenSSL::CertificateVerifier -{ -public: - - SingleCertificateVerifier(const Ice::ByteSeq&); - - virtual int verify(int, X509_STORE_CTX*, SSL*); - - Ice::ByteSeq toByteSeq(X509*); - -protected: - - Ice::ByteSeq _publicKey; -}; - -} - -} - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_SINGLE_CERTIFICATE_VERIFIER_H
+#define ICE_SSL_SINGLE_CERTIFICATE_VERIFIER_H
+
+#include <Ice/BuiltinSequences.h>
+#include <IceSSL/CertificateVerifierOpenSSL.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class SingleCertificateVerifier : public IceSSL::OpenSSL::CertificateVerifier
+{
+public:
+
+ SingleCertificateVerifier(const Ice::ByteSeq&);
+
+ virtual int verify(int, X509_STORE_CTX*, SSL*);
+
+ Ice::ByteSeq toByteSeq(X509*);
+
+protected:
+
+ Ice::ByteSeq _publicKey;
+};
+
+}
+
+}
+
+#endif
+
diff --git a/cpp/src/IceSSL/SslAcceptor.cpp b/cpp/src/IceSSL/SslAcceptor.cpp index 8218a47ccb0..f1fbbadc967 100644 --- a/cpp/src/IceSSL/SslAcceptor.cpp +++ b/cpp/src/IceSSL/SslAcceptor.cpp @@ -29,7 +29,7 @@ IceSSL::SslAcceptor::fd() void IceSSL::SslAcceptor::close() { - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { ostringstream s; s << "stopping to accept ssl connections at " << toString(); @@ -54,7 +54,7 @@ IceSSL::SslAcceptor::listen() throw; } - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { ostringstream s; s << "accepting ssl connections at " << toString(); @@ -68,7 +68,7 @@ IceSSL::SslAcceptor::accept(int timeout) SOCKET fd = doAccept(_fd, timeout); setBlock(fd, false); - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { ostringstream s; s << "accepted ssl connection\n" << fdToString(fd); @@ -107,7 +107,7 @@ IceSSL::SslAcceptor::SslAcceptor(const PluginBaseIPtr& plugin, const string& hos _logger(plugin->getLogger()), _backlog(0) { - if (_backlog <= 0) + if(_backlog <= 0) { _backlog = 5; } diff --git a/cpp/src/IceSSL/SslAcceptor.h b/cpp/src/IceSSL/SslAcceptor.h index 5718d5ab3c9..dbe7656e840 100644 --- a/cpp/src/IceSSL/SslAcceptor.h +++ b/cpp/src/IceSSL/SslAcceptor.h @@ -1,58 +1,58 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_ACCEPTOR_H -#define ICE_SSL_ACCEPTOR_H - -#include <Ice/TransceiverF.h> -#include <Ice/LoggerF.h> -#include <Ice/Acceptor.h> -#include <IceSSL/PluginBaseIF.h> -#include <IceSSL/TraceLevelsF.h> - -#ifndef _WIN32 -# include <netinet/in.h> // For struct sockaddr_in -#endif - -namespace IceSSL -{ - -class SslEndpoint; - -class SslAcceptor : public IceInternal::Acceptor -{ -public: - - virtual SOCKET fd(); - virtual void close(); - virtual void listen(); - virtual IceInternal::TransceiverPtr accept(int); - virtual std::string toString() const; - - bool equivalent(const std::string&, int) const; - int effectivePort(); - -private: - - SslAcceptor(const PluginBaseIPtr&, const std::string&, int); - virtual ~SslAcceptor(); - friend class SslEndpoint; - - PluginBaseIPtr _plugin; - TraceLevelsPtr _traceLevels; - ::Ice::LoggerPtr _logger; - SOCKET _fd; - int _backlog; - struct sockaddr_in _addr; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_ACCEPTOR_H
+#define ICE_SSL_ACCEPTOR_H
+
+#include <Ice/TransceiverF.h>
+#include <Ice/LoggerF.h>
+#include <Ice/Acceptor.h>
+#include <IceSSL/PluginBaseIF.h>
+#include <IceSSL/TraceLevelsF.h>
+
+#ifndef _WIN32
+# include <netinet/in.h> // For struct sockaddr_in
+#endif
+
+namespace IceSSL
+{
+
+class SslEndpoint;
+
+class SslAcceptor : public IceInternal::Acceptor
+{
+public:
+
+ virtual SOCKET fd();
+ virtual void close();
+ virtual void listen();
+ virtual IceInternal::TransceiverPtr accept(int);
+ virtual std::string toString() const;
+
+ bool equivalent(const std::string&, int) const;
+ int effectivePort();
+
+private:
+
+ SslAcceptor(const PluginBaseIPtr&, const std::string&, int);
+ virtual ~SslAcceptor();
+ friend class SslEndpoint;
+
+ PluginBaseIPtr _plugin;
+ TraceLevelsPtr _traceLevels;
+ ::Ice::LoggerPtr _logger;
+ SOCKET _fd;
+ int _backlog;
+ struct sockaddr_in _addr;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnection.h b/cpp/src/IceSSL/SslConnection.h index eb7aedb9e7f..8347f7893bf 100644 --- a/cpp/src/IceSSL/SslConnection.h +++ b/cpp/src/IceSSL/SslConnection.h @@ -1,46 +1,46 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTION_H -#define ICE_SSL_CONNECTION_H - -#include <Ice/Buffer.h> -#include <Ice/LoggerF.h> -#include <IceSSL/SslConnectionF.h> -#include <IceSSL/TraceLevelsF.h> -#include <IceSSL/CertificateVerifierF.h> - -namespace IceSSL -{ - -class Connection : public IceUtil::Shared -{ -public: - - Connection(const TraceLevelsPtr&, - const Ice::LoggerPtr&, - const CertificateVerifierPtr&); - virtual ~Connection(); - - virtual int shutdown(int timeout = 0) = 0; - - virtual int read(IceInternal::Buffer&, int) = 0; - virtual int write(IceInternal::Buffer&, int) = 0; - -protected: - - TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; - CertificateVerifierPtr _certificateVerifier; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTION_H
+#define ICE_SSL_CONNECTION_H
+
+#include <Ice/Buffer.h>
+#include <Ice/LoggerF.h>
+#include <IceSSL/SslConnectionF.h>
+#include <IceSSL/TraceLevelsF.h>
+#include <IceSSL/CertificateVerifierF.h>
+
+namespace IceSSL
+{
+
+class Connection : public IceUtil::Shared
+{
+public:
+
+ Connection(const TraceLevelsPtr&,
+ const Ice::LoggerPtr&,
+ const CertificateVerifierPtr&);
+ virtual ~Connection();
+
+ virtual int shutdown(int timeout = 0) = 0;
+
+ virtual int read(IceInternal::Buffer&, int) = 0;
+ virtual int write(IceInternal::Buffer&, int) = 0;
+
+protected:
+
+ TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+ CertificateVerifierPtr _certificateVerifier;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnectionF.h b/cpp/src/IceSSL/SslConnectionF.h index 5d394788405..48c4383448f 100644 --- a/cpp/src/IceSSL/SslConnectionF.h +++ b/cpp/src/IceSSL/SslConnectionF.h @@ -1,32 +1,32 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTION_F_H -#define ICE_SSL_CONNECTION_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -class Connection; -typedef IceInternal::Handle<Connection> ConnectionPtr; - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::Connection*); -void decRef(::IceSSL::Connection*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTION_F_H
+#define ICE_SSL_CONNECTION_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+class Connection;
+typedef IceInternal::Handle<Connection> ConnectionPtr;
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::Connection*);
+void decRef(::IceSSL::Connection*);
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnectionOpenSSL.cpp b/cpp/src/IceSSL/SslConnectionOpenSSL.cpp index dba97fde2d2..844568e4adb 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSL.cpp +++ b/cpp/src/IceSSL/SslConnectionOpenSSL.cpp @@ -79,7 +79,7 @@ IceSSL::OpenSSL::Connection::Connection(const IceSSL::CertificateVerifierPtr& ce IceSSL::OpenSSL::Connection::~Connection() { - if (_sslConnection != 0) + if(_sslConnection != 0) { removeConnection(_sslConnection); SSL_set_ex_data(_sslConnection, 0, 0); @@ -91,29 +91,29 @@ IceSSL::OpenSSL::Connection::~Connection() int IceSSL::OpenSSL::Connection::shutdown(int timeout) { - if (_sslConnection == 0) + if(_sslConnection == 0) { return 1; } int retCode = 0; - if (_initWantWrite) + if(_initWantWrite) { int i = writeSelect(timeout); - if (i == 0) + if(i == 0) { return 0; } _initWantWrite = 0; } - else if (_initWantRead) + else if(_initWantRead) { int i = readSelect(timeout); - if (i == 0) + if(i == 0) { return 0; } @@ -125,18 +125,18 @@ IceSSL::OpenSSL::Connection::shutdown(int timeout) retCode = SSL_shutdown(_sslConnection); - if (retCode == 1) + if(retCode == 1) { // Shutdown successful - shut down the socket for writing. ::shutdown(SSL_get_fd(_sslConnection), SHUT_WR); } - else if (retCode == -1) + else if(retCode == -1) { setLastError(retCode); // Shutdown failed due to an error. - switch (getLastError()) + switch(getLastError()) { case SSL_ERROR_WANT_WRITE: { @@ -166,20 +166,20 @@ IceSSL::OpenSSL::Connection::shutdown(int timeout) // Some error with the underlying transport. // - if (interrupted()) + if(interrupted()) { retCode = 0; break; } - if (wouldBlock()) + if(wouldBlock()) { readSelect(timeout); retCode = 0; break; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -262,7 +262,7 @@ IceSSL::OpenSSL::Connection::verifyCertificate(int preVerifyOkay, X509_STORE_CTX verifier = dynamic_cast<IceSSL::OpenSSL::CertificateVerifier*>(_certificateVerifier.get()); // Check to make sure we have a proper verifier for the operation. - if (verifier) + if(verifier) { // Use the verifier to verify the certificate try @@ -271,7 +271,7 @@ IceSSL::OpenSSL::Connection::verifyCertificate(int preVerifyOkay, X509_STORE_CTX } catch (const Ice::LocalException& localEx) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { ostringstream s; @@ -289,11 +289,11 @@ IceSSL::OpenSSL::Connection::verifyCertificate(int preVerifyOkay, X509_STORE_CTX // Note: This code should NEVER be able to be reached, as we check each // CertificateVerifier as it is added to the System. - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { string errorString; - if (_certificateVerifier.get()) + if(_certificateVerifier.get()) { errorString = "WRN improper CertificateVerifier type"; } @@ -353,7 +353,7 @@ IceSSL::OpenSSL::Connection::initialize(int timeout) { int retCode = 0; - while (true) + while(true) { // One lucky thread will get the honor of carrying out the hanshake, // if there is one to perform. The HandshakeSentinel effectively @@ -365,9 +365,9 @@ IceSSL::OpenSSL::Connection::initialize(int timeout) HandshakeSentinel handshakeSentinel(_handshakeFlag); - if (!handshakeSentinel.ownHandshake()) + if(!handshakeSentinel.ownHandshake()) { - if (timeout >= 0) + if(timeout >= 0) { // We should return immediately here - do not block, // leave it to the caller to figure this out. @@ -389,9 +389,9 @@ IceSSL::OpenSSL::Connection::initialize(int timeout) // get away with it. As long as we don't encounter some error // status (or completion), this thread continues to service the // initialize() call. - while (retCode == 0) + while(retCode == 0) { - switch (_phase) + switch(_phase) { case Handshake : { @@ -409,7 +409,7 @@ IceSSL::OpenSSL::Connection::initialize(int timeout) { retCode = SSL_is_init_finished(_sslConnection); - if (!retCode) + if(!retCode) { // In this case, we are essentially renegotiating // the connection at the behest of the peer. @@ -481,7 +481,7 @@ IceSSL::OpenSSL::Connection::select(int timeout, bool write) fd_set rwFdSet; struct timeval tv; - if (timeout >= 0) + if(timeout >= 0) { tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000; @@ -492,9 +492,9 @@ IceSSL::OpenSSL::Connection::select(int timeout, bool write) FD_ZERO(&rwFdSet); FD_SET(fd, &rwFdSet); - if (timeout >= 0) + if(timeout >= 0) { - if (write) + if(write) { ret = ::select(fd + 1, 0, &rwFdSet, 0, &tv); } @@ -505,7 +505,7 @@ IceSSL::OpenSSL::Connection::select(int timeout, bool write) } else { - if (write) + if(write) { ret = ::select(fd + 1, 0, &rwFdSet, 0, 0); } @@ -515,16 +515,16 @@ IceSSL::OpenSSL::Connection::select(int timeout, bool write) } } } - while (ret == SOCKET_ERROR && interrupted()); + while(ret == SOCKET_ERROR && interrupted()); - if (ret == SOCKET_ERROR) + if(ret == SOCKET_ERROR) { SocketException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); throw ex; } - if (ret == 0) + if(ret == 0) { throw TimeoutException(__FILE__, __LINE__); } @@ -554,18 +554,18 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) int initReturn = 0; // We keep reading until we're done. - while (buf.i != buf.b.end()) + while(buf.i != buf.b.end()) { // Ensure we're initialized. initReturn = initialize(timeout); - if (initReturn == -1) + if(initReturn == -1) { // Handshake underway, timeout immediately, easy way to deal with this. throw TimeoutException(__FILE__, __LINE__); } - if (initReturn == 0) + if(initReturn == 0) { // Retry the initialize call continue; @@ -573,10 +573,10 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) // initReturn must be > 0, so we're okay to try a read - if (!pending() && !readSelect(_readTimeout)) + if(!pending() && !readSelect(_readTimeout)) { // Nothing is left to read (according to SSL). - if (_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) + if(_traceLevels->security >= IceSSL::SECURITY_PROTOCOL) { _logger->trace(_traceLevels->securityCat, "no pending application-level bytes"); } @@ -589,13 +589,13 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) bytesRead = sslRead(static_cast<char*>(&*buf.i), packetSize); - switch (getLastError()) + switch(getLastError()) { case SSL_ERROR_NONE: { - if (bytesRead > 0) + if(bytesRead > 0) { - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { ostringstream s; s << "received " << bytesRead << " of " << packetSize; @@ -607,7 +607,7 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) buf.i += bytesRead; - if (packetSize > buf.b.end() - buf.i) + if(packetSize > buf.b.end() - buf.i) { packetSize = buf.b.end() - buf.i; } @@ -617,7 +617,7 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) case SSL_ERROR_WANT_READ: { - if (!readSelect(timeout)) + if(!readSelect(timeout)) { // Timeout and wait for them to arrive. throw TimeoutException(__FILE__, __LINE__); @@ -638,17 +638,17 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) { // IO Error in underlying BIO - if (interrupted()) + if(interrupted()) { break; } - if (wouldBlock()) + if(wouldBlock()) { break; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -721,11 +721,11 @@ IceSSL::OpenSSL::Connection::showCertificateChain(BIO* bio) // Big nasty buffer char buffer[4096]; - if ((sk = SSL_get_peer_cert_chain(_sslConnection)) != 0) + if((sk = SSL_get_peer_cert_chain(_sslConnection)) != 0) { BIO_printf(bio,"---\nCertificate chain\n"); - for (int i = 0; i < sk_X509_num(sk); i++) + for(int i = 0; i < sk_X509_num(sk); i++) { X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk,i)), buffer, sizeof(buffer)); BIO_printf(bio, "%2d s:%s\n", i, buffer); @@ -751,7 +751,7 @@ IceSSL::OpenSSL::Connection::showPeerCertificate(BIO* bio, const char* connType) X509* peerCert = 0; char buffer[4096]; - if ((peerCert = SSL_get_peer_certificate(_sslConnection)) != 0) + if((peerCert = SSL_get_peer_certificate(_sslConnection)) != 0) { BIO_printf(bio, "%s Certificate\n", connType); PEM_write_bio_X509(bio, peerCert); @@ -784,7 +784,7 @@ IceSSL::OpenSSL::Connection::showSharedCiphers(BIO* bio) char buffer[4096]; char* strPointer = 0; - if ((strPointer = SSL_get_shared_ciphers(_sslConnection, buffer, sizeof(buffer))) != 0) + if((strPointer = SSL_get_shared_ciphers(_sslConnection, buffer, sizeof(buffer))) != 0) { // This works only for SSL 2. In later protocol versions, the client does not know // what other ciphers (in addition to the one to be used in the current connection) @@ -795,9 +795,9 @@ IceSSL::OpenSSL::Connection::showSharedCiphers(BIO* bio) int j = 0; int i = 0; - while (*strPointer) + while(*strPointer) { - if (*strPointer == ':') + if(*strPointer == ':') { BIO_write(bio, " ", (15-j%25)); i++; @@ -823,7 +823,7 @@ IceSSL::OpenSSL::Connection::showSessionInfo(BIO* bio) assert(_sslConnection != 0); assert(bio != 0); - if (_sslConnection->hit) + if(_sslConnection->hit) { BIO_printf(bio, "Reused session-id\n"); } @@ -871,11 +871,11 @@ IceSSL::OpenSSL::Connection::showClientCAList(BIO* bio, const char* connType) char buffer[4096]; STACK_OF(X509_NAME)* sk = SSL_get_client_CA_list(_sslConnection); - if ((sk != 0) && (sk_X509_NAME_num(sk) > 0)) + if((sk != 0) && (sk_X509_NAME_num(sk) > 0)) { BIO_printf(bio,"---\nAcceptable %s certificate CA names\n", connType); - for (int i = 0; i < sk_X509_NAME_num(sk); i++) + for(int i = 0; i < sk_X509_NAME_num(sk); i++) { X509_NAME_oneline(sk_X509_NAME_value(sk, i), buffer, sizeof(buffer)); BIO_write(bio, buffer, strlen(buffer)); diff --git a/cpp/src/IceSSL/SslConnectionOpenSSL.h b/cpp/src/IceSSL/SslConnectionOpenSSL.h index 0d08f83ccbc..6cf2a501b4b 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSL.h +++ b/cpp/src/IceSSL/SslConnectionOpenSSL.h @@ -1,206 +1,206 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTION_OPENSSL_H -#define ICE_SSL_CONNECTION_OPENSSL_H - -#include <IceUtil/Mutex.h> -#include <IceSSL/SslConnection.h> -#include <IceSSL/PluginBaseIF.h> -#include <IceSSL/SslConnectionOpenSSLF.h> -#include <IceSSL/CertificateVerifierOpenSSL.h> -#include <IceSSL/TraceLevelsF.h> - -#include <openssl/ssl.h> - -#include <map> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class SafeFlag -{ -public: - - SafeFlag(bool flagVal = false) - { - _flag = flagVal; - } - - ~SafeFlag() - { - } - - bool checkAndSet() - { - IceUtil::Mutex::Lock sync(_mutex); - - if (_flag) - { - return false; - } - else - { - _flag = true; - return true; - } - } - - bool check() - { - IceUtil::Mutex::Lock sync(_mutex); - return _flag; - } - - void set() - { - IceUtil::Mutex::Lock sync(_mutex); - _flag = true; - } - - void unset() - { - IceUtil::Mutex::Lock sync(_mutex); - _flag = false; - } - -private: - - IceUtil::Mutex _mutex; - bool _flag; -}; - -class HandshakeSentinel -{ -public: - - HandshakeSentinel(SafeFlag& handshakeFlag) : - _flag(handshakeFlag) - { - _ownHandshake = _flag.checkAndSet(); - } - - ~HandshakeSentinel() - { - if (_ownHandshake) - { - _flag.unset(); - } - } - - bool ownHandshake() - { - return _ownHandshake; - } - -private: - - bool _ownHandshake; - SafeFlag& _flag; -}; - -// NOTE: This is a mapping from SSL* to Connection*, for use with the verifyCallback. -// I have purposely not used ConnectionPtr here, as connections register themselves -// with this map on construction and unregister themselves in the destructor. If -// this map used ConnectionPtr, Connection instances would never destruct as there -// would always be a reference to them from the map. -typedef std::map<SSL*, Connection*> SslConnectionMap; - -typedef enum -{ - Handshake, // The connection is negotiating a connection with the peer. - Shutdown, // The connection is in the process of shutting down. - Connected // The connection is connected - communication may continue. -} ConnectPhase; - -class Connection : public IceSSL::Connection -{ -public: - - Connection(const IceSSL::CertificateVerifierPtr&, - SSL*, - const IceSSL::PluginBaseIPtr&); - virtual ~Connection(); - - virtual int shutdown(int timeout = 0); - - virtual int read(IceInternal::Buffer&, int); - virtual int write(IceInternal::Buffer&, int) = 0; - - virtual int handshake(int timeout = 0) = 0; - - void setHandshakeReadTimeout(int timeout); - - static ConnectionPtr getConnection(SSL*); - - // Callback from OpenSSL for purposes of certificate verification - int verifyCertificate(int, X509_STORE_CTX*); - -protected: - - int connect(); - int accept(); - int renegotiate(); - int initialize(int timeout); - - int pending(); - int getLastError() const; - - int sslRead(char*, int); - int sslWrite(char*, int); - - int select(int, bool); - int readSelect(int); - int writeSelect(int); - - int readSSL(IceInternal::Buffer&, int); - - static void addConnection(SSL*, Connection*); - static void removeConnection(SSL*); - - virtual void showConnectionInfo() = 0; - - void showCertificateChain(BIO*); - void showPeerCertificate(BIO*, const char*); - void showSharedCiphers(BIO*); - void showSessionInfo(BIO*); - void showSelectedCipherInfo(BIO*); - void showHandshakeStats(BIO*); - void showClientCAList(BIO*, const char*); - - void setLastError(int errorCode) { _lastError = errorCode; }; - - static SslConnectionMap _connectionMap; - static IceUtil::Mutex _connectionRepositoryMutex; - - // Pointer to the OpenSSL Connection structure. - SSL* _sslConnection; - - int _lastError; - - IceUtil::Mutex _handshakeWaitMutex; - - SafeFlag _handshakeFlag; - int _initWantRead; - int _initWantWrite; - int _handshakeReadTimeout; - int _readTimeout; - - ConnectPhase _phase; -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTION_OPENSSL_H
+#define ICE_SSL_CONNECTION_OPENSSL_H
+
+#include <IceUtil/Mutex.h>
+#include <IceSSL/SslConnection.h>
+#include <IceSSL/PluginBaseIF.h>
+#include <IceSSL/SslConnectionOpenSSLF.h>
+#include <IceSSL/CertificateVerifierOpenSSL.h>
+#include <IceSSL/TraceLevelsF.h>
+
+#include <openssl/ssl.h>
+
+#include <map>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class SafeFlag
+{
+public:
+
+ SafeFlag(bool flagVal = false)
+ {
+ _flag = flagVal;
+ }
+
+ ~SafeFlag()
+ {
+ }
+
+ bool checkAndSet()
+ {
+ IceUtil::Mutex::Lock sync(_mutex);
+
+ if(_flag)
+ {
+ return false;
+ }
+ else
+ {
+ _flag = true;
+ return true;
+ }
+ }
+
+ bool check()
+ {
+ IceUtil::Mutex::Lock sync(_mutex);
+ return _flag;
+ }
+
+ void set()
+ {
+ IceUtil::Mutex::Lock sync(_mutex);
+ _flag = true;
+ }
+
+ void unset()
+ {
+ IceUtil::Mutex::Lock sync(_mutex);
+ _flag = false;
+ }
+
+private:
+
+ IceUtil::Mutex _mutex;
+ bool _flag;
+};
+
+class HandshakeSentinel
+{
+public:
+
+ HandshakeSentinel(SafeFlag& handshakeFlag) :
+ _flag(handshakeFlag)
+ {
+ _ownHandshake = _flag.checkAndSet();
+ }
+
+ ~HandshakeSentinel()
+ {
+ if(_ownHandshake)
+ {
+ _flag.unset();
+ }
+ }
+
+ bool ownHandshake()
+ {
+ return _ownHandshake;
+ }
+
+private:
+
+ bool _ownHandshake;
+ SafeFlag& _flag;
+};
+
+// NOTE: This is a mapping from SSL* to Connection*, for use with the verifyCallback.
+// I have purposely not used ConnectionPtr here, as connections register themselves
+// with this map on construction and unregister themselves in the destructor. If
+// this map used ConnectionPtr, Connection instances would never destruct as there
+// would always be a reference to them from the map.
+typedef std::map<SSL*, Connection*> SslConnectionMap;
+
+typedef enum
+{
+ Handshake, // The connection is negotiating a connection with the peer.
+ Shutdown, // The connection is in the process of shutting down.
+ Connected // The connection is connected - communication may continue.
+} ConnectPhase;
+
+class Connection : public IceSSL::Connection
+{
+public:
+
+ Connection(const IceSSL::CertificateVerifierPtr&,
+ SSL*,
+ const IceSSL::PluginBaseIPtr&);
+ virtual ~Connection();
+
+ virtual int shutdown(int timeout = 0);
+
+ virtual int read(IceInternal::Buffer&, int);
+ virtual int write(IceInternal::Buffer&, int) = 0;
+
+ virtual int handshake(int timeout = 0) = 0;
+
+ void setHandshakeReadTimeout(int timeout);
+
+ static ConnectionPtr getConnection(SSL*);
+
+ // Callback from OpenSSL for purposes of certificate verification
+ int verifyCertificate(int, X509_STORE_CTX*);
+
+protected:
+
+ int connect();
+ int accept();
+ int renegotiate();
+ int initialize(int timeout);
+
+ int pending();
+ int getLastError() const;
+
+ int sslRead(char*, int);
+ int sslWrite(char*, int);
+
+ int select(int, bool);
+ int readSelect(int);
+ int writeSelect(int);
+
+ int readSSL(IceInternal::Buffer&, int);
+
+ static void addConnection(SSL*, Connection*);
+ static void removeConnection(SSL*);
+
+ virtual void showConnectionInfo() = 0;
+
+ void showCertificateChain(BIO*);
+ void showPeerCertificate(BIO*, const char*);
+ void showSharedCiphers(BIO*);
+ void showSessionInfo(BIO*);
+ void showSelectedCipherInfo(BIO*);
+ void showHandshakeStats(BIO*);
+ void showClientCAList(BIO*, const char*);
+
+ void setLastError(int errorCode) { _lastError = errorCode; };
+
+ static SslConnectionMap _connectionMap;
+ static IceUtil::Mutex _connectionRepositoryMutex;
+
+ // Pointer to the OpenSSL Connection structure.
+ SSL* _sslConnection;
+
+ int _lastError;
+
+ IceUtil::Mutex _handshakeWaitMutex;
+
+ SafeFlag _handshakeFlag;
+ int _initWantRead;
+ int _initWantWrite;
+ int _handshakeReadTimeout;
+ int _readTimeout;
+
+ ConnectPhase _phase;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp b/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp index acfbdd6bc71..15042ebd0b6 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp +++ b/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp @@ -57,26 +57,26 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) int retCode = SSL_is_init_finished(_sslConnection); - while (!retCode) + while(!retCode) { _readTimeout = timeout > _handshakeReadTimeout ? timeout : _handshakeReadTimeout; - if (_initWantRead) + if(_initWantRead) { int i = readSelect(_readTimeout); - if (i == 0) + if(i == 0) { return 0; } _initWantRead = 0; } - else if (_initWantWrite) + else if(_initWantWrite) { int i = writeSelect(timeout); - if (i == 0) + if(i == 0) { return 0; } @@ -86,7 +86,7 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) int result = connect(); - switch (getLastError()) + switch(getLastError()) { case SSL_ERROR_WANT_READ: { @@ -119,18 +119,18 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) { // IO Error in underlying BIO - if (interrupted()) + if(interrupted()) { break; } - if (wouldBlock()) + if(wouldBlock()) { readSelect(_readTimeout); break; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -165,7 +165,7 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) { int verifyError = SSL_get_verify_result(_sslConnection); - if (verifyError != X509_V_OK && verifyError != 1) + if(verifyError != X509_V_OK && verifyError != 1) { CertificateVerificationException certVerEx(__FILE__, __LINE__); @@ -173,7 +173,7 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) string errors = sslGetErrors(); - if (!errors.empty()) + if(!errors.empty()) { certVerEx._message += "\n"; certVerEx._message += errors; @@ -206,7 +206,7 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) retCode = SSL_is_init_finished(_sslConnection); - if (retCode > 0) + if(retCode > 0) { _phase = Connected; @@ -231,17 +231,17 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) // Limit packet size to avoid performance problems on WIN32. // (blatantly ripped off from Marc Laukien) // - if (packetSize > 64 * 1024) + if(packetSize > 64 * 1024) { packetSize = 64 * 1024; } #endif // We keep reading until we're done - while (buf.i != buf.b.end()) + while(buf.i != buf.b.end()) { // Ensure we're initialized. - if (initialize(timeout) <= 0) + if(initialize(timeout) <= 0) { // Retry the initialize call continue; @@ -250,7 +250,7 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) // initialize() must have returned > 0, so we're okay to try a write. // Perform a select on the socket. - if (!writeSelect(timeout)) + if(!writeSelect(timeout)) { // We're done here. break; @@ -258,13 +258,13 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) bytesWritten = sslWrite(static_cast<char*>(&*buf.i), packetSize); - switch (getLastError()) + switch(getLastError()) { case SSL_ERROR_NONE: { - if (bytesWritten > 0) + if(bytesWritten > 0) { - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { ostringstream s; s << "sent " << bytesWritten << " of " << packetSize; @@ -276,7 +276,7 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) buf.i += bytesWritten; - if (packetSize > buf.b.end() - buf.i) + if(packetSize > buf.b.end() - buf.i) { packetSize = buf.b.end() - buf.i; } @@ -299,21 +299,21 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) // requiring shutdown. // If nothing was written, the demo client stops writing - we continue. // This is potentially something wierd to watch out for. - if (bytesWritten == -1) + if(bytesWritten == -1) { // IO Error in underlying BIO - if (interrupted()) + if(interrupted()) { break; } - if (wouldBlock()) + if(wouldBlock()) { break; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -324,7 +324,7 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) ex.error = getSocketErrno(); throw ex; } - else if (bytesWritten > 0) + else if(bytesWritten > 0) { ProtocolException protocolEx(__FILE__, __LINE__); @@ -371,7 +371,7 @@ void IceSSL::OpenSSL::ClientConnection::showConnectionInfo() { // Only in extreme cases do we enable this, partially because it doesn't use the Logger. - if ((_traceLevels->security >= IceSSL::SECURITY_PROTOCOL_DEBUG) && 0) + if((_traceLevels->security >= IceSSL::SECURITY_PROTOCOL_DEBUG) && 0) { BIOJanitor bioJanitor(BIO_new_fp(stdout, BIO_NOCLOSE)); BIO* bio = bioJanitor.get(); diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLClient.h b/cpp/src/IceSSL/SslConnectionOpenSSLClient.h index 89903e5c8a8..988bd20411e 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLClient.h +++ b/cpp/src/IceSSL/SslConnectionOpenSSLClient.h @@ -1,44 +1,44 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTION_OPENSSL_CLIENT_H -#define ICE_SSL_CONNECTION_OPENSSL_CLIENT_H - -#include <IceSSL/SslConnectionOpenSSL.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ClientConnection : public Connection -{ -public: - - ClientConnection(const IceSSL::CertificateVerifierPtr&, - SSL*, - const IceSSL::PluginBaseIPtr&); - virtual ~ClientConnection(); - - virtual int handshake(int timeout = 0); - - virtual int write(IceInternal::Buffer&, int); - -protected: - - virtual void showConnectionInfo(); -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTION_OPENSSL_CLIENT_H
+#define ICE_SSL_CONNECTION_OPENSSL_CLIENT_H
+
+#include <IceSSL/SslConnectionOpenSSL.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ClientConnection : public Connection
+{
+public:
+
+ ClientConnection(const IceSSL::CertificateVerifierPtr&,
+ SSL*,
+ const IceSSL::PluginBaseIPtr&);
+ virtual ~ClientConnection();
+
+ virtual int handshake(int timeout = 0);
+
+ virtual int write(IceInternal::Buffer&, int);
+
+protected:
+
+ virtual void showConnectionInfo();
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLF.h b/cpp/src/IceSSL/SslConnectionOpenSSLF.h index 4c35b8166a3..b5fb778de64 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLF.h +++ b/cpp/src/IceSSL/SslConnectionOpenSSLF.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTION_OPENSSL_F_H -#define ICE_SSL_CONNECTION_OPENSSL_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class Connection; -typedef IceInternal::Handle<Connection> ConnectionPtr; - -} - -} - -namespace IceInternal -{ - -void incRef(::IceSSL::OpenSSL::Connection*); -void decRef(::IceSSL::OpenSSL::Connection*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTION_OPENSSL_F_H
+#define ICE_SSL_CONNECTION_OPENSSL_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class Connection;
+typedef IceInternal::Handle<Connection> ConnectionPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::OpenSSL::Connection*);
+void decRef(::IceSSL::OpenSSL::Connection*);
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp b/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp index 1933a5056a1..e925e6d61b2 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp +++ b/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp @@ -59,15 +59,15 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) int retCode = SSL_is_init_finished(_sslConnection); - while (!retCode) + while(!retCode) { _readTimeout = timeout > _handshakeReadTimeout ? timeout : _handshakeReadTimeout; - if (_initWantWrite) + if(_initWantWrite) { int i = writeSelect(timeout); - if (i == 0) + if(i == 0) { cerr << "-" << flush; return 0; @@ -79,7 +79,7 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) { int i = readSelect(_readTimeout); - if (i == 0) + if(i == 0) { cerr << "-" << flush; return 0; @@ -89,12 +89,12 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) int result = accept(); // We're doing an Accept and we don't get a retry on the socket. - if ((result <= 0) && (BIO_sock_should_retry(result) == 0)) + if((result <= 0) && (BIO_sock_should_retry(result) == 0)) { // Socket can't retry - bad scene, find out why. long verifyError = SSL_get_verify_result(_sslConnection); - if (verifyError != X509_V_OK) + if(verifyError != X509_V_OK) { // Flag the connection for shutdown, let the // usual initialization take care of it. @@ -115,7 +115,7 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) } // Find out what the error was (if any). - switch (getLastError()) + switch(getLastError()) { case SSL_ERROR_WANT_WRITE: { @@ -139,18 +139,18 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) // if you look at their code). if(result == -1) { - if (interrupted()) + if(interrupted()) { break; } - if (wouldBlock()) + if(wouldBlock()) { readSelect(_readTimeout); break; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -197,7 +197,7 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) retCode = SSL_is_init_finished(_sslConnection); - if (retCode > 0) + if(retCode > 0) { _phase = Connected; @@ -221,17 +221,17 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) // // Limit packet size to avoid performance problems on WIN32. // - if (packetSize > 64 * 1024) + if(packetSize > 64 * 1024) { packetSize = 64 * 1024; } #endif // We keep writing until we're done. - while (buf.i != buf.b.end()) + while(buf.i != buf.b.end()) { // Ensure we're initialized. - if (initialize(timeout) <= 0) + if(initialize(timeout) <= 0) { // Retry the initialize call continue; @@ -240,7 +240,7 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) // initialize() must have returned > 0, so we're okay to try a write. // Perform a select on the socket. - if (!writeSelect(timeout)) + if(!writeSelect(timeout)) { // We're done here. break; @@ -248,11 +248,11 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) bytesWritten = sslWrite(static_cast<char*>(&*buf.i), packetSize); - switch (getLastError()) + switch(getLastError()) { case SSL_ERROR_NONE: { - if (_traceLevels->network >= 3) + if(_traceLevels->network >= 3) { ostringstream s; s << "sent " << bytesWritten << " of " << packetSize; @@ -264,7 +264,7 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) buf.i += bytesWritten; - if (packetSize > buf.b.end() - buf.i) + if(packetSize > buf.b.end() - buf.i) { packetSize = buf.b.end() - buf.i; } @@ -280,21 +280,21 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) case SSL_ERROR_SYSCALL: { - if (bytesWritten == -1) + if(bytesWritten == -1) { // IO Error in underlying BIO - if (interrupted()) + if(interrupted()) { break; } - if (wouldBlock()) + if(wouldBlock()) { break; } - if (connectionLost()) + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); @@ -347,7 +347,7 @@ void IceSSL::OpenSSL::ServerConnection::showConnectionInfo() { // Only in extreme cases do we enable this, partially because it doesn't use the Logger. - if ((_traceLevels->security >= IceSSL::SECURITY_PROTOCOL_DEBUG) && 0) + if((_traceLevels->security >= IceSSL::SECURITY_PROTOCOL_DEBUG) && 0) { BIOJanitor bioJanitor(BIO_new_fp(stdout, BIO_NOCLOSE)); BIO* bio = bioJanitor.get(); diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLServer.h b/cpp/src/IceSSL/SslConnectionOpenSSLServer.h index fb990670f68..6e1b91a524b 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLServer.h +++ b/cpp/src/IceSSL/SslConnectionOpenSSLServer.h @@ -1,44 +1,44 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTION_OPENSSL_SERVER_H -#define ICE_SSL_CONNECTION_OPENSSL_SERVER_H - -#include <IceSSL/SslConnectionOpenSSL.h> - -namespace IceSSL -{ - -namespace OpenSSL -{ - -class ServerConnection : public Connection -{ -public: - - ServerConnection(const IceSSL::CertificateVerifierPtr&, - SSL*, - const IceSSL::PluginBaseIPtr&); - virtual ~ServerConnection(); - - virtual int handshake(int timeout = 0); - - virtual int write(IceInternal::Buffer&, int); - -protected: - - virtual void showConnectionInfo(); -}; - -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTION_OPENSSL_SERVER_H
+#define ICE_SSL_CONNECTION_OPENSSL_SERVER_H
+
+#include <IceSSL/SslConnectionOpenSSL.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class ServerConnection : public Connection
+{
+public:
+
+ ServerConnection(const IceSSL::CertificateVerifierPtr&,
+ SSL*,
+ const IceSSL::PluginBaseIPtr&);
+ virtual ~ServerConnection();
+
+ virtual int handshake(int timeout = 0);
+
+ virtual int write(IceInternal::Buffer&, int);
+
+protected:
+
+ virtual void showConnectionInfo();
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslConnector.cpp b/cpp/src/IceSSL/SslConnector.cpp index be354757e81..d82288e8b52 100644 --- a/cpp/src/IceSSL/SslConnector.cpp +++ b/cpp/src/IceSSL/SslConnector.cpp @@ -26,7 +26,7 @@ IceSSL::SslConnector::connect(int timeout) TraceLevelsPtr traceLevels = _plugin->getTraceLevels(); LoggerPtr logger = _plugin->getLogger(); - if (traceLevels->network >= 2) + if(traceLevels->network >= 2) { ostringstream s; s << "trying to establish ssl connection to " << toString(); @@ -37,7 +37,7 @@ IceSSL::SslConnector::connect(int timeout) setBlock(fd, false); doConnect(fd, _addr, timeout); - if (traceLevels->network >= 1) + if(traceLevels->network >= 1) { ostringstream s; s << "ssl connection established\n" << fdToString(fd); diff --git a/cpp/src/IceSSL/SslConnector.h b/cpp/src/IceSSL/SslConnector.h index de556f0e3ba..7514abcc82b 100644 --- a/cpp/src/IceSSL/SslConnector.h +++ b/cpp/src/IceSSL/SslConnector.h @@ -1,46 +1,46 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_CONNECTOR_H -#define ICE_SSL_CONNECTOR_H - -#include <Ice/TransceiverF.h> -#include <Ice/Connector.h> -#include <IceSSL/PluginBaseIF.h> - -#ifndef _WIN32 -# include <netinet/in.h> // For struct sockaddr_in -#endif - -namespace IceSSL -{ - -class SslEndpoint; - -class SslConnector : public IceInternal::Connector -{ -public: - - virtual IceInternal::TransceiverPtr connect(int); - virtual std::string toString() const; - -private: - - SslConnector(const PluginBaseIPtr&, const std::string&, int); - virtual ~SslConnector(); - friend class SslEndpoint; - - PluginBaseIPtr _plugin; - struct sockaddr_in _addr; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_CONNECTOR_H
+#define ICE_SSL_CONNECTOR_H
+
+#include <Ice/TransceiverF.h>
+#include <Ice/Connector.h>
+#include <IceSSL/PluginBaseIF.h>
+
+#ifndef _WIN32
+# include <netinet/in.h> // For struct sockaddr_in
+#endif
+
+namespace IceSSL
+{
+
+class SslEndpoint;
+
+class SslConnector : public IceInternal::Connector
+{
+public:
+
+ virtual IceInternal::TransceiverPtr connect(int);
+ virtual std::string toString() const;
+
+private:
+
+ SslConnector(const PluginBaseIPtr&, const std::string&, int);
+ virtual ~SslConnector();
+ friend class SslEndpoint;
+
+ PluginBaseIPtr _plugin;
+ struct sockaddr_in _addr;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslEndpoint.cpp b/cpp/src/IceSSL/SslEndpoint.cpp index 8c5e000ec15..c3b593a8d77 100644 --- a/cpp/src/IceSSL/SslEndpoint.cpp +++ b/cpp/src/IceSSL/SslEndpoint.cpp @@ -39,44 +39,44 @@ IceSSL::SslEndpoint::SslEndpoint(const PluginBaseIPtr& plugin, const string& str string::size_type beg; string::size_type end = 0; - while (true) + while(true) { beg = str.find_first_not_of(delim, end); - if (beg == string::npos) + if(beg == string::npos) { break; } end = str.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } string option = str.substr(beg, end - beg); - if (option.length() != 2 || option[0] != '-') + if(option.length() != 2 || option[0] != '-') { throw EndpointParseException(__FILE__, __LINE__); } string argument; string::size_type argumentBeg = str.find_first_not_of(delim, end); - if (argumentBeg != string::npos && str[argumentBeg] != '-') + if(argumentBeg != string::npos && str[argumentBeg] != '-') { beg = argumentBeg; end = str.find_first_of(delim, beg); - if (end == string::npos) + if(end == string::npos) { end = str.length(); } argument = str.substr(beg, end - beg); } - switch (option[1]) + switch(option[1]) { case 'h': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -86,7 +86,7 @@ IceSSL::SslEndpoint::SslEndpoint(const PluginBaseIPtr& plugin, const string& str case 'p': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -96,7 +96,7 @@ IceSSL::SslEndpoint::SslEndpoint(const PluginBaseIPtr& plugin, const string& str case 't': { - if (argument.empty()) + if(argument.empty()) { throw EndpointParseException(__FILE__, __LINE__); } @@ -111,7 +111,7 @@ IceSSL::SslEndpoint::SslEndpoint(const PluginBaseIPtr& plugin, const string& str } } - if (_host.empty()) + if(_host.empty()) { const_cast<string&>(_host) = _plugin->getProtocolPluginFacade()->getDefaultHost(); } @@ -145,7 +145,7 @@ IceSSL::SslEndpoint::toString() const { ostringstream s; s << "ssl -h " << _host << " -p " << _port; - if (_timeout != -1) + if(_timeout != -1) { s << " -t " << _timeout; } @@ -167,7 +167,7 @@ IceSSL::SslEndpoint::timeout() const EndpointPtr IceSSL::SslEndpoint::timeout(Int timeout) const { - if (timeout == _timeout) + if(timeout == _timeout) { return const_cast<SslEndpoint*>(this); } @@ -232,7 +232,7 @@ bool IceSSL::SslEndpoint::equivalent(const AcceptorPtr& acceptor) const { const SslAcceptor* sslAcceptor = dynamic_cast<const SslAcceptor*>(acceptor.get()); - if (!sslAcceptor) + if(!sslAcceptor) { return false; } @@ -243,27 +243,27 @@ bool IceSSL::SslEndpoint::operator==(const Endpoint& r) const { const SslEndpoint* p = dynamic_cast<const SslEndpoint*>(&r); - if (!p) + if(!p) { return false; } - if (this == p) + if(this == p) { return true; } - if (_port != p->_port) + if(_port != p->_port) { return false; } - if (_timeout != p->_timeout) + if(_timeout != p->_timeout) { return false; } - if (_host != p->_host) + if(_host != p->_host) { // // We do the most time-consuming part of the comparison last. @@ -288,35 +288,35 @@ bool IceSSL::SslEndpoint::operator<(const Endpoint& r) const { const SslEndpoint* p = dynamic_cast<const SslEndpoint*>(&r); - if (!p) + if(!p) { return type() < r.type(); } - if (this == p) + if(this == p) { return false; } - if (_port < p->_port) + if(_port < p->_port) { return true; } - else if (p->_port < _port) + else if(p->_port < _port) { return false; } - if (_timeout < p->_timeout) + if(_timeout < p->_timeout) { return true; } - else if (p->_timeout < _timeout) + else if(p->_timeout < _timeout) { return false; } - if (_host != p->_host) + if(_host != p->_host) { // // We do the most time-consuming part of the comparison last. @@ -325,11 +325,11 @@ IceSSL::SslEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host, _port, laddr); getAddress(p->_host, p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) + if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; } - else if (raddr.sin_addr.s_addr < laddr.sin_addr.s_addr) + else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr) { return false; } diff --git a/cpp/src/IceSSL/SslEndpoint.h b/cpp/src/IceSSL/SslEndpoint.h index 308f4b072db..4f2c4303737 100644 --- a/cpp/src/IceSSL/SslEndpoint.h +++ b/cpp/src/IceSSL/SslEndpoint.h @@ -1,81 +1,81 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_ENDPOINT_H -#define ICE_SSL_ENDPOINT_H - -#include <Ice/Endpoint.h> -#include <Ice/EndpointFactory.h> -#include <IceSSL/PluginBaseI.h> - -namespace IceSSL -{ - -const ::Ice::Short SslEndpointType = 2; - -class SslEndpoint : public IceInternal::Endpoint -{ -public: - - SslEndpoint(const IceSSL::PluginBaseIPtr&, const std::string&, ::Ice::Int, ::Ice::Int); - SslEndpoint(const IceSSL::PluginBaseIPtr&, const std::string&); - SslEndpoint(const IceSSL::PluginBaseIPtr&, IceInternal::BasicStream*); - - virtual void streamWrite(IceInternal::BasicStream*) const; - virtual std::string toString() const; - virtual ::Ice::Short type() const; - virtual ::Ice::Int timeout() const; - virtual IceInternal::EndpointPtr timeout(::Ice::Int) const; - virtual bool datagram() const; - virtual bool secure() const; - virtual bool unknown() const; - virtual IceInternal::TransceiverPtr clientTransceiver() const; - virtual IceInternal::TransceiverPtr serverTransceiver(IceInternal::EndpointPtr&) const; - virtual IceInternal::ConnectorPtr connector() const; - virtual IceInternal::AcceptorPtr acceptor(IceInternal::EndpointPtr&) const; - virtual bool equivalent(const IceInternal::TransceiverPtr&) const; - virtual bool equivalent(const IceInternal::AcceptorPtr&) const; - - virtual bool operator==(const IceInternal::Endpoint&) const; - virtual bool operator!=(const IceInternal::Endpoint&) const; - virtual bool operator<(const IceInternal::Endpoint&) const; - -private: - - // - // All members are const, because endpoints are immutable. - // - const IceSSL::PluginBaseIPtr _plugin; - const std::string _host; - const ::Ice::Int _port; - const ::Ice::Int _timeout; -}; - -class SslEndpointFactory : public IceInternal::EndpointFactory -{ -public: - - SslEndpointFactory(const IceSSL::PluginBaseIPtr&); - virtual ~SslEndpointFactory(); - - virtual ::Ice::Short type() const; - virtual const ::std::string& protocol() const; - virtual IceInternal::EndpointPtr create(const std::string&) const; - virtual IceInternal::EndpointPtr read(IceInternal::BasicStream*) const; - virtual void destroy(); - -private: - - IceSSL::PluginBaseIPtr _plugin; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_ENDPOINT_H
+#define ICE_SSL_ENDPOINT_H
+
+#include <Ice/Endpoint.h>
+#include <Ice/EndpointFactory.h>
+#include <IceSSL/PluginBaseI.h>
+
+namespace IceSSL
+{
+
+const ::Ice::Short SslEndpointType = 2;
+
+class SslEndpoint : public IceInternal::Endpoint
+{
+public:
+
+ SslEndpoint(const IceSSL::PluginBaseIPtr&, const std::string&, ::Ice::Int, ::Ice::Int);
+ SslEndpoint(const IceSSL::PluginBaseIPtr&, const std::string&);
+ SslEndpoint(const IceSSL::PluginBaseIPtr&, IceInternal::BasicStream*);
+
+ virtual void streamWrite(IceInternal::BasicStream*) const;
+ virtual std::string toString() const;
+ virtual ::Ice::Short type() const;
+ virtual ::Ice::Int timeout() const;
+ virtual IceInternal::EndpointPtr timeout(::Ice::Int) const;
+ virtual bool datagram() const;
+ virtual bool secure() const;
+ virtual bool unknown() const;
+ virtual IceInternal::TransceiverPtr clientTransceiver() const;
+ virtual IceInternal::TransceiverPtr serverTransceiver(IceInternal::EndpointPtr&) const;
+ virtual IceInternal::ConnectorPtr connector() const;
+ virtual IceInternal::AcceptorPtr acceptor(IceInternal::EndpointPtr&) const;
+ virtual bool equivalent(const IceInternal::TransceiverPtr&) const;
+ virtual bool equivalent(const IceInternal::AcceptorPtr&) const;
+
+ virtual bool operator==(const IceInternal::Endpoint&) const;
+ virtual bool operator!=(const IceInternal::Endpoint&) const;
+ virtual bool operator<(const IceInternal::Endpoint&) const;
+
+private:
+
+ //
+ // All members are const, because endpoints are immutable.
+ //
+ const IceSSL::PluginBaseIPtr _plugin;
+ const std::string _host;
+ const ::Ice::Int _port;
+ const ::Ice::Int _timeout;
+};
+
+class SslEndpointFactory : public IceInternal::EndpointFactory
+{
+public:
+
+ SslEndpointFactory(const IceSSL::PluginBaseIPtr&);
+ virtual ~SslEndpointFactory();
+
+ virtual ::Ice::Short type() const;
+ virtual const ::std::string& protocol() const;
+ virtual IceInternal::EndpointPtr create(const std::string&) const;
+ virtual IceInternal::EndpointPtr read(IceInternal::BasicStream*) const;
+ virtual void destroy();
+
+private:
+
+ IceSSL::PluginBaseIPtr _plugin;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/SslException.cpp b/cpp/src/IceSSL/SslException.cpp index bc5d645450a..dbda359f50c 100644 --- a/cpp/src/IceSSL/SslException.cpp +++ b/cpp/src/IceSSL/SslException.cpp @@ -18,7 +18,7 @@ void IceSSL::SslException::ice_print(ostream& out) const { Exception::ice_print(out); - if (!_message.empty()) + if(!_message.empty()) { out << ":\n" << _message; } diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp index 64dc4b002d7..72a8362d950 100644 --- a/cpp/src/IceSSL/SslTransceiver.cpp +++ b/cpp/src/IceSSL/SslTransceiver.cpp @@ -31,7 +31,7 @@ IceSSL::SslTransceiver::fd() void IceSSL::SslTransceiver::close() { - if (_traceLevels->network >= 1) + if(_traceLevels->network >= 1) { ostringstream s; s << "closing ssl connection\n" << toString(); @@ -49,7 +49,7 @@ IceSSL::SslTransceiver::close() shutdown = _sslConnection->shutdown(); retries++; } - while ((shutdown == 0) && (retries < 0)); + while((shutdown == 0) && (retries < 0)); ::shutdown(fd, SHUT_RDWR); // helps to unblock threads in recv() closeSocket(fd); @@ -58,7 +58,7 @@ IceSSL::SslTransceiver::close() void IceSSL::SslTransceiver::shutdown() { - if (_traceLevels->network >= 2) + if(_traceLevels->network >= 2) { ostringstream s; s << "shutting down ssl connection\n" << toString(); @@ -73,7 +73,7 @@ IceSSL::SslTransceiver::shutdown() shutdown = _sslConnection->shutdown(); retries++; } - while ((shutdown == 0) && (retries < 0)); + while((shutdown == 0) && (retries < 0)); ::shutdown(_fd, SHUT_WR); // Shutdown socket for writing } @@ -87,9 +87,9 @@ IceSSL::SslTransceiver::write(Buffer& buf, int timeout) void IceSSL::SslTransceiver::read(Buffer& buf, int timeout) { - if (!_sslConnection->read(buf, timeout)) + if(!_sslConnection->read(buf, timeout)) { - if (_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) { _logger->trace(_traceLevels->securityCat, "WRN reading from ssl connection returns no bytes"); } diff --git a/cpp/src/IceSSL/SslTransceiver.h b/cpp/src/IceSSL/SslTransceiver.h index fd07fcd78b6..3f37406398a 100644 --- a/cpp/src/IceSSL/SslTransceiver.h +++ b/cpp/src/IceSSL/SslTransceiver.h @@ -1,56 +1,56 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_TRANSCEIVER_H -#define ICE_SSL_TRANSCEIVER_H - -#include <Ice/LoggerF.h> -#include <Ice/Transceiver.h> -#include <IceSSL/SslConnectionF.h> -#include <IceSSL/PluginBaseIF.h> -#include <IceSSL/TraceLevelsF.h> - -namespace IceSSL -{ - -class SslConnector; -class SslAcceptor; - -class SslTransceiver : public IceInternal::Transceiver -{ -public: - - virtual SOCKET fd(); - virtual void close(); - virtual void shutdown(); - virtual void write(IceInternal::Buffer&, int); - virtual void read(IceInternal::Buffer&, int); - virtual std::string toString() const; - -private: - - SslTransceiver(const PluginBaseIPtr&, SOCKET, const ::IceSSL::ConnectionPtr&); - - virtual ~SslTransceiver(); - friend class SslConnector; - friend class SslAcceptor; - - TraceLevelsPtr _traceLevels; - Ice::LoggerPtr _logger; - SOCKET _fd; - fd_set _rFdSet; - fd_set _wFdSet; - - ::IceSSL::ConnectionPtr _sslConnection; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_TRANSCEIVER_H
+#define ICE_SSL_TRANSCEIVER_H
+
+#include <Ice/LoggerF.h>
+#include <Ice/Transceiver.h>
+#include <IceSSL/SslConnectionF.h>
+#include <IceSSL/PluginBaseIF.h>
+#include <IceSSL/TraceLevelsF.h>
+
+namespace IceSSL
+{
+
+class SslConnector;
+class SslAcceptor;
+
+class SslTransceiver : public IceInternal::Transceiver
+{
+public:
+
+ virtual SOCKET fd();
+ virtual void close();
+ virtual void shutdown();
+ virtual void write(IceInternal::Buffer&, int);
+ virtual void read(IceInternal::Buffer&, int);
+ virtual std::string toString() const;
+
+private:
+
+ SslTransceiver(const PluginBaseIPtr&, SOCKET, const ::IceSSL::ConnectionPtr&);
+
+ virtual ~SslTransceiver();
+ friend class SslConnector;
+ friend class SslAcceptor;
+
+ TraceLevelsPtr _traceLevels;
+ Ice::LoggerPtr _logger;
+ SOCKET _fd;
+ fd_set _rFdSet;
+ fd_set _wFdSet;
+
+ ::IceSSL::ConnectionPtr _sslConnection;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/TempCerts.h b/cpp/src/IceSSL/TempCerts.h index f46e7f09720..1614668cff2 100644 --- a/cpp/src/IceSSL/TempCerts.h +++ b/cpp/src/IceSSL/TempCerts.h @@ -1,68 +1,68 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_TEMP_CERTS_H -#define ICE_SSL_TEMP_CERTS_H - -#include <IceSSL/CertificateDesc.h> - -namespace IceSSL -{ - -class TempCertificates -{ -public: - - TempCertificates(); - ~TempCertificates(); - - void addRSACert(CertificateDesc&); - void addDHParams(DiffieHellmanParamsFile&); - - RSAVector& getRSACerts(); - DHVector& getDHParams(); - -protected: - - RSAVector _rsaCerts; - DHVector _dhParams; -}; - -template<class Stream> -inline Stream& operator << (Stream& target, TempCertificates& tmpCerts) -{ - RSAVector::iterator iRSA = tmpCerts.getRSACerts().begin(); - RSAVector::iterator eRSA = tmpCerts.getRSACerts().end(); - - while (iRSA != eRSA) - { - target << "RSA" << std::endl << "{" << std::endl; - target << *iRSA; - target << "}" << std::endl << std::endl; - iRSA++; - } - - DHVector::iterator iDHP = tmpCerts.getDHParams().begin(); - DHVector::iterator eDHP = tmpCerts.getDHParams().end(); - - while (iDHP != eDHP) - { - target << "DH" << std::endl << "{" << std::endl; - target << *iDHP; - target << "}" << std::endl << std::endl; - iDHP++; - } - - return target; -} - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_TEMP_CERTS_H
+#define ICE_SSL_TEMP_CERTS_H
+
+#include <IceSSL/CertificateDesc.h>
+
+namespace IceSSL
+{
+
+class TempCertificates
+{
+public:
+
+ TempCertificates();
+ ~TempCertificates();
+
+ void addRSACert(CertificateDesc&);
+ void addDHParams(DiffieHellmanParamsFile&);
+
+ RSAVector& getRSACerts();
+ DHVector& getDHParams();
+
+protected:
+
+ RSAVector _rsaCerts;
+ DHVector _dhParams;
+};
+
+template<class Stream>
+inline Stream& operator << (Stream& target, TempCertificates& tmpCerts)
+{
+ RSAVector::iterator iRSA = tmpCerts.getRSACerts().begin();
+ RSAVector::iterator eRSA = tmpCerts.getRSACerts().end();
+
+ while(iRSA != eRSA)
+ {
+ target << "RSA" << std::endl << "{" << std::endl;
+ target << *iRSA;
+ target << "}" << std::endl << std::endl;
+ iRSA++;
+ }
+
+ DHVector::iterator iDHP = tmpCerts.getDHParams().begin();
+ DHVector::iterator eDHP = tmpCerts.getDHParams().end();
+
+ while(iDHP != eDHP)
+ {
+ target << "DH" << std::endl << "{" << std::endl;
+ target << *iDHP;
+ target << "}" << std::endl << std::endl;
+ iDHP++;
+ }
+
+ return target;
+}
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/TraceLevels.h b/cpp/src/IceSSL/TraceLevels.h index d2ef318e0fc..519b8f0375b 100644 --- a/cpp/src/IceSSL/TraceLevels.h +++ b/cpp/src/IceSSL/TraceLevels.h @@ -1,37 +1,37 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_TRACE_LEVELS_H -#define ICE_SSL_TRACE_LEVELS_H - -#include <IceUtil/Shared.h> -#include <Ice/ProtocolPluginFacadeF.h> -#include <IceSSL/TraceLevelsF.h> - -namespace IceSSL -{ - -class TraceLevels : public ::IceUtil::Shared -{ -public: - - TraceLevels(const IceInternal::ProtocolPluginFacadePtr&); - virtual ~TraceLevels(); - - const int network; - const char* networkCat; - - const int security; - const char* securityCat; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_TRACE_LEVELS_H
+#define ICE_SSL_TRACE_LEVELS_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/ProtocolPluginFacadeF.h>
+#include <IceSSL/TraceLevelsF.h>
+
+namespace IceSSL
+{
+
+class TraceLevels : public ::IceUtil::Shared
+{
+public:
+
+ TraceLevels(const IceInternal::ProtocolPluginFacadePtr&);
+ virtual ~TraceLevels();
+
+ const int network;
+ const char* networkCat;
+
+ const int security;
+ const char* securityCat;
+};
+
+}
+
+#endif
diff --git a/cpp/src/IceSSL/TraceLevelsF.h b/cpp/src/IceSSL/TraceLevelsF.h index 417c3bb7630..ee35dd5c692 100644 --- a/cpp/src/IceSSL/TraceLevelsF.h +++ b/cpp/src/IceSSL/TraceLevelsF.h @@ -1,32 +1,32 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_SSL_TRACE_LEVELS_F_H -#define ICE_SSL_TRACE_LEVELS_F_H - -#include <Ice/Handle.h> - -namespace IceSSL -{ - -class TraceLevels; -typedef IceInternal::Handle<TraceLevels> TraceLevelsPtr; - -} - -namespace IceInternal -{ - -void incRef(IceSSL::TraceLevels*); -void decRef(IceSSL::TraceLevels*); - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_TRACE_LEVELS_F_H
+#define ICE_SSL_TRACE_LEVELS_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+class TraceLevels;
+typedef IceInternal::Handle<TraceLevels> TraceLevelsPtr;
+
+}
+
+namespace IceInternal
+{
+
+void incRef(IceSSL::TraceLevels*);
+void decRef(IceSSL::TraceLevels*);
+
+}
+
+#endif
diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp index 4fa1e530218..1fdf607bc93 100644 --- a/cpp/src/IceStorm/Admin.cpp +++ b/cpp/src/IceStorm/Admin.cpp @@ -77,43 +77,43 @@ Client::run(int argc, char* argv[]) bool debug = false; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-e") == 0) + else if(strcmp(argv[idx], "-e") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << appName() << ": argument expected for`" << argv[idx] << "'" << endl; usage(); @@ -123,22 +123,22 @@ Client::run(int argc, char* argv[]) commands += argv[idx + 1]; commands += ';'; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << appName() << ": unknown option `" << argv[idx] << "'" << endl; usage(); @@ -150,7 +150,7 @@ Client::run(int argc, char* argv[]) } } - if (argc >= 2 && !commands.empty()) + if(argc >= 2 && !commands.empty()) { cerr << appName() << ": `-e' option cannot be used if input files are given" << endl; usage(); @@ -159,7 +159,7 @@ Client::run(int argc, char* argv[]) const char* managerEndpointsProperty = "IceStorm.TopicManager.Endpoints"; string managerEndpoints = properties->getProperty(managerEndpointsProperty); - if (managerEndpoints.empty()) + if(managerEndpoints.empty()) { cerr << appName() << ": property `" << managerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -167,7 +167,7 @@ Client::run(int argc, char* argv[]) ObjectPrx base = communicator()->stringToProxy("TopicManager:" + managerEndpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << appName() << ": `" << managerEndpoints << "' is not running" << endl; return EXIT_FAILURE; @@ -176,12 +176,12 @@ Client::run(int argc, char* argv[]) ParserPtr parser = Parser::createParser(communicator(), manager); int status = EXIT_SUCCESS; - if (argc < 2) // No files given + if(argc < 2) // No files given { - if (!commands.empty()) // Commands were given + if(!commands.empty()) // Commands were given { int parseStatus = parser->parse(commands, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -189,7 +189,7 @@ Client::run(int argc, char* argv[]) else // No commands, let's use standard input { int parseStatus = parser->parse(stdin, debug); - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -197,10 +197,10 @@ Client::run(int argc, char* argv[]) } else // Process files given on the command line { - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << appName() << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -213,7 +213,7 @@ Client::run(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == NULL) + if(cppHandle == NULL) { cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -227,7 +227,7 @@ Client::run(int argc, char* argv[]) pclose(cppHandle); #endif - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } diff --git a/cpp/src/IceStorm/Flushable.h b/cpp/src/IceStorm/Flushable.h index ee6566e337d..f071a72beb6 100644 --- a/cpp/src/IceStorm/Flushable.h +++ b/cpp/src/IceStorm/Flushable.h @@ -1,50 +1,50 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FLUSHABLE_H -#define FLUSHABLE_H - -#include <IceUtil/Handle.h> -#include <IceUtil/Shared.h> - -namespace IceStorm -{ - -// -// Flushable interface. -// -class Flushable : public virtual IceUtil::Shared -{ -public: - - Flushable() { } - ~Flushable() { } - - // - // Flush any pending writes. - // - virtual void flush() = 0; - - // - // Is this flushable object invalid? - // - virtual bool inactive() const = 0; - - // - // Equality for flushable objects. - // - virtual bool operator==(const Flushable&) const = 0; -}; - -typedef IceUtil::Handle<Flushable> FlushablePtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FLUSHABLE_H
+#define FLUSHABLE_H
+
+#include <IceUtil/Handle.h>
+#include <IceUtil/Shared.h>
+
+namespace IceStorm
+{
+
+//
+// Flushable interface.
+//
+class Flushable : public virtual IceUtil::Shared
+{
+public:
+
+ Flushable() { }
+ ~Flushable() { }
+
+ //
+ // Flush any pending writes.
+ //
+ virtual void flush() = 0;
+
+ //
+ // Is this flushable object invalid?
+ //
+ virtual bool inactive() const = 0;
+
+ //
+ // Equality for flushable objects.
+ //
+ virtual bool operator==(const Flushable&) const = 0;
+};
+
+typedef IceUtil::Handle<Flushable> FlushablePtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/Flusher.cpp b/cpp/src/IceStorm/Flusher.cpp index 55629f92407..cbfa897f004 100644 --- a/cpp/src/IceStorm/Flusher.cpp +++ b/cpp/src/IceStorm/Flusher.cpp @@ -35,7 +35,7 @@ public: _destroy(false) { _flushTime = communicator->getProperties()->getPropertyAsIntWithDefault("IceStorm.Flush.Timeout", 1000); - if (_flushTime < 100) + if(_flushTime < 100) { _flushTime = 100; // Minimum of 100 ms } @@ -49,10 +49,10 @@ public: run() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while (!_destroy) + while(!_destroy) { long tout = calcTimeout(); - if (tout == 0) + if(tout == 0) { wait(); } @@ -60,7 +60,7 @@ public: { timedWait(IceUtil::Time::milliSeconds(tout)); } - if (_destroy) + if(_destroy) { continue; } @@ -93,7 +93,7 @@ public: // If the set of subscribers was previously empty then wake up // the flushing thread since it will be waiting indefinitely // - if (isEmpty) + if(isEmpty) { notify(); } @@ -129,7 +129,7 @@ private: // Trace after the flush so that the correct number of objects // are displayed // - if (_traceLevels->flush > 0) + if(_traceLevels->flush > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->flushCat); out << _subscribers.size() << " object(s)"; diff --git a/cpp/src/IceStorm/Flusher.h b/cpp/src/IceStorm/Flusher.h index ab0828ee146..dd1849ee7be 100644 --- a/cpp/src/IceStorm/Flusher.h +++ b/cpp/src/IceStorm/Flusher.h @@ -1,56 +1,56 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef FLUSHER_H -#define FLUSHER_H - -#include <IceUtil/Handle.h> -#include <IceUtil/Shared.h> -#include <Ice/CommunicatorF.h> - -namespace IceStorm -{ - -// -// Forward declarations. -// -class FlusherThread; -typedef IceUtil::Handle<FlusherThread> FlusherThreadPtr; - -class TraceLevels; -typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; - -class Flushable; -typedef IceUtil::Handle<Flushable> FlushablePtr; - -// -// Responsible for flushing Flushable objects at regular intervals. -// -class Flusher : public IceUtil::Shared -{ -public: - - Flusher(const Ice::CommunicatorPtr&, const TraceLevelsPtr&); - ~Flusher(); - - void add(const FlushablePtr&); - void remove(const FlushablePtr&); - void stopFlushing(); - -private: - - FlusherThreadPtr _thread; -}; - -typedef IceUtil::Handle<Flusher> FlusherPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef FLUSHER_H
+#define FLUSHER_H
+
+#include <IceUtil/Handle.h>
+#include <IceUtil/Shared.h>
+#include <Ice/CommunicatorF.h>
+
+namespace IceStorm
+{
+
+//
+// Forward declarations.
+//
+class FlusherThread;
+typedef IceUtil::Handle<FlusherThread> FlusherThreadPtr;
+
+class TraceLevels;
+typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
+
+class Flushable;
+typedef IceUtil::Handle<Flushable> FlushablePtr;
+
+//
+// Responsible for flushing Flushable objects at regular intervals.
+//
+class Flusher : public IceUtil::Shared
+{
+public:
+
+ Flusher(const Ice::CommunicatorPtr&, const TraceLevelsPtr&);
+ ~Flusher();
+
+ void add(const FlushablePtr&);
+ void remove(const FlushablePtr&);
+ void stopFlushing();
+
+private:
+
+ FlusherThreadPtr _thread;
+};
+
+typedef IceUtil::Handle<Flusher> FlusherPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/LinkSubscriber.cpp b/cpp/src/IceStorm/LinkSubscriber.cpp index 3b13c133685..b9b563848b8 100644 --- a/cpp/src/IceStorm/LinkSubscriber.cpp +++ b/cpp/src/IceStorm/LinkSubscriber.cpp @@ -44,7 +44,7 @@ LinkSubscriber::unsubscribe() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateUnsubscribed; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << "Unsubscribe " << _obj->ice_getIdentity(); @@ -57,7 +57,7 @@ LinkSubscriber::replace() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateReplaced; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << "Replace " << _obj->ice_getIdentity(); @@ -70,7 +70,7 @@ LinkSubscriber::publish(const Event& event) // // Don't forward forwarded, or more costly events. // - if (event.forwarded || event.cost > _cost) + if(event.forwarded || event.cost > _cost) { return; } @@ -87,7 +87,7 @@ LinkSubscriber::publish(const Event& event) IceUtil::Mutex::Lock sync(_stateMutex); _state = StateError; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << _obj->ice_getIdentity() << ": link topic publish failed: " << e; @@ -95,7 +95,7 @@ LinkSubscriber::publish(const Event& event) } catch(const Ice::LocalException& e) { - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << _obj->ice_getIdentity() << ": link topic publish failed: " << e; @@ -118,7 +118,7 @@ LinkSubscriber::flush() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateError; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << _obj->ice_getIdentity() << ": link topic flush failed: " << e; @@ -126,7 +126,7 @@ LinkSubscriber::flush() } catch(const Ice::LocalException& e) { - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << _obj->ice_getIdentity() << ": link topic flush failed: " << e; @@ -138,7 +138,7 @@ bool LinkSubscriber::operator==(const Flushable& therhs) const { const LinkSubscriber* rhs = dynamic_cast<const LinkSubscriber*>(&therhs); - if (rhs != 0) + if(rhs != 0) { return id() == rhs->id(); } diff --git a/cpp/src/IceStorm/LinkSubscriber.h b/cpp/src/IceStorm/LinkSubscriber.h index 5b437892f49..45f447d1e8f 100644 --- a/cpp/src/IceStorm/LinkSubscriber.h +++ b/cpp/src/IceStorm/LinkSubscriber.h @@ -1,47 +1,47 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef LINK_SUBSCRIBER_H -#define LINK_SUBSCRIBER_H - -#include <IceStorm/Flushable.h> -#include <IceStorm/Subscriber.h> -#include <IceStorm/IceStormInternal.h> // For TopicLink - -namespace IceStorm -{ - -class LinkSubscriber : public Subscriber, public Flushable -{ -public: - - LinkSubscriber(const TraceLevelsPtr&, const TopicLinkPrx&, Ice::Int); - ~LinkSubscriber(); - - virtual bool persistent() const; - virtual bool inactive() const; - virtual void unsubscribe(); - virtual void replace(); - virtual void publish(const Event&); - - virtual void flush(); - virtual bool operator==(const Flushable&) const; - -private: - - // Immutable - TopicLinkPrx _obj; - Ice::Int _cost; -}; - -} // End namespace IceStorm - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef LINK_SUBSCRIBER_H
+#define LINK_SUBSCRIBER_H
+
+#include <IceStorm/Flushable.h>
+#include <IceStorm/Subscriber.h>
+#include <IceStorm/IceStormInternal.h> // For TopicLink
+
+namespace IceStorm
+{
+
+class LinkSubscriber : public Subscriber, public Flushable
+{
+public:
+
+ LinkSubscriber(const TraceLevelsPtr&, const TopicLinkPrx&, Ice::Int);
+ ~LinkSubscriber();
+
+ virtual bool persistent() const;
+ virtual bool inactive() const;
+ virtual void unsubscribe();
+ virtual void replace();
+ virtual void publish(const Event&);
+
+ virtual void flush();
+ virtual bool operator==(const Flushable&) const;
+
+private:
+
+ // Immutable
+ TopicLinkPrx _obj;
+ Ice::Int _cost;
+};
+
+} // End namespace IceStorm
+
+#endif
+
diff --git a/cpp/src/IceStorm/OnewayBatchSubscriber.cpp b/cpp/src/IceStorm/OnewayBatchSubscriber.cpp index 137e0c02626..21e866e9f5d 100644 --- a/cpp/src/IceStorm/OnewayBatchSubscriber.cpp +++ b/cpp/src/IceStorm/OnewayBatchSubscriber.cpp @@ -34,7 +34,7 @@ OnewayBatchSubscriber::unsubscribe() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateUnsubscribed; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << "Unsubscribe " << _obj->ice_getIdentity(); @@ -53,7 +53,7 @@ OnewayBatchSubscriber::replace() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateReplaced; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << "Replace " << _obj->ice_getIdentity(); @@ -87,9 +87,9 @@ OnewayBatchSubscriber::flush() // marked invalid by another thread. Don't display a // diagnostic in this case. // - if (_state == StateActive) + if(_state == StateActive) { - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << _obj->ice_getIdentity() << ": flush failed: " << e; @@ -103,7 +103,7 @@ bool OnewayBatchSubscriber::operator==(const Flushable& therhs) const { const OnewayBatchSubscriber* rhs = dynamic_cast<const OnewayBatchSubscriber*>(&therhs); - if (rhs != 0) + if(rhs != 0) { return id() == rhs->id(); } diff --git a/cpp/src/IceStorm/OnewayBatchSubscriber.h b/cpp/src/IceStorm/OnewayBatchSubscriber.h index 4b90d33d1a6..3dda3b00889 100644 --- a/cpp/src/IceStorm/OnewayBatchSubscriber.h +++ b/cpp/src/IceStorm/OnewayBatchSubscriber.h @@ -1,50 +1,50 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ONEWAY_BATCH_SUBSCRIBER_H -#define ONEWAY_BATCH_SUBSCRIBER_H - -#include <IceStorm/OnewaySubscriber.h> -#include <IceStorm/Flushable.h> - -namespace IceStorm -{ - -// -// Forward declarations. -// -class Flusher; -typedef IceUtil::Handle<Flusher> FlusherPtr; - -class OnewayBatchSubscriber : public OnewaySubscriber, public Flushable -{ -public: - - OnewayBatchSubscriber(const TraceLevelsPtr&, const FlusherPtr&, const Ice::ObjectPrx&); - ~OnewayBatchSubscriber(); - - virtual void unsubscribe(); - virtual void replace(); - virtual bool inactive() const; - - virtual void flush(); - - virtual bool operator==(const Flushable&) const; - -private: - - FlusherPtr _flusher; -}; - -typedef IceUtil::Handle<OnewayBatchSubscriber> OnewayBatchSubscriberPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ONEWAY_BATCH_SUBSCRIBER_H
+#define ONEWAY_BATCH_SUBSCRIBER_H
+
+#include <IceStorm/OnewaySubscriber.h>
+#include <IceStorm/Flushable.h>
+
+namespace IceStorm
+{
+
+//
+// Forward declarations.
+//
+class Flusher;
+typedef IceUtil::Handle<Flusher> FlusherPtr;
+
+class OnewayBatchSubscriber : public OnewaySubscriber, public Flushable
+{
+public:
+
+ OnewayBatchSubscriber(const TraceLevelsPtr&, const FlusherPtr&, const Ice::ObjectPrx&);
+ ~OnewayBatchSubscriber();
+
+ virtual void unsubscribe();
+ virtual void replace();
+ virtual bool inactive() const;
+
+ virtual void flush();
+
+ virtual bool operator==(const Flushable&) const;
+
+private:
+
+ FlusherPtr _flusher;
+};
+
+typedef IceUtil::Handle<OnewayBatchSubscriber> OnewayBatchSubscriberPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/OnewaySubscriber.cpp b/cpp/src/IceStorm/OnewaySubscriber.cpp index e3ce184f727..ab6628df709 100644 --- a/cpp/src/IceStorm/OnewaySubscriber.cpp +++ b/cpp/src/IceStorm/OnewaySubscriber.cpp @@ -37,7 +37,7 @@ OnewaySubscriber::unsubscribe() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateUnsubscribed; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << "Unsubscribe " << _obj->ice_getIdentity(); @@ -50,7 +50,7 @@ OnewaySubscriber::replace() IceUtil::Mutex::Lock sync(_stateMutex); _state = StateReplaced; - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << "Replace " << _obj->ice_getIdentity(); @@ -73,9 +73,9 @@ OnewaySubscriber::publish(const Event& event) // marked invalid by another thread. Don't display a // diagnostic in this case. // - if (_state == StateActive) + if(_state == StateActive) { - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << _obj->ice_getIdentity() << ": publish failed: " << e; diff --git a/cpp/src/IceStorm/OnewaySubscriber.h b/cpp/src/IceStorm/OnewaySubscriber.h index 032821f271a..cef8f63993a 100644 --- a/cpp/src/IceStorm/OnewaySubscriber.h +++ b/cpp/src/IceStorm/OnewaySubscriber.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ONEWAY_SUBSCRIBER_H -#define ONEWAY_SUBSCRIBER_H - -#include <IceStorm/Subscriber.h> - -namespace IceStorm -{ - -class OnewaySubscriber : public Subscriber -{ -public: - - OnewaySubscriber(const TraceLevelsPtr&, const Ice::ObjectPrx&); - ~OnewaySubscriber(); - - virtual bool persistent() const; - virtual void unsubscribe(); - virtual void replace(); - virtual void publish(const Event&); - -protected: - - // Immutable - Ice::ObjectPrx _obj; -}; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ONEWAY_SUBSCRIBER_H
+#define ONEWAY_SUBSCRIBER_H
+
+#include <IceStorm/Subscriber.h>
+
+namespace IceStorm
+{
+
+class OnewaySubscriber : public Subscriber
+{
+public:
+
+ OnewaySubscriber(const TraceLevelsPtr&, const Ice::ObjectPrx&);
+ ~OnewaySubscriber();
+
+ virtual bool persistent() const;
+ virtual void unsubscribe();
+ virtual void replace();
+ virtual void publish(const Event&);
+
+protected:
+
+ // Immutable
+ Ice::ObjectPrx _obj;
+};
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp index 506a8549d96..7b94cf7d3ab 100644 --- a/cpp/src/IceStorm/Parser.cpp +++ b/cpp/src/IceStorm/Parser.cpp @@ -57,7 +57,7 @@ Parser::create(const list<string>& args) { try { - for (list<string>::const_iterator i = args.begin(); i != args.end() ; ++i) + for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i) { _admin->create(*i); } @@ -75,7 +75,7 @@ Parser::destroy(const list<string>& args) { try { - for (list<string>::const_iterator i = args.begin(); i != args.end() ; ++i) + for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i) { TopicPrx topic = _admin->retrieve(*i); topic->destroy(); @@ -94,7 +94,7 @@ Parser::link(const list<string>& _args) { list<string> args = _args; - if (args.size() != 3) + if(args.size() != 3) { error("`link' requires exactly three arguments (type `help' for more info)"); return; @@ -148,7 +148,7 @@ Parser::unlink(const list<string>& _args) { list<string> args = _args; - if (args.size() != 2) + if(args.size() != 2) { error("`unlink' requires exactly two arguments (type `help' for more info)"); return; @@ -201,14 +201,14 @@ Parser::dolist(const list<string>& _args) try { - if (args.size() == 0) + if(args.size() == 0) { TopicDict d = _admin->retrieveAll(); - if (!d.empty()) + if(!d.empty()) { - for (TopicDict::iterator i = d.begin(); i != d.end(); ++i) + for(TopicDict::iterator i = d.begin(); i != d.end(); ++i) { - if (i != d.begin()) + if(i != d.begin()) { cout << ", "; } @@ -219,7 +219,7 @@ Parser::dolist(const list<string>& _args) } else { - while (args.size() != 0) + while(args.size() != 0) { string name = args.front(); args.pop_front(); @@ -228,7 +228,7 @@ Parser::dolist(const list<string>& _args) { TopicPrx topic = _admin->retrieve(name); LinkInfoSeq links = topic->getLinkInfoSeq(); - for (LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p) + for(LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p) { cout << "\t" << (*p).name << " with cost " << (*p).cost << endl; } @@ -253,7 +253,7 @@ Parser::graph(const list<string>& _args) { list<string> args = _args; - if (args.size() != 2) + if(args.size() != 2) { error("`graph' requires exactly two arguments (type `help' for more info)"); return; @@ -262,7 +262,7 @@ Parser::graph(const list<string>& _args) string file = args.front(); args.pop_front(); int maxCost = atoi(args.front().c_str()); - if (maxCost == 0) + if(maxCost == 0) { error("`graph': cost must be a positive number"); return; @@ -272,7 +272,7 @@ Parser::graph(const list<string>& _args) try { WeightedGraph graph; - if (!graph.parse(file)) + if(!graph.parse(file)) { cerr << file << ": parse failed" << endl; return; @@ -293,9 +293,9 @@ Parser::graph(const list<string>& _args) TopicDict d = _admin->retrieveAll(); vector<string>::const_iterator p; - for (p = vertices.begin(); p != vertices.end(); ++p) + for(p = vertices.begin(); p != vertices.end(); ++p) { - if (d.find(*p) == d.end()) + if(d.find(*p) == d.end()) { cout << *p << ": referenced topic not found" << endl; return; @@ -308,28 +308,28 @@ Parser::graph(const list<string>& _args) // // Get the edge set for reach vertex. // - for (p = vertices.begin(); p != vertices.end(); ++p) + for(p = vertices.begin(); p != vertices.end(); ++p) { TopicPrx topic = d[*p]; assert(topic); LinkInfoSeq seq = topic->getLinkInfoSeq(); vector<pair<string, int> > edges = graph.getEdgesFor(*p); - for (vector<pair<string, int> >::const_iterator q = edges.begin(); q != edges.end(); ++q) + for(vector<pair<string, int> >::const_iterator q = edges.begin(); q != edges.end(); ++q) { bool link = true; - for (LinkInfoSeq::iterator r = seq.begin(); r != seq.end(); ++r) + for(LinkInfoSeq::iterator r = seq.begin(); r != seq.end(); ++r) { // // Found the link element. // - if ((*r).name == (*q).first) + if((*r).name == (*q).first) { // // If the cost is the same, then there is // nothing to do. // - if ((*r).cost == (*q).second) + if((*r).cost == (*q).second) { link = false; } @@ -341,7 +341,7 @@ Parser::graph(const list<string>& _args) // // Else, need to rebind the link. // - if (link) + if(link) { TopicPrx target = d[(*q).first]; ++links; @@ -352,7 +352,7 @@ Parser::graph(const list<string>& _args) // // The remainder of the links are obsolete. // - for (LinkInfoSeq::const_iterator r = seq.begin(); r != seq.end(); ++r) + for(LinkInfoSeq::const_iterator r = seq.begin(); r != seq.end(); ++r) { ++unlinks; topic->unlink((*r).topic); @@ -386,9 +386,9 @@ Parser::shutdown() void Parser::getInput(char* buf, int& result, int maxSize) { - if (!_commands.empty()) + if(!_commands.empty()) { - if (_commands == ";") + if(_commands == ";") { result = 0; } @@ -402,30 +402,30 @@ Parser::getInput(char* buf, int& result, int maxSize) #endif strncpy(buf, _commands.c_str(), result); _commands.erase(0, result); - if (_commands.empty()) + if(_commands.empty()) { _commands = ";"; } } } - else if (isatty(fileno(yyin))) + else if(isatty(fileno(yyin))) { #ifdef HAVE_READLINE char* line = readline(parser->getPrompt()); - if (!line) + if(!line) { result = 0; } else { - if (*line) + if(*line) { add_history(line); } result = strlen(line) + 1; - if (result > maxSize) + if(result > maxSize) { free(line); error("input line too long"); @@ -444,12 +444,12 @@ Parser::getInput(char* buf, int& result, int maxSize) cout << parser->getPrompt() << flush; string line; - while (true) + while(true) { char c = static_cast<char>(getc(yyin)); - if (c == EOF) + if(c == EOF) { - if (line.size()) + if(line.size()) { line += '\n'; } @@ -458,14 +458,14 @@ Parser::getInput(char* buf, int& result, int maxSize) line += c; - if (c == '\n') + if(c == '\n') { break; } } result = line.length(); - if (result > maxSize) + if(result > maxSize) { error("input line too long"); buf[0] = EOF; @@ -480,7 +480,7 @@ Parser::getInput(char* buf, int& result, int maxSize) } else { - if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + if(((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) { error("input in flex scanner failed"); buf[0] = EOF; @@ -506,7 +506,7 @@ Parser::getPrompt() { assert(_commands.empty() && isatty(fileno(yyin))); - if (_continue) + if(_continue) { _continue = false; return "(cont) "; @@ -524,13 +524,13 @@ Parser::scanPosition(const char* s) string::size_type idx; idx = line.find("line"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx + 4); } idx = line.find_first_not_of(" \t\r#"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); } @@ -538,18 +538,18 @@ Parser::scanPosition(const char* s) _currentLine = atoi(line.c_str()) - 1; idx = line.find_first_of(" \t\r"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); } idx = line.find_first_not_of(" \t\r\""); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); idx = line.find_first_of(" \t\r\""); - if (idx != string::npos) + if(idx != string::npos) { _currentFile = line.substr(0, idx); line.erase(0, idx + 1); @@ -564,7 +564,7 @@ Parser::scanPosition(const char* s) void Parser::error(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } @@ -584,7 +584,7 @@ Parser::error(const string& s) void Parser::warning(const char* s) { - if (_commands.empty() && !isatty(fileno(yyin))) + if(_commands.empty() && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } @@ -620,7 +620,7 @@ Parser::parse(FILE* file, bool debug) nextLine(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } @@ -649,7 +649,7 @@ Parser::parse(const std::string& commands, bool debug) nextLine(); int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } diff --git a/cpp/src/IceStorm/Parser.h b/cpp/src/IceStorm/Parser.h index a60d2866f58..841f8e22d1f 100644 --- a/cpp/src/IceStorm/Parser.h +++ b/cpp/src/IceStorm/Parser.h @@ -1,108 +1,108 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_STORM_PARSER_H -#define ICE_STORM_PARSER_H - -#include <IceUtil/Handle.h> -#include <IceStorm/IceStorm.h> -#include <list> - -#ifdef _WIN32 -# include <io.h> -# define isatty _isatty -# define fileno _fileno -// '_isatty' : inconsistent dll linkage. dllexport assumed. -# pragma warning( disable : 4273 ) -#endif - -// -// Stuff for flex and bison -// - -#define YYSTYPE std::list<std::string> -#define YY_DECL int yylex(YYSTYPE* yylvalp) -YY_DECL; -int yyparse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) yyerror(a) - -namespace IceStorm -{ - -// -// Forward declaration. -// -class Parser; -typedef ::IceUtil::Handle<Parser> ParserPtr; - -class Parser : public ::IceUtil::SimpleShared -{ -public: - - static ParserPtr createParser(const Ice::CommunicatorPtr&, const IceStorm::TopicManagerPrx&); - - void usage(); - - void create(const std::list<std::string>&); - void destroy(const std::list<std::string>&); - void dolist(const std::list<std::string>&); // Don't name list - conflicts with std::list - void link(const std::list<std::string>&); - void unlink(const std::list<std::string>&); - void graph(const std::list<std::string>&); - void shutdown(); - - void getInput(char*, int&, int); - void nextLine(); - void continueLine(); - char* getPrompt(); - void scanPosition(const char*); - - void error(const char*); - void error(const std::string&); - - void warning(const char*); - void warning(const std::string&); - - int parse(FILE*, bool); - int parse(const std::string&, bool); - -private: - - Parser(const Ice::CommunicatorPtr&, const IceStorm::TopicManagerPrx&); - - std::string _commands; - Ice::CommunicatorPtr _communicator; - IceStorm::TopicManagerPrx _admin; - bool _continue; - int _errors; - int _currentLine; - std::string _currentFile; -}; - -extern Parser* parser; // The current parser for bison/flex - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_STORM_PARSER_H
+#define ICE_STORM_PARSER_H
+
+#include <IceUtil/Handle.h>
+#include <IceStorm/IceStorm.h>
+#include <list>
+
+#ifdef _WIN32
+# include <io.h>
+# define isatty _isatty
+# define fileno _fileno
+// '_isatty' : inconsistent dll linkage. dllexport assumed.
+# pragma warning( disable : 4273 )
+#endif
+
+//
+// Stuff for flex and bison
+//
+
+#define YYSTYPE std::list<std::string>
+#define YY_DECL int yylex(YYSTYPE* yylvalp)
+YY_DECL;
+int yyparse();
+
+//
+// I must set the initial stack depth to the maximum stack depth to
+// disable bison stack resizing. The bison stack resizing routines use
+// simple malloc/alloc/memcpy calls, which do not work for the
+// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
+// assignment operator, etc.
+//
+#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum.
+#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
+
+//
+// Newer bison versions allow to disable stack resizing by defining
+// yyoverflow.
+//
+#define yyoverflow(a, b, c, d, e, f) yyerror(a)
+
+namespace IceStorm
+{
+
+//
+// Forward declaration.
+//
+class Parser;
+typedef ::IceUtil::Handle<Parser> ParserPtr;
+
+class Parser : public ::IceUtil::SimpleShared
+{
+public:
+
+ static ParserPtr createParser(const Ice::CommunicatorPtr&, const IceStorm::TopicManagerPrx&);
+
+ void usage();
+
+ void create(const std::list<std::string>&);
+ void destroy(const std::list<std::string>&);
+ void dolist(const std::list<std::string>&); // Don't name list - conflicts with std::list
+ void link(const std::list<std::string>&);
+ void unlink(const std::list<std::string>&);
+ void graph(const std::list<std::string>&);
+ void shutdown();
+
+ void getInput(char*, int&, int);
+ void nextLine();
+ void continueLine();
+ char* getPrompt();
+ void scanPosition(const char*);
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void warning(const char*);
+ void warning(const std::string&);
+
+ int parse(FILE*, bool);
+ int parse(const std::string&, bool);
+
+private:
+
+ Parser(const Ice::CommunicatorPtr&, const IceStorm::TopicManagerPrx&);
+
+ std::string _commands;
+ Ice::CommunicatorPtr _communicator;
+ IceStorm::TopicManagerPrx _admin;
+ bool _continue;
+ int _errors;
+ int _currentLine;
+ std::string _currentFile;
+};
+
+extern Parser* parser; // The current parser for bison/flex
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/Server.cpp b/cpp/src/IceStorm/Server.cpp index cb9565bc813..e9615bebf0a 100644 --- a/cpp/src/IceStorm/Server.cpp +++ b/cpp/src/IceStorm/Server.cpp @@ -71,14 +71,14 @@ IceStorm::Server::usage() int IceStorm::Server::runFreeze(int argc, char* argv[], const Freeze::DBEnvironmentPtr& dbEnv) { - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); return EXIT_SUCCESS; } - else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) + else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; diff --git a/cpp/src/IceStorm/Subscriber.h b/cpp/src/IceStorm/Subscriber.h index 453c8b125b3..5f30a365b89 100644 --- a/cpp/src/IceStorm/Subscriber.h +++ b/cpp/src/IceStorm/Subscriber.h @@ -1,136 +1,136 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SUBSCRIBER_H -#define SUBSCRIBER_H - -#include <IceUtil/Mutex.h> -#include <Ice/Current.h> // For Ice::Context -#include <Ice/Identity.h> - -#include <vector> - -namespace IceStorm -{ - -// -// Forward declarations. -// -class TraceLevels; -typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; - -// -// Note that at present this requires to copy the event which isn't -// nice. If this indeed becomes a bottleneck then either the event can -// carry a reference to the blob, context & op (while event itself -// isn't copied), or the op, blob & context can be passed along as -// arguments (or do copy on write, or some such trick). -// -struct Event -{ - bool forwarded; - int cost; - std::string op; - bool nonmutating; - std::vector< Ice::Byte> data; - Ice::Context context; -}; - -// -// Subscriber interface. -// -class Subscriber : public virtual IceUtil::Shared -{ -public: - - Subscriber(const TraceLevelsPtr& traceLevels, const Ice::Identity&); - ~Subscriber(); - - virtual bool persistent() const = 0; - - // - // Return true if the Subscriber is not active, false otherwise. - // - bool inactive() const; - - // - // Retrieve true if the Subscriber is in the error state, false - // otherwise. - // - bool error() const; - - // - // Retrieve the identity of the Subscriber. - // - Ice::Identity id() const; - - // - // Unsubscribe. Mark the state as Unsubscribed. - // - virtual void unsubscribe() = 0; - - // - // Unsubscribe. Mark the state as Replaced. - // - virtual void replace() = 0; - - // - // Publish the given event. Mark the state as Error in the event of - // a problem. - // - virtual void publish(const Event&) = 0; - -protected: - - // Immutable - TraceLevelsPtr _traceLevels; - - // - // Subscriber state. - // - enum State - { - // - // The Subscriber is active. - // - StateActive, - // - // The Subscriber encountered an error during event - // transmission. - // - StateError, - // - // The Subscriber has been unsubscribed. - // - StateUnsubscribed, - // - // The Subscriber has been replaced. - // - StateReplaced - }; - - IceUtil::Mutex _stateMutex; - State _state; - -private: - - // - // This id is the full id of the subscriber for a particular topic. - // - // Immutable. - // - Ice::Identity _id; -}; - -typedef IceUtil::Handle<Subscriber> SubscriberPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SUBSCRIBER_H
+#define SUBSCRIBER_H
+
+#include <IceUtil/Mutex.h>
+#include <Ice/Current.h> // For Ice::Context
+#include <Ice/Identity.h>
+
+#include <vector>
+
+namespace IceStorm
+{
+
+//
+// Forward declarations.
+//
+class TraceLevels;
+typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
+
+//
+// Note that at present this requires to copy the event which isn't
+// nice. If this indeed becomes a bottleneck then either the event can
+// carry a reference to the blob, context & op (while event itself
+// isn't copied), or the op, blob & context can be passed along as
+// arguments (or do copy on write, or some such trick).
+//
+struct Event
+{
+ bool forwarded;
+ int cost;
+ std::string op;
+ bool nonmutating;
+ std::vector< Ice::Byte> data;
+ Ice::Context context;
+};
+
+//
+// Subscriber interface.
+//
+class Subscriber : public virtual IceUtil::Shared
+{
+public:
+
+ Subscriber(const TraceLevelsPtr& traceLevels, const Ice::Identity&);
+ ~Subscriber();
+
+ virtual bool persistent() const = 0;
+
+ //
+ // Return true if the Subscriber is not active, false otherwise.
+ //
+ bool inactive() const;
+
+ //
+ // Retrieve true if the Subscriber is in the error state, false
+ // otherwise.
+ //
+ bool error() const;
+
+ //
+ // Retrieve the identity of the Subscriber.
+ //
+ Ice::Identity id() const;
+
+ //
+ // Unsubscribe. Mark the state as Unsubscribed.
+ //
+ virtual void unsubscribe() = 0;
+
+ //
+ // Unsubscribe. Mark the state as Replaced.
+ //
+ virtual void replace() = 0;
+
+ //
+ // Publish the given event. Mark the state as Error in the event of
+ // a problem.
+ //
+ virtual void publish(const Event&) = 0;
+
+protected:
+
+ // Immutable
+ TraceLevelsPtr _traceLevels;
+
+ //
+ // Subscriber state.
+ //
+ enum State
+ {
+ //
+ // The Subscriber is active.
+ //
+ StateActive,
+ //
+ // The Subscriber encountered an error during event
+ // transmission.
+ //
+ StateError,
+ //
+ // The Subscriber has been unsubscribed.
+ //
+ StateUnsubscribed,
+ //
+ // The Subscriber has been replaced.
+ //
+ StateReplaced
+ };
+
+ IceUtil::Mutex _stateMutex;
+ State _state;
+
+private:
+
+ //
+ // This id is the full id of the subscriber for a particular topic.
+ //
+ // Immutable.
+ //
+ Ice::Identity _id;
+};
+
+typedef IceUtil::Handle<Subscriber> SubscriberPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/SubscriberFactory.cpp b/cpp/src/IceStorm/SubscriberFactory.cpp index 975936eb52c..b2ffb86a7e4 100644 --- a/cpp/src/IceStorm/SubscriberFactory.cpp +++ b/cpp/src/IceStorm/SubscriberFactory.cpp @@ -35,7 +35,7 @@ SubscriberFactory::createSubscriber(const QoS& qos, const Ice::ObjectPrx& obj) QoS::const_iterator i = qos.find("reliability"); string reliability; - if (i == qos.end()) + if(i == qos.end()) { reliability = "oneway"; } @@ -44,15 +44,15 @@ SubscriberFactory::createSubscriber(const QoS& qos, const Ice::ObjectPrx& obj) reliability = i->second; } - if (reliability == "batch") + if(reliability == "batch") { return new OnewayBatchSubscriber(_traceLevels, _flusher, obj->ice_batchOneway()); } else // reliability == "oneway" { - if (reliability != "oneway") + if(reliability != "oneway") { - if (_traceLevels->subscriber > 0) + if(_traceLevels->subscriber > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberCat); out << reliability <<" mode not understood."; diff --git a/cpp/src/IceStorm/SubscriberFactory.h b/cpp/src/IceStorm/SubscriberFactory.h index 9e6ee95e2af..904f8d35b5f 100644 --- a/cpp/src/IceStorm/SubscriberFactory.h +++ b/cpp/src/IceStorm/SubscriberFactory.h @@ -1,62 +1,62 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SUBSCRIBER_FACTORY_H -#define SUBSCRIBER_FACTORY_H - -#include <IceStorm/IceStormInternal.h> // For QoS, TopicLink - -namespace IceStorm -{ - -// -// Forward declarations. -// -class TraceLevels; -typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; - -class Subscriber; -typedef IceUtil::Handle<Subscriber> SubscriberPtr; - -class Flusher; -typedef IceUtil::Handle<Flusher> FlusherPtr; - -// -// Factory object that knows how to create various type of Subscriber -// objects. -// -class SubscriberFactory : public IceUtil::Shared -{ -public: - - SubscriberFactory(const TraceLevelsPtr&, const FlusherPtr&); - - // - // Create a link subscriber (that is a subscriber that points to - // another topic instance). - // - SubscriberPtr createLinkSubscriber(const TopicLinkPrx&, Ice::Int); - - // - // Create a Subscriber with the given QoS. - // - SubscriberPtr createSubscriber(const QoS&, const Ice::ObjectPrx&); - -private: - - TraceLevelsPtr _traceLevels; - FlusherPtr _flusher; -}; - -typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SUBSCRIBER_FACTORY_H
+#define SUBSCRIBER_FACTORY_H
+
+#include <IceStorm/IceStormInternal.h> // For QoS, TopicLink
+
+namespace IceStorm
+{
+
+//
+// Forward declarations.
+//
+class TraceLevels;
+typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
+
+class Subscriber;
+typedef IceUtil::Handle<Subscriber> SubscriberPtr;
+
+class Flusher;
+typedef IceUtil::Handle<Flusher> FlusherPtr;
+
+//
+// Factory object that knows how to create various type of Subscriber
+// objects.
+//
+class SubscriberFactory : public IceUtil::Shared
+{
+public:
+
+ SubscriberFactory(const TraceLevelsPtr&, const FlusherPtr&);
+
+ //
+ // Create a link subscriber (that is a subscriber that points to
+ // another topic instance).
+ //
+ SubscriberPtr createLinkSubscriber(const TopicLinkPrx&, Ice::Int);
+
+ //
+ // Create a Subscriber with the given QoS.
+ //
+ SubscriberPtr createSubscriber(const QoS&, const Ice::ObjectPrx&);
+
+private:
+
+ TraceLevelsPtr _traceLevels;
+ FlusherPtr _flusher;
+};
+
+typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp index 417ec20520e..e45e45199f3 100644 --- a/cpp/src/IceStorm/TopicI.cpp +++ b/cpp/src/IceStorm/TopicI.cpp @@ -115,9 +115,9 @@ public: // the list of subscribers - it marks the Subscriber as // replaced, and it's removed on the next event publish. // - for (SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) + for(SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) { - if ((*i)->id() == id) + if((*i)->id() == id) { // // This marks the subscriber as invalid. It will be @@ -148,9 +148,9 @@ public: IceUtil::Mutex::Lock sync(_subscribersMutex); - for (SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) + for(SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) { - if ((*i)->id() == id) + if((*i)->id() == id) { // // This marks the subscriber as invalid. It will be @@ -164,7 +164,7 @@ public: // // If the subscriber was not found then display a diagnostic // - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << id << ": not subscribed."; @@ -206,11 +206,11 @@ public: // list. Copy the subscribers in error to the error list. // SubscriberList::iterator p = _subscribers.begin(); - while (p != _subscribers.end()) + while(p != _subscribers.end()) { - if ((*p)->inactive()) + if((*p)->inactive()) { - if ((*p)->error()) + if((*p)->error()) { e.push_back(*p); } @@ -226,14 +226,14 @@ public: } } - if (!e.empty()) + if(!e.empty()) { IceUtil::Mutex::Lock errorSync(_errorMutex); _error.splice(_error.begin(), e); } } - for (SubscriberList::iterator p = copy.begin(); p != copy.end(); ++p) + for(SubscriberList::iterator p = copy.begin(); p != copy.end(); ++p) { (*p)->publish(event); } @@ -285,7 +285,7 @@ PublisherProxyI::ice_invoke(const vector< Ice::Byte>& inParams, vector< Ice::Byt Event event; event.forwarded = false; Ice::Context::const_iterator p = context.find("cost"); - if (p != context.end()) + if(p != context.end()) { event.cost = atoi(p->second.c_str()); } @@ -358,9 +358,9 @@ TopicI::TopicI(const Ice::ObjectAdapterPtr& adapter, const TraceLevelsPtr& trace // // Run through link database re-establishing linked subscribers. // - for (IdentityLinkDict::const_iterator p = _links.begin(); p != _links.end(); ++p) + for(IdentityLinkDict::const_iterator p = _links.begin(); p != _links.end(); ++p) { - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << _name << " relink " << p->first; @@ -398,7 +398,7 @@ TopicI::destroy(const Ice::Current&) { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__); } @@ -412,7 +412,7 @@ TopicI::destroy(const Ice::Current&) id.category = _name; id.name = "publish"; - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << "destroying " << id; @@ -429,7 +429,7 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&) { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__); } @@ -437,7 +437,7 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&) reap(); string name = topic->getName(); - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << _name << " link " << name << " cost " << cost; @@ -472,7 +472,7 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current&) { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__); } @@ -482,9 +482,9 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current&) TopicInternalPrx internal = TopicInternalPrx::checkedCast(topic); Ice::ObjectPrx link = internal->getLinkProxy(); - if (_links.erase(link->ice_getIdentity()) > 0) + if(_links.erase(link->ice_getIdentity()) > 0) { - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << _name << " unlink " << topic->getName(); @@ -493,7 +493,7 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current&) } else { - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << _name << " unlink " << topic->getName() << " failed - not linked"; @@ -506,7 +506,7 @@ TopicI::getLinkInfoSeq(const Ice::Current&) { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__); } @@ -515,7 +515,7 @@ TopicI::getLinkInfoSeq(const Ice::Current&) LinkInfoSeq seq; - for (IdentityLinkDict::const_iterator p = _links.begin(); p != _links.end(); ++p) + for(IdentityLinkDict::const_iterator p = _links.begin(); p != _links.end(); ++p) { LinkInfo info = p->second.info; seq.push_back(info); @@ -543,7 +543,7 @@ TopicI::subscribe(const Ice::ObjectPrx& obj, const QoS& qos) { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__); } @@ -562,7 +562,7 @@ TopicI::unsubscribe(const Ice::ObjectPrx& obj) { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { throw Ice::ObjectNotExistException(__FILE__, __LINE__); } @@ -580,7 +580,7 @@ TopicI::reap() { IceUtil::RecMutex::Lock sync(*this); - if (_destroyed) + if(_destroyed) { return; } @@ -590,15 +590,15 @@ TopicI::reap() // database. // SubscriberList error = _subscribers->clearErrorList(); - for (SubscriberList::iterator p = error.begin(); p != error.end(); ++p) + for(SubscriberList::iterator p = error.begin(); p != error.end(); ++p) { SubscriberPtr subscriber = *p; assert(subscriber->error()); - if (subscriber->persistent()) + if(subscriber->persistent()) { - if (_links.erase(subscriber->id()) > 0) + if(_links.erase(subscriber->id()) > 0) { - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << "reaping " << subscriber->id(); @@ -606,7 +606,7 @@ TopicI::reap() } else { - if (_traceLevels->topic > 0) + if(_traceLevels->topic > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); out << "reaping " << subscriber->id() << " failed - not in database"; diff --git a/cpp/src/IceStorm/TopicI.h b/cpp/src/IceStorm/TopicI.h index 67153cfda6c..f3f1a79ffcf 100644 --- a/cpp/src/IceStorm/TopicI.h +++ b/cpp/src/IceStorm/TopicI.h @@ -1,92 +1,92 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TOPIC_I_H -#define TOPIC_I_H - -#include <IceUtil/RecMutex.h> -#include <IceStorm/IceStormInternal.h> -#include <IceStorm/IdentityLinkDict.h> -#include <IceStorm/SubscriberFactory.h> - -namespace IceStorm -{ - -// -// Forward declarations. -// -class TopicSubscribers; -typedef IceUtil::Handle<TopicSubscribers> TopicSubscribersPtr; - -class TraceLevels; -typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; - -class SubscriberFactory; -typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr; - -// -// TopicInternal implementation. -// -class TopicI : public TopicInternal, public IceUtil::RecMutex -{ -public: - - TopicI(const Ice::ObjectAdapterPtr&, const TraceLevelsPtr&, const std::string&, const SubscriberFactoryPtr&, - const Freeze::DBPtr&); - ~TopicI(); - - virtual std::string getName(const Ice::Current&); - virtual Ice::ObjectPrx getPublisher(const Ice::Current&); - virtual void destroy(const Ice::Current&); - virtual void link(const TopicPrx&, Ice::Int, const Ice::Current&); - virtual void unlink(const TopicPrx&, const Ice::Current&); - virtual LinkInfoSeq getLinkInfoSeq(const Ice::Current&); - - virtual TopicLinkPrx getLinkProxy(const Ice::Current&); - - // Internal methods - bool destroyed() const; - void subscribe(const Ice::ObjectPrx&, const QoS&); - void unsubscribe(const Ice::ObjectPrx&); - - void reap(); - -private: - - // - // Immutable members. - // - Ice::ObjectAdapterPtr _adapter; - TraceLevelsPtr _traceLevels; - std::string _name; // The topic name - SubscriberFactoryPtr _factory; - - Ice::ObjectPtr _publisher; // Publisher & associated proxy - Ice::ObjectPrx _publisherPrx; - - Ice::ObjectPtr _link; // TopicLink & associated proxy - TopicLinkPrx _linkPrx; - - // - // Mutable members. Protected by *this - // - bool _destroyed; // Has this Topic been destroyed? - - TopicSubscribersPtr _subscribers; // Set of Subscribers - - IdentityLinkDict _links; // The database of Topic links - Freeze::DBPtr _linksDb; -}; - -typedef IceUtil::Handle<TopicI> TopicIPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TOPIC_I_H
+#define TOPIC_I_H
+
+#include <IceUtil/RecMutex.h>
+#include <IceStorm/IceStormInternal.h>
+#include <IceStorm/IdentityLinkDict.h>
+#include <IceStorm/SubscriberFactory.h>
+
+namespace IceStorm
+{
+
+//
+// Forward declarations.
+//
+class TopicSubscribers;
+typedef IceUtil::Handle<TopicSubscribers> TopicSubscribersPtr;
+
+class TraceLevels;
+typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
+
+class SubscriberFactory;
+typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr;
+
+//
+// TopicInternal implementation.
+//
+class TopicI : public TopicInternal, public IceUtil::RecMutex
+{
+public:
+
+ TopicI(const Ice::ObjectAdapterPtr&, const TraceLevelsPtr&, const std::string&, const SubscriberFactoryPtr&,
+ const Freeze::DBPtr&);
+ ~TopicI();
+
+ virtual std::string getName(const Ice::Current&);
+ virtual Ice::ObjectPrx getPublisher(const Ice::Current&);
+ virtual void destroy(const Ice::Current&);
+ virtual void link(const TopicPrx&, Ice::Int, const Ice::Current&);
+ virtual void unlink(const TopicPrx&, const Ice::Current&);
+ virtual LinkInfoSeq getLinkInfoSeq(const Ice::Current&);
+
+ virtual TopicLinkPrx getLinkProxy(const Ice::Current&);
+
+ // Internal methods
+ bool destroyed() const;
+ void subscribe(const Ice::ObjectPrx&, const QoS&);
+ void unsubscribe(const Ice::ObjectPrx&);
+
+ void reap();
+
+private:
+
+ //
+ // Immutable members.
+ //
+ Ice::ObjectAdapterPtr _adapter;
+ TraceLevelsPtr _traceLevels;
+ std::string _name; // The topic name
+ SubscriberFactoryPtr _factory;
+
+ Ice::ObjectPtr _publisher; // Publisher & associated proxy
+ Ice::ObjectPrx _publisherPrx;
+
+ Ice::ObjectPtr _link; // TopicLink & associated proxy
+ TopicLinkPrx _linkPrx;
+
+ //
+ // Mutable members. Protected by *this
+ //
+ bool _destroyed; // Has this Topic been destroyed?
+
+ TopicSubscribersPtr _subscribers; // Set of Subscribers
+
+ IdentityLinkDict _links; // The database of Topic links
+ Freeze::DBPtr _linksDb;
+};
+
+typedef IceUtil::Handle<TopicI> TopicIPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/TopicManagerI.cpp b/cpp/src/IceStorm/TopicManagerI.cpp index 179267e7483..518a1975909 100644 --- a/cpp/src/IceStorm/TopicManagerI.cpp +++ b/cpp/src/IceStorm/TopicManagerI.cpp @@ -38,7 +38,7 @@ TopicManagerI::TopicManagerI(const Ice::CommunicatorPtr& communicator, const Ice // should only occur upon a crash. // StringBoolDict::iterator p = _topics.begin(); - while (p != _topics.end()) + while(p != _topics.end()) { assert(_topicIMap.find(p->first) == _topicIMap.end()); try @@ -48,7 +48,7 @@ TopicManagerI::TopicManagerI(const Ice::CommunicatorPtr& communicator, const Ice } catch(const Freeze::DBNotFoundException& ex) { - if (_traceLevels->topicMgr > 0) + if(_traceLevels->topicMgr > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicMgrCat); out << ex; @@ -72,7 +72,7 @@ TopicManagerI::create(const string& name, const Ice::Current&) reap(); - if (_topicIMap.find(name) != _topicIMap.end()) + if(_topicIMap.find(name) != _topicIMap.end()) { TopicExists ex; ex.name = name; @@ -97,7 +97,7 @@ TopicManagerI::retrieve(const string& name, const Ice::Current&) reap(); - if (_topicIMap.find(name) != _topicIMap.end()) + if(_topicIMap.find(name) != _topicIMap.end()) { Ice::Identity id; id.name = name; @@ -140,16 +140,16 @@ TopicManagerI::subscribe(const QoS& qos, const Ice::ObjectPrx& subscriber, const IceUtil::Mutex::Lock sync(*this); Ice::Identity ident = subscriber->ice_getIdentity(); - if (_traceLevels->topicMgr > 0) + if(_traceLevels->topicMgr > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicMgrCat); out << "Subscribe: " << Ice::identityToString(ident); - if (_traceLevels->topicMgr > 1) + if(_traceLevels->topicMgr > 1) { out << " QoS: "; - for (QoS::const_iterator qi = qos.begin(); qi != qos.end() ; ++qi) + for(QoS::const_iterator qi = qos.begin(); qi != qos.end() ; ++qi) { - if (qi != qos.begin()) + if(qi != qos.begin()) { out << ','; } @@ -163,7 +163,7 @@ TopicManagerI::subscribe(const QoS& qos, const Ice::ObjectPrx& subscriber, const // channel. // TopicIMap::iterator elem = _topicIMap.find(ident.category); - if (elem == _topicIMap.end()) + if(elem == _topicIMap.end()) { NoSuchTopic ex; ex.name = ident.category; @@ -183,7 +183,7 @@ TopicManagerI::unsubscribe(const Ice::ObjectPrx& subscriber, const Ice::Current& Ice::Identity ident = subscriber->ice_getIdentity(); - if (_traceLevels->topicMgr > 0) + if(_traceLevels->topicMgr > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicMgrCat); @@ -192,7 +192,7 @@ TopicManagerI::unsubscribe(const Ice::ObjectPrx& subscriber, const Ice::Current& TopicIMap::iterator elem = _topicIMap.find(ident.category); - if (elem != _topicIMap.end()) + if(elem != _topicIMap.end()) { elem->second->unsubscribe(subscriber); } @@ -214,11 +214,11 @@ TopicManagerI::reap() // IceUtil::Mutex::Lock sync(*this); // TopicIMap::iterator i = _topicIMap.begin(); - while (i != _topicIMap.end()) + while(i != _topicIMap.end()) { - if (i->second->destroyed()) + if(i->second->destroyed()) { - if (_traceLevels->topicMgr > 0) + if(_traceLevels->topicMgr > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicMgrCat); out << "Reaping " << i->first; @@ -236,7 +236,7 @@ TopicManagerI::reap() void TopicManagerI::installTopic(const std::string& message, const std::string& name, bool create) { - if (_traceLevels->topicMgr > 0) + if(_traceLevels->topicMgr > 0) { Ice::Trace out(_traceLevels->logger, _traceLevels->topicMgrCat); out << message << ' ' << name; diff --git a/cpp/src/IceStorm/TopicManagerI.h b/cpp/src/IceStorm/TopicManagerI.h index 0aa5b91f784..993cf1a5d0a 100644 --- a/cpp/src/IceStorm/TopicManagerI.h +++ b/cpp/src/IceStorm/TopicManagerI.h @@ -1,78 +1,78 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TOPIC_MANAGER_I_H -#define TOPIC_MANAGER_I_H - -#include <IceStorm/IceStorm.h> -#include <IceStorm/StringBoolDict.h> - -namespace IceStorm -{ - -// -// Forward declarations. -// -class TopicI; -typedef IceUtil::Handle<TopicI> TopicIPtr; - -class TraceLevels; -typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; - -class Flusher; -typedef IceUtil::Handle<Flusher> FlusherPtr; - -class SubscriberFactory; -typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr; - -// -// Map of TopicImplementation objects. -// -typedef std::map<std::string, TopicIPtr> TopicIMap; - -// -// TopicManager implementation. -// -class TopicManagerI : public TopicManager, public IceUtil::Mutex -{ -public: - - TopicManagerI(const Ice::CommunicatorPtr&, const Ice::ObjectAdapterPtr&, const TraceLevelsPtr&, - const Freeze::DBEnvironmentPtr&, const Freeze::DBPtr&); - ~TopicManagerI(); - - virtual TopicPrx create(const std::string&, const Ice::Current&); - virtual TopicPrx retrieve(const std::string&, const Ice::Current&); - virtual TopicDict retrieveAll(const Ice::Current&); - virtual void subscribe(const QoS&, const Ice::ObjectPrx&, const Ice::Current&); - virtual void unsubscribe(const Ice::ObjectPrx&, const Ice::Current&); - virtual void shutdown(const Ice::Current&); - - void reap(); - -private: - - void installTopic(const std::string&, const std::string&, bool); - - Ice::CommunicatorPtr _communicator; - Ice::ObjectAdapterPtr _adapter; - TraceLevelsPtr _traceLevels; - TopicIMap _topicIMap; - FlusherPtr _flusher; - SubscriberFactoryPtr _factory; - Freeze::DBEnvironmentPtr _dbEnv; - StringBoolDict _topics; -}; - -typedef IceUtil::Handle<TopicManagerI> TopicManagerIPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TOPIC_MANAGER_I_H
+#define TOPIC_MANAGER_I_H
+
+#include <IceStorm/IceStorm.h>
+#include <IceStorm/StringBoolDict.h>
+
+namespace IceStorm
+{
+
+//
+// Forward declarations.
+//
+class TopicI;
+typedef IceUtil::Handle<TopicI> TopicIPtr;
+
+class TraceLevels;
+typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
+
+class Flusher;
+typedef IceUtil::Handle<Flusher> FlusherPtr;
+
+class SubscriberFactory;
+typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr;
+
+//
+// Map of TopicImplementation objects.
+//
+typedef std::map<std::string, TopicIPtr> TopicIMap;
+
+//
+// TopicManager implementation.
+//
+class TopicManagerI : public TopicManager, public IceUtil::Mutex
+{
+public:
+
+ TopicManagerI(const Ice::CommunicatorPtr&, const Ice::ObjectAdapterPtr&, const TraceLevelsPtr&,
+ const Freeze::DBEnvironmentPtr&, const Freeze::DBPtr&);
+ ~TopicManagerI();
+
+ virtual TopicPrx create(const std::string&, const Ice::Current&);
+ virtual TopicPrx retrieve(const std::string&, const Ice::Current&);
+ virtual TopicDict retrieveAll(const Ice::Current&);
+ virtual void subscribe(const QoS&, const Ice::ObjectPrx&, const Ice::Current&);
+ virtual void unsubscribe(const Ice::ObjectPrx&, const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+ void reap();
+
+private:
+
+ void installTopic(const std::string&, const std::string&, bool);
+
+ Ice::CommunicatorPtr _communicator;
+ Ice::ObjectAdapterPtr _adapter;
+ TraceLevelsPtr _traceLevels;
+ TopicIMap _topicIMap;
+ FlusherPtr _flusher;
+ SubscriberFactoryPtr _factory;
+ Freeze::DBEnvironmentPtr _dbEnv;
+ StringBoolDict _topics;
+};
+
+typedef IceUtil::Handle<TopicManagerI> TopicManagerIPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/TraceLevels.h b/cpp/src/IceStorm/TraceLevels.h index fbc08dc4d6f..e971dd28169 100644 --- a/cpp/src/IceStorm/TraceLevels.h +++ b/cpp/src/IceStorm/TraceLevels.h @@ -1,47 +1,47 @@ -// ********************************************************************** -// -// Copyright (c) 2002 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef ICE_STORM_TRACE_LEVELS_H -#define ICE_STORM_TRACE_LEVELS_H - -#include <IceUtil/Shared.h> -#include <Ice/PropertiesF.h> -#include <Ice/LoggerF.h> - -namespace IceStorm -{ - -class TraceLevels : public ::IceUtil::Shared -{ -public: - - TraceLevels(const ::Ice::PropertiesPtr&, const Ice::LoggerPtr&); - virtual ~TraceLevels(); - - const int topicMgr; - const char* topicMgrCat; - - const int topic; - const char* topicCat; - - const int flush; - const char* flushCat; - - const int subscriber; - const char* subscriberCat; - - const Ice::LoggerPtr logger; -}; - -typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_STORM_TRACE_LEVELS_H
+#define ICE_STORM_TRACE_LEVELS_H
+
+#include <IceUtil/Shared.h>
+#include <Ice/PropertiesF.h>
+#include <Ice/LoggerF.h>
+
+namespace IceStorm
+{
+
+class TraceLevels : public ::IceUtil::Shared
+{
+public:
+
+ TraceLevels(const ::Ice::PropertiesPtr&, const Ice::LoggerPtr&);
+ virtual ~TraceLevels();
+
+ const int topicMgr;
+ const char* topicMgrCat;
+
+ const int topic;
+ const char* topicCat;
+
+ const int flush;
+ const char* flushCat;
+
+ const int subscriber;
+ const char* subscriberCat;
+
+ const Ice::LoggerPtr logger;
+};
+
+typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/WeightedGraph.cpp b/cpp/src/IceStorm/WeightedGraph.cpp index 864e30f35be..f856f3aa465 100644 --- a/cpp/src/IceStorm/WeightedGraph.cpp +++ b/cpp/src/IceStorm/WeightedGraph.cpp @@ -110,12 +110,12 @@ SAXGraphHandler::startElement(const XMLCh *const name, AttributeList &attrs) try { - if (str == "vertex") + if(str == "vertex") { XMLCh* n = XMLString::transcode("name"); const XMLCh* value = attrs.getValue(n); delete[] n; - if (value == 0) + if(value == 0) { WeightedGraphParseException ex; ex.reason = "<vertex> name attribute missing"; @@ -126,12 +126,12 @@ SAXGraphHandler::startElement(const XMLCh *const name, AttributeList &attrs) _graph.addVertex(vstr); } - else if (str == "edge") + else if(str == "edge") { XMLCh* n = XMLString::transcode("source"); const XMLCh* value = attrs.getValue(n); delete[] n; - if (value == 0) + if(value == 0) { WeightedGraphParseException ex; ex.reason = "<edge> source attribute missing"; @@ -143,7 +143,7 @@ SAXGraphHandler::startElement(const XMLCh *const name, AttributeList &attrs) n = XMLString::transcode("target"); value = attrs.getValue(n); delete[] n; - if (value == 0) + if(value == 0) { WeightedGraphParseException ex; ex.reason = "<edge> target attribute missing"; @@ -156,7 +156,7 @@ SAXGraphHandler::startElement(const XMLCh *const name, AttributeList &attrs) delete[] n; int cost = 0; - if (value != 0) + if(value != 0) { string cstr = toString(value); cost = atoi(cstr.c_str()); @@ -224,9 +224,9 @@ WeightedGraph::parse(const string& xmlFile) void WeightedGraph::dump(ostream& os) { - for (unsigned int i = 0 ; i < _vertices.size(); ++i) + for(unsigned int i = 0 ; i < _vertices.size(); ++i) { - for (unsigned int j = 0; j < _vertices.size(); ++j) + for(unsigned int j = 0; j < _vertices.size(); ++j) { os << _edges[i*_vertices.size() + j] << " "; } @@ -253,12 +253,12 @@ WeightedGraph::getEdgesFor(const std::string& vertex) const vector<pair<string, int> > edges; map<std::string, int>::const_iterator p = _vlookup.find(vertex); - if (p != _vlookup.end()) + if(p != _vlookup.end()) { int row = p->second * _vertices.size(); - for (unsigned int i = row; i < row + _vertices.size(); ++i) + for(unsigned int i = row; i < row + _vertices.size(); ++i) { - if (_edges[i] != -1) + if(_edges[i] != -1) { edges.push_back(make_pair(_vertices[i-row], _edges[i])); } @@ -281,7 +281,7 @@ WeightedGraph::compute(vector<int>& newEdges, int max) // For each vertex calculate the cost for all reachable vertexes // within the given max cost. // - for (unsigned int i = 0; i < _vertices.size(); ++i) + for(unsigned int i = 0; i < _vertices.size(); ++i) { // // List of <vertex-index,cost> pairs. @@ -294,15 +294,15 @@ WeightedGraph::compute(vector<int>& newEdges, int max) // Add each vertex-index/cost pair to the new adjacency // matrix. // - for (list<pair<unsigned int, int> >::iterator p = visited.begin(); p != visited.end(); ++p) + for(list<pair<unsigned int, int> >::iterator p = visited.begin(); p != visited.end(); ++p) { // // Ignore loops. // - if ((*p).first != i) + if((*p).first != i) { newEdges[i*_vertices.size() + (*p).first] = (*p).second; - if (_reflective) + if(_reflective) { newEdges[(*p).first*_vertices.size() + i] = (*p).second; } @@ -318,11 +318,11 @@ WeightedGraph::visit(unsigned int vertex, int cost, list<pair<unsigned int, int> // Is the given vertex already in the visited list? If so, then // check that is the cost is minimal cost and replace if not. // - for ( list<pair<unsigned int, int> >::iterator p = visited.begin(); p != visited.end(); ++p) + for( list<pair<unsigned int, int> >::iterator p = visited.begin(); p != visited.end(); ++p) { - if (p->first == vertex) + if(p->first == vertex) { - if (p->second > cost) + if(p->second > cost) { p->second = cost; } @@ -340,11 +340,11 @@ WeightedGraph::visit(unsigned int vertex, int cost, list<pair<unsigned int, int> // adjacency matrix). // int row = vertex * _vertices.size(); - for (unsigned int i = row ; i < row + _vertices.size() ; ++i) + for(unsigned int i = row ; i < row + _vertices.size() ; ++i) { - if (_edges[i] != -1) + if(_edges[i] != -1) { - if (cost + _edges[i] <= max) + if(cost + _edges[i] <= max) { visit(i - row, cost + _edges[i], visited, max); } @@ -364,20 +364,20 @@ WeightedGraph::addEdge(const string& from, const string& to, int cost) // // Loops are not permitted. // - if (from == to) + if(from == to) { WeightedGraphParseException ex; ex.reason = "loops are not permitted"; throw ex; } - if (_edges.size() == 0) + if(_edges.size() == 0) { // // Prepare the edge map // _edges.resize(_vertices.size()*_vertices.size(), -1); - for (unsigned int i = 0; i < _vertices.size(); ++i) + for(unsigned int i = 0; i < _vertices.size(); ++i) { _vlookup.insert(make_pair(_vertices[i], i)); } @@ -387,7 +387,7 @@ WeightedGraph::addEdge(const string& from, const string& to, int cost) // Location of from and to. // map<string, int>::iterator p = _vlookup.find(from); - if (p == _vlookup.end()) + if(p == _vlookup.end()) { WeightedGraphParseException ex; ex.reason = "<edge> vertex " + from + " not found"; @@ -396,7 +396,7 @@ WeightedGraph::addEdge(const string& from, const string& to, int cost) int fidx = p->second; p = _vlookup.find(to); - if (p == _vlookup.end()) + if(p == _vlookup.end()) { WeightedGraphParseException ex; ex.reason = "<edge> vertex " + to + " not found"; @@ -408,7 +408,7 @@ WeightedGraph::addEdge(const string& from, const string& to, int cost) // Fill in from, to - to,from // _edges[fidx*_vertices.size() + tidx] = cost; - if (_reflective) + if(_reflective) { _edges[tidx*_vertices.size() + fidx] = cost; } diff --git a/cpp/src/IceStorm/WeightedGraph.h b/cpp/src/IceStorm/WeightedGraph.h index edbaa55a265..c0465ebd7f3 100644 --- a/cpp/src/IceStorm/WeightedGraph.h +++ b/cpp/src/IceStorm/WeightedGraph.h @@ -1,116 +1,116 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef WEIGHTED_GRAPH_H -#define WEIGHTED_GRAPH_H - -#include <IceUtil/Config.h> -#include <vector> -#include <list> -#include <map> - -namespace IceStorm -{ - -// -// Forward declaration. -// -class SAXGraphHandler; - -// -// A weighted graph. This class uses internally a vertex, adjacency -// matrix representation. Each vertex has a name. The [i,j] of the -// adjacency graph represents the the edge from _vertices[i] to -// _vertices[j]. -// -class WeightedGraph -{ -public: - - WeightedGraph(bool = false); - ~WeightedGraph(); - - // - // Parse the graph from the given XML file. Returns false in event - // of a parse error. - // - bool parse(const std::string&); - - // - // Compute a new adjacency matrix with the given cost. - // - void compute(std::vector<int>&, int); - - // - // Render the edge table in ASCII format. - // - void dump(std::ostream&); - - // - // Swap the adjacency matrix. This could be actual swap. - // - void swap(const std::vector<int>&); - - // - // Get all the vertices. - // - std::vector<std::string> getVertices() const; - - // - // Get the set of edges for a vertex. The return data is the name - // of the second vertex, and the cost. - // - std::vector<std::pair<std::string, int> > getEdgesFor(const std::string&) const; - -private: - - // - // Recursive function used in computation of new edge set. - // - void visit(unsigned int, int, std::list<std::pair<unsigned int, int> >&, int); - - // - // Callbacks from parsing routines - // - void addVertex(const std::string&); - void addEdge(const std::string&, const std::string&, int); - - void error(); - - // - // List of vertices. - // - std::vector<std::string> _vertices; - - // - // Lookup table - maps from vertex name to vertex index. - // - std::map<std::string, int> _vlookup; - - // - // The adjacency matrix. -1 indicates no edge, otherwise the value - // is the cost. - // - std::vector<int> _edges; - - // - // Is the graph reflective? That is if there is edge (v1, v2, - // cost) then there is (v2, v1, cost). - // - bool _reflective; - - int _error; - - friend class SAXGraphHandler; -}; - -} // End namespace IceStorm - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef WEIGHTED_GRAPH_H
+#define WEIGHTED_GRAPH_H
+
+#include <IceUtil/Config.h>
+#include <vector>
+#include <list>
+#include <map>
+
+namespace IceStorm
+{
+
+//
+// Forward declaration.
+//
+class SAXGraphHandler;
+
+//
+// A weighted graph. This class uses internally a vertex, adjacency
+// matrix representation. Each vertex has a name. The [i,j] of the
+// adjacency graph represents the the edge from _vertices[i] to
+// _vertices[j].
+//
+class WeightedGraph
+{
+public:
+
+ WeightedGraph(bool = false);
+ ~WeightedGraph();
+
+ //
+ // Parse the graph from the given XML file. Returns false in event
+ // of a parse error.
+ //
+ bool parse(const std::string&);
+
+ //
+ // Compute a new adjacency matrix with the given cost.
+ //
+ void compute(std::vector<int>&, int);
+
+ //
+ // Render the edge table in ASCII format.
+ //
+ void dump(std::ostream&);
+
+ //
+ // Swap the adjacency matrix. This could be actual swap.
+ //
+ void swap(const std::vector<int>&);
+
+ //
+ // Get all the vertices.
+ //
+ std::vector<std::string> getVertices() const;
+
+ //
+ // Get the set of edges for a vertex. The return data is the name
+ // of the second vertex, and the cost.
+ //
+ std::vector<std::pair<std::string, int> > getEdgesFor(const std::string&) const;
+
+private:
+
+ //
+ // Recursive function used in computation of new edge set.
+ //
+ void visit(unsigned int, int, std::list<std::pair<unsigned int, int> >&, int);
+
+ //
+ // Callbacks from parsing routines
+ //
+ void addVertex(const std::string&);
+ void addEdge(const std::string&, const std::string&, int);
+
+ void error();
+
+ //
+ // List of vertices.
+ //
+ std::vector<std::string> _vertices;
+
+ //
+ // Lookup table - maps from vertex name to vertex index.
+ //
+ std::map<std::string, int> _vlookup;
+
+ //
+ // The adjacency matrix. -1 indicates no edge, otherwise the value
+ // is the cost.
+ //
+ std::vector<int> _edges;
+
+ //
+ // Is the graph reflective? That is if there is edge (v1, v2,
+ // cost) then there is (v2, v1, cost).
+ //
+ bool _reflective;
+
+ int _error;
+
+ friend class SAXGraphHandler;
+};
+
+} // End namespace IceStorm
+
+#endif
diff --git a/cpp/src/IceStorm/dummyinclude/unistd.h b/cpp/src/IceStorm/dummyinclude/unistd.h index 92d53d10b9b..a5868056a35 100644 --- a/cpp/src/IceStorm/dummyinclude/unistd.h +++ b/cpp/src/IceStorm/dummyinclude/unistd.h @@ -1,4 +1,4 @@ -// -// Files generated by flex need unistd.h, which is not available on -// Windows. Thus this dummy file. -// +//
+// Files generated by flex need unistd.h, which is not available on
+// Windows. Thus this dummy file.
+//
diff --git a/cpp/src/IceUtil/Base64.cpp b/cpp/src/IceUtil/Base64.cpp index 5cd6fe44af1..eae4ca9a94f 100644 --- a/cpp/src/IceUtil/Base64.cpp +++ b/cpp/src/IceUtil/Base64.cpp @@ -18,7 +18,7 @@ IceUtil::Base64::encode(const ByteSeq& plainSeq) { string retval; - if (plainSeq.size() == 0) + if(plainSeq.size() == 0) { return retval; } @@ -38,18 +38,18 @@ IceUtil::Base64::encode(const ByteSeq& plainSeq) unsigned char by6 = 0; unsigned char by7 = 0; - for (unsigned long i = 0; i < plainSeq.size(); i += 3) + for(unsigned long i = 0; i < plainSeq.size(); i += 3) { by1 = plainSeq[i]; by2 = 0; by3 = 0; - if ((i + 1) < plainSeq.size()) + if((i + 1) < plainSeq.size()) { by2 = plainSeq[i+1]; } - if ((i + 2) < plainSeq.size()) + if((i + 2) < plainSeq.size()) { by3 = plainSeq[i+2]; } @@ -62,7 +62,7 @@ IceUtil::Base64::encode(const ByteSeq& plainSeq) retval += encode(by4); retval += encode(by5); - if ((i + 1) < plainSeq.size()) + if((i + 1) < plainSeq.size()) { retval += encode(by6); } @@ -71,7 +71,7 @@ IceUtil::Base64::encode(const ByteSeq& plainSeq) retval += "="; } - if ((i + 2) < plainSeq.size()) + if((i + 2) < plainSeq.size()) { retval += encode(by7); } @@ -85,7 +85,7 @@ IceUtil::Base64::encode(const ByteSeq& plainSeq) outString.reserve(totalBytes); string::iterator iter = retval.begin(); - while ((retval.end() - iter) > 76) + while((retval.end() - iter) > 76) { copy(iter, iter+76, back_inserter(outString)); outString += "\r\n"; @@ -104,9 +104,9 @@ IceUtil::Base64::decode(const string& str) newStr.reserve(str.length()); - for (unsigned long j = 0; j < str.length(); j++) + for(unsigned long j = 0; j < str.length(); j++) { - if (isBase64(str[j])) + if(isBase64(str[j])) { newStr += str[j]; } @@ -114,7 +114,7 @@ IceUtil::Base64::decode(const string& str) ByteSeq retval; - if (newStr.length() == 0) + if(newStr.length() == 0) { return retval; } @@ -136,7 +136,7 @@ IceUtil::Base64::decode(const string& str) char c1, c2, c3, c4; - for (unsigned long i = 0; i < newStr.length(); i += 4) + for(unsigned long i = 0; i < newStr.length(); i += 4) { c1 = 'A'; c2 = 'A'; @@ -145,17 +145,17 @@ IceUtil::Base64::decode(const string& str) c1 = newStr[i]; - if ((i + 1) < newStr.length()) + if((i + 1) < newStr.length()) { c2 = newStr[i + 1]; } - if ((i + 2) < newStr.length()) + if((i + 2) < newStr.length()) { c3 = newStr[i + 2]; } - if ((i + 3) < newStr.length()) + if((i + 3) < newStr.length()) { c4 = newStr[i + 3]; } @@ -167,12 +167,12 @@ IceUtil::Base64::decode(const string& str) retval.push_back((by1 << 2) | (by2 >> 4)); - if (c3 != '=') + if(c3 != '=') { retval.push_back(((by2 & 0xf) << 4) | (by3 >> 2)); } - if (c4 != '=') + if(c4 != '=') { retval.push_back(((by3 & 0x3) << 6) | by4); } @@ -184,22 +184,22 @@ IceUtil::Base64::decode(const string& str) char IceUtil::Base64::encode(unsigned char uc) { - if (uc < 26) + if(uc < 26) { return 'A' + uc; } - if (uc < 52) + if(uc < 52) { return 'a' + (uc - 26); } - if (uc < 62) + if(uc < 62) { return '0' + (uc - 52); } - if (uc == 62) + if(uc == 62) { return '+'; } @@ -210,22 +210,22 @@ IceUtil::Base64::encode(unsigned char uc) unsigned char IceUtil::Base64::decode(char c) { - if (c >= 'A' && c <= 'Z') + if(c >= 'A' && c <= 'Z') { return c - 'A'; } - if (c >= 'a' && c <= 'z') + if(c >= 'a' && c <= 'z') { return c - 'a' + 26; } - if (c >= '0' && c <= '9') + if(c >= '0' && c <= '9') { return c - '0' + 52; } - if (c == '+') + if(c == '+') { return 62; } @@ -237,32 +237,32 @@ IceUtil::Base64::decode(char c) bool IceUtil::Base64::isBase64(char c) { - if (c >= 'A' && c <= 'Z') + if(c >= 'A' && c <= 'Z') { return true; } - if (c >= 'a' && c <= 'z') + if(c >= 'a' && c <= 'z') { return true; } - if (c >= '0' && c <= '9') + if(c >= '0' && c <= '9') { return true; } - if (c == '+') + if(c == '+') { return true; } - if (c == '/') + if(c == '/') { return true; } - if (c == '=') + if(c == '=') { return true; } diff --git a/cpp/src/IceUtil/Cond.cpp b/cpp/src/IceUtil/Cond.cpp index 867d153224c..c26e0122661 100644 --- a/cpp/src/IceUtil/Cond.cpp +++ b/cpp/src/IceUtil/Cond.cpp @@ -19,7 +19,7 @@ IceUtil::Semaphore::Semaphore(long initial) { _sem = CreateSemaphore(0, initial, 0x7fffffff, 0); - if (_sem == INVALID_HANDLE_VALUE) + if(_sem == INVALID_HANDLE_VALUE) { throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); } @@ -34,7 +34,7 @@ void IceUtil::Semaphore::wait() const { int rc = WaitForSingleObject(_sem, INFINITE); - if (rc != WAIT_OBJECT_0) + if(rc != WAIT_OBJECT_0) { throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); } @@ -47,7 +47,7 @@ IceUtil::Semaphore::timedWait(const Time& timeout) const long msec = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); int rc = WaitForSingleObject(_sem, msec); - if (rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0) + if(rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0) { throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); } @@ -58,7 +58,7 @@ void IceUtil::Semaphore::post(int count) const { int rc = ReleaseSemaphore(_sem, count, 0); - if (rc == 0) + if(rc == 0) { throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); } @@ -97,13 +97,13 @@ IceUtil::Cond::wake(bool broadcast) _gate.wait(); _internal.lock(); - if (_unblocked != 0) + if(_unblocked != 0) { _blocked -= _unblocked; _unblocked = 0; } - if (_blocked > 0) + if(_blocked > 0) { // // Unblock some number of waiters. @@ -136,17 +136,17 @@ IceUtil::Cond::postWait(bool timedOut) const _internal.lock(); _unblocked++; - if (_toUnblock != 0) + if(_toUnblock != 0) { bool last = --_toUnblock == 0; _internal.unlock(); - if (timedOut) + if(timedOut) { _queue.wait(); } - if (last) + if(last) { _gate.post(); } @@ -197,7 +197,7 @@ IceUtil::Cond::timedDowait(const Time& timeout) const IceUtil::Cond::Cond() { int rc = pthread_cond_init(&_cond, 0); - if (rc != 0) + if(rc != 0) { throw SyscallException(strerror(rc), __FILE__, __LINE__); } @@ -214,7 +214,7 @@ void IceUtil::Cond::signal() { int rc = pthread_cond_signal(&_cond); - if (rc != 0) + if(rc != 0) { throw SyscallException(strerror(rc), __FILE__, __LINE__); } @@ -224,7 +224,7 @@ void IceUtil::Cond::broadcast() { int rc = pthread_cond_broadcast(&_cond); - if (rc != 0) + if(rc != 0) { throw SyscallException(strerror(rc), __FILE__, __LINE__); } diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 38afb2406ef..eab176ff011 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -38,7 +38,7 @@ IceUtil::Exception::ice_name() const void IceUtil::Exception::ice_print(ostream& out) const { - if (_file && _line > 0) + if(_file && _line > 0) { out << _file << ':' << _line << ": "; } diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp index 1c690ff5f88..1759f8bec88 100644 --- a/cpp/src/IceUtil/OutputUtil.cpp +++ b/cpp/src/IceUtil/OutputUtil.cpp @@ -73,9 +73,9 @@ IceUtil::OutputBase::open(const char* s) void IceUtil::OutputBase::print(const char* s) { - for (unsigned int i = 0; i < strlen(s); ++i) + for(unsigned int i = 0; i < strlen(s); ++i) { - if (s[i] == '\n') + if(s[i] == '\n') { _pos = 0; } @@ -144,9 +144,9 @@ IceUtil::OutputBase::nl() int indent = _indent; - if (_useTab) + if(_useTab) { - while (indent >= 8) + while(indent >= 8) { indent -= 8; _out << '\t'; @@ -155,7 +155,7 @@ IceUtil::OutputBase::nl() } else { - while (indent >= _indentSize) + while(indent >= _indentSize) { indent -= _indentSize; _out << " "; @@ -163,7 +163,7 @@ IceUtil::OutputBase::nl() } } - while (indent > 0) + while(indent > 0) { --indent; _out << ' '; @@ -176,7 +176,7 @@ IceUtil::OutputBase::nl() void IceUtil::OutputBase::sp() { - if (_separator) + if(_separator) { _out << '\n'; } @@ -228,7 +228,7 @@ IceUtil::Output::setEndBlock(const char *eb) void IceUtil::Output::sb() { - if (_blockStart.length()) + if(_blockStart.length()) { nl(); _out << _blockStart; @@ -242,7 +242,7 @@ void IceUtil::Output::eb() { dec(); - if (_blockEnd.length()) + if(_blockEnd.length()) { nl(); _out << _blockEnd; @@ -293,7 +293,7 @@ IceUtil::XMLOutput::setSGML(bool sgml) void IceUtil::XMLOutput::print(const char* s) { - if (!_printed) + if(!_printed) { _out << '>'; _printed = true; @@ -304,7 +304,7 @@ IceUtil::XMLOutput::print(const char* s) void IceUtil::XMLOutput::nl() { - if (!_printed) + if(!_printed) { _printed = true; _out << '>'; @@ -323,7 +323,7 @@ IceUtil::XMLOutput::se(const std::string& element) // emitted) or until something //is displayed. // _out << '<' << element; - if (_sgml) + if(_sgml) { _out << '>'; } @@ -334,7 +334,7 @@ IceUtil::XMLOutput::se(const std::string& element) string::size_type pos = element.find_first_of(" \t"); - if (pos == string::npos) + if(pos == string::npos) { _elementStack.push(element); } @@ -355,7 +355,7 @@ IceUtil::XMLOutput::ee() _elementStack.pop(); dec(); - if (!_printed) + if(!_printed) { _out << "/>"; } diff --git a/cpp/src/IceUtil/RWRecMutex.cpp b/cpp/src/IceUtil/RWRecMutex.cpp index a9785dc7fef..e4c602c95ac 100644 --- a/cpp/src/IceUtil/RWRecMutex.cpp +++ b/cpp/src/IceUtil/RWRecMutex.cpp @@ -33,7 +33,7 @@ IceUtil::RWRecMutex::readlock() const // Wait while a writer holds the lock or while writers are waiting // to get the lock. // - while (_count < 0 || _waitingWriters != 0) + while(_count < 0 || _waitingWriters != 0) { _readers.wait(lock); } @@ -49,7 +49,7 @@ IceUtil::RWRecMutex::tryReadlock() const // Would block if a writer holds the lock or if writers are // waiting to get the lock. // - if (_count < 0 || _waitingWriters != 0) + if(_count < 0 || _waitingWriters != 0) { throw LockedException(__FILE__, __LINE__); } @@ -66,10 +66,10 @@ IceUtil::RWRecMutex::timedTryReadlock(const Time& timeout) const // to get the lock. // Time end = Time::now() + timeout; - while (_count < 0 || _waitingWriters != 0) + while(_count < 0 || _waitingWriters != 0) { Time remainder = end - Time::now(); - if (remainder > Time()) + if(remainder > Time()) { _readers.timedWait(lock, remainder); } @@ -91,7 +91,7 @@ IceUtil::RWRecMutex::writelock() const // If the mutex is already write locked by this writer then // decrement _count, and return. // - if (_count < 0 && _writerControl == ThreadControl()) + if(_count < 0 && _writerControl == ThreadControl()) { --_count; return; @@ -101,7 +101,7 @@ IceUtil::RWRecMutex::writelock() const // Wait for the lock to become available and increment the number // of waiting writers. // - while (_count != 0) + while(_count != 0) { _waitingWriters++; try @@ -131,7 +131,7 @@ IceUtil::RWRecMutex::tryWritelock() const // If the mutex is already write locked by this writer then // decrement _count, and return. // - if (_count < 0 && _writerControl == ThreadControl()) + if(_count < 0 && _writerControl == ThreadControl()) { --_count; return; @@ -140,7 +140,7 @@ IceUtil::RWRecMutex::tryWritelock() const // // If there are readers or other writers then the call would block. // - if (_count != 0) + if(_count != 0) { throw LockedException(__FILE__, __LINE__); } @@ -160,7 +160,7 @@ IceUtil::RWRecMutex::timedTryWritelock(const Time& timeout) const // If the mutex is already write locked by this writer then // decrement _count, and return. // - if (_count < 0 && _writerControl == ThreadControl()) + if(_count < 0 && _writerControl == ThreadControl()) { --_count; return; @@ -171,10 +171,10 @@ IceUtil::RWRecMutex::timedTryWritelock(const Time& timeout) const // of waiting writers. // Time end = Time::now() + timeout; - while (_count != 0) + while(_count != 0) { Time remainder = end - Time::now(); - if (remainder > Time()) + if(remainder > Time()) { _waitingWriters++; try @@ -215,7 +215,7 @@ IceUtil::RWRecMutex::unlock() const // lock, so release the lock. Otherwise, _count is guaranteed to // be > 0, so the calling thread is a reader releasing the lock. // - if (_count < 0) + if(_count < 0) { // // Writer called unlock @@ -225,7 +225,7 @@ IceUtil::RWRecMutex::unlock() const // // If the write lock wasn't totally released we're done. // - if (_count != 0) + if(_count != 0) { return; } @@ -252,14 +252,14 @@ IceUtil::RWRecMutex::unlock() const // Wake up a waiting writer if there is one. If not, wake up all // readers (just in case -- there may be none). // - if (ww) + if(ww) { // // Wake writer // _writers.signal(); } - else if (wr) + else if(wr) { // // Wake readers @@ -282,7 +282,7 @@ IceUtil::RWRecMutex::upgrade() const // // Wait to acquire the write lock. // - while (_count != 0) + while(_count != 0) { _waitingWriters++; try @@ -320,10 +320,10 @@ IceUtil::RWRecMutex::timedUpgrade(const Time& timeout) const // Wait to acquire the write lock. // Time end = Time::now() + timeout; - while (_count != 0) + while(_count != 0) { Time remainder = end - Time::now(); - if (remainder > Time()) + if(remainder > Time()) { _waitingWriters++; try diff --git a/cpp/src/IceUtil/RecMutex.cpp b/cpp/src/IceUtil/RecMutex.cpp index 9a876fb2ccd..182751ea67e 100644 --- a/cpp/src/IceUtil/RecMutex.cpp +++ b/cpp/src/IceUtil/RecMutex.cpp @@ -31,7 +31,7 @@ bool IceUtil::RecMutex::lock() const { EnterCriticalSection(&_mutex); - if (++_count > 1) + if(++_count > 1) { LeaveCriticalSection(&_mutex); return false; @@ -42,11 +42,11 @@ IceUtil::RecMutex::lock() const bool IceUtil::RecMutex::trylock() const { - if (!TryEnterCriticalSection(&_mutex)) + if(!TryEnterCriticalSection(&_mutex)) { throw LockedException(__FILE__, __LINE__); } - if (++_count > 1) + if(++_count > 1) { LeaveCriticalSection(&_mutex); return false; @@ -57,7 +57,7 @@ IceUtil::RecMutex::trylock() const bool IceUtil::RecMutex::unlock() const { - if (--_count == 0) + if(--_count == 0) { LeaveCriticalSection(&_mutex); return true; @@ -86,7 +86,7 @@ IceUtil::RecMutex::RecMutex() : { const pthread_mutexattr_t attr = { PTHREAD_MUTEX_RECURSIVE_NP }; int rc = pthread_mutex_init(&_mutex, &attr); - if (rc != 0) + if(rc != 0) { throw SyscallException(strerror(rc), __FILE__, __LINE__); } @@ -104,11 +104,11 @@ bool IceUtil::RecMutex::lock() const { int rc = pthread_mutex_lock(&_mutex); - if (rc != 0) + if(rc != 0) { throw SyscallException(strerror(rc), __FILE__, __LINE__); } - if (++_count > 1) + if(++_count > 1) { rc = pthread_mutex_unlock(&_mutex); assert(rc == 0); @@ -121,15 +121,15 @@ bool IceUtil::RecMutex::trylock() const { int rc = pthread_mutex_trylock(&_mutex); - if (rc != 0) + if(rc != 0) { - if (rc == EBUSY) + if(rc == EBUSY) { throw LockedException(__FILE__, __LINE__); } throw SyscallException(strerror(rc), __FILE__, __LINE__); } - if (++_count > 1) + if(++_count > 1) { rc = pthread_mutex_unlock(&_mutex); assert(rc == 0); @@ -141,7 +141,7 @@ IceUtil::RecMutex::trylock() const bool IceUtil::RecMutex::unlock() const { - if (--_count == 0) + if(--_count == 0) { int rc = 0; // Prevent warnings when NDEBUG is defined. rc = pthread_mutex_unlock(&_mutex); diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index cfb4f11c0f0..31ba4c36115 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -9,7 +9,7 @@ // ********************************************************************** #include <IceUtil/Thread.h> -#include <IceUtil/Exception.h>
+#include <IceUtil/Exception.h> #include <IceUtil/Time.h> using namespace std; @@ -23,7 +23,7 @@ IceUtil::ThreadControl::ThreadControl() : HANDLE proc = GetCurrentProcess(); HANDLE current = GetCurrentThread(); int rc = DuplicateHandle(proc, current, proc, &_handle->handle, SYNCHRONIZE, TRUE, 0); - if (rc == 0) + if(rc == 0) { throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); } @@ -57,7 +57,7 @@ void IceUtil::ThreadControl::join() { int rc = WaitForSingleObject(_handle->handle, INFINITE); - if (rc != WAIT_OBJECT_0) + if(rc != WAIT_OBJECT_0) { throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); } @@ -136,7 +136,7 @@ IceUtil::Thread::start() __incRef(); _handle->handle = (HANDLE)_beginthreadex(0, 0, (unsigned (__stdcall*)(void*))startHook, (LPVOID)this, 0, &_id); - if (_handle->handle == 0) + if(_handle->handle == 0) { __decRef(); throw SyscallException(SyscallException::errorToString(GetLastError()), __FILE__, __LINE__); @@ -205,7 +205,7 @@ IceUtil::ThreadControl::join() { void* ignore = 0; int rc = pthread_join(_id, &ignore); - if (rc != 0) + if(rc != 0) { throw SyscallException(strerror(rc), __FILE__, __LINE__); } @@ -276,7 +276,7 @@ IceUtil::Thread::start() // __incRef(); int rc = pthread_create(&_id, 0, startHook, this); - if (rc != 0) + if(rc != 0) { __decRef(); throw SyscallException(strerror(rc), __FILE__, __LINE__); diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index 1cff84ab08a..6410cb2b9b5 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -19,27 +19,27 @@ IceUtil::wstringToString(const wstring& str) string result; result.reserve(str.length() * 2); - for (unsigned int i = 0; i < str.length(); ++i) + for(unsigned int i = 0; i < str.length(); ++i) { wchar_t wc; wc = str[i]; - if (wc < 0x80) + if(wc < 0x80) { result += static_cast<char>(wc); } - else if (wc < 0x800) + else if(wc < 0x800) { result += 0xc0 | (wc>>6); result += 0x80 | (wc & 0x3f); } - else if (wc < 0x10000) + else if(wc < 0x10000) { result += 0xe0 | (wc>>12); result += 0x80 | ((wc>>6) & 0x3f); result += 0x80 | (wc & 0x3f); } - else if (wc < 0x10FFFF) + else if(wc < 0x10FFFF) { result += 0xf0 | (wc>>18); result += 0x80 | ((wc>>12) & 0x3f); @@ -62,19 +62,19 @@ IceUtil::stringToWstring(const string& str) result.reserve(str.length()); unsigned int len; - for (unsigned int i = 0; i < str.length(); i += len) + for(unsigned int i = 0; i < str.length(); i += len) { unsigned char c = str[i]; wchar_t wc; int minval; - if (c < 0x80) + if(c < 0x80) { wc = c; len = 1; minval = 0; } - else if (c < 0xc0) // Lead byte must not be 10xxxxxx + else if(c < 0xc0) // Lead byte must not be 10xxxxxx { return result; // Error, not encodable. } @@ -97,14 +97,14 @@ IceUtil::stringToWstring(const string& str) len = 4; minval = 0x10000; } - else if (c < 0xfc) // 111110xx + else if(c < 0xfc) // 111110xx { // Length 5 and 6 is declared invalid in Unicode 3.1 and ISO 10646:2001. wc = c & 3; len = 5; minval = 0x110000; } - else if (c < 0xfe) // 1111110x + else if(c < 0xfe) // 1111110x { // Length 5 and 6 is declared invalid in Unicode 3.1 and ISO 10646:2001. wc = c & 1; @@ -117,11 +117,11 @@ IceUtil::stringToWstring(const string& str) return result; // Error, not encodable. } - if (i + len - 1 < str.length()) + if(i + len - 1 < str.length()) { - for (unsigned int j = 1; j < len; ++j) + for(unsigned int j = 1; j < len; ++j) { - if ((str[i + j] & 0xc0) != 0x80) // All other bytes must be 10xxxxxx + if((str[i + j] & 0xc0) != 0x80) // All other bytes must be 10xxxxxx { return result; // Error, not encodable. } @@ -130,7 +130,7 @@ IceUtil::stringToWstring(const string& str) wc |= str[i + j] & 0x3f; } - if (wc < minval) + if(wc < minval) { return result; // Error, non-shortest form. } diff --git a/cpp/src/IceXML/StreamI.cpp b/cpp/src/IceXML/StreamI.cpp index d8c6b252213..9848d14a7ab 100644 --- a/cpp/src/IceXML/StreamI.cpp +++ b/cpp/src/IceXML/StreamI.cpp @@ -218,7 +218,7 @@ IceXML::StreamI::StreamI(const ::Ice::CommunicatorPtr& communicator, std::istrea // // Read the contents of the stream into memory. // - while (!is.eof()) + while(!is.eof()) { char buf[1000]; is.read(buf, sizeof(buf)); @@ -236,7 +236,7 @@ IceXML::StreamI::StreamI(const ::Ice::CommunicatorPtr& communicator, std::istrea // _input->parser = new DOMParser; _input->parser->setValidationScheme(DOMParser::Val_Auto); - if (schema) + if(schema) { _input->parser->setDoNamespaces(true); _input->parser->setDoSchema(true); @@ -260,7 +260,7 @@ IceXML::StreamI::StreamI(const ::Ice::CommunicatorPtr& communicator, std::istrea { _input->parser->parse(*_input->source); int errorCount = _input->parser->getErrorCount(); - if (errorCount > 0) + if(errorCount > 0) { errorsOccured = true; } @@ -280,7 +280,7 @@ IceXML::StreamI::StreamI(const ::Ice::CommunicatorPtr& communicator, std::istrea errorsOccured = true; } - if (errorsOccured) + if(errorsOccured) { delete _input; throw ::Ice::MarshalException(__FILE__, __LINE__); @@ -476,14 +476,14 @@ IceXML::StreamI::readEnum(const string& name, const ::Ice::StringSeq& table) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } string value = toString(child.getNodeValue()); ::Ice::StringSeq::const_iterator p = find(table.begin(), table.end(), value); - if (p == table.end()) + if(p == table.end()) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -507,7 +507,7 @@ void IceXML::StreamI::writeByteSeq(const string& name, const ::Ice::ByteSeq& seq) { startWrite(name); - for (::Ice::ByteSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::ByteSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << (int)*p << "</e>"; } @@ -520,14 +520,14 @@ IceXML::StreamI::readByte(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } string s = toString(child.getNodeValue()); ::Ice::Int i = atoi(s.c_str()); - if (i < -127 || i > 128) + if(i < -127 || i > 128) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -549,21 +549,21 @@ IceXML::StreamI::readByte(const string& name) // DOM_NodeList children = _input->current.getChildNodes(); // // int nchildren = children.getLength(); -// for (int i = 0; i < nchildren; ++i) +// for(int i = 0; i < nchildren; ++i) // { // DOM_Node child = children.item(i); -// while (child.getNodeType() != DOM_Node::ELEMENT_NODE) +// while(child.getNodeType() != DOM_Node::ELEMENT_NODE) // { // child = child.getNextSibling(); // } // string name = toString(child.getNodeName()); -// if (name != seqElementName) +// if(name != seqElementName) // { // throw ::Ice::MarshalException(__FILE__, __LINE__); // } // // child = child.getFirstChild(); -// if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) +// if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) // { // throw ::Ice::MarshalException(__FILE__, __LINE__); // } @@ -586,10 +586,10 @@ IceXML::StreamI::readByteSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readByte(seqElementName); } @@ -612,7 +612,7 @@ void IceXML::StreamI::writeBoolSeq(const string& name, const ::Ice::BoolSeq& seq) { startWrite(name); - for (::Ice::BoolSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::BoolSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << ((*p) ? "true" : "false") << "</e>"; } @@ -625,7 +625,7 @@ IceXML::StreamI::readBool(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -646,10 +646,10 @@ IceXML::StreamI::readBoolSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readBool(seqElementName); } @@ -672,7 +672,7 @@ void IceXML::StreamI::writeShortSeq(const string& name, const ::Ice::ShortSeq& seq) { startWrite(name); - for (::Ice::ShortSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::ShortSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << *p << "</e>"; } @@ -685,14 +685,14 @@ IceXML::StreamI::readShort(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } string s = toString(child.getNodeValue()); ::Ice::Int i = atoi(s.c_str()); - if (i < -32767 || i > 32768) + if(i < -32767 || i > 32768) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -711,10 +711,10 @@ IceXML::StreamI::readShortSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readShort(seqElementName); } @@ -737,7 +737,7 @@ void IceXML::StreamI::writeIntSeq(const string& name, const ::Ice::IntSeq& seq) { startWrite(name); - for (::Ice::IntSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::IntSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << *p << "</e>"; } @@ -750,7 +750,7 @@ IceXML::StreamI::readInt(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -771,10 +771,10 @@ IceXML::StreamI::readIntSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readInt(seqElementName); } @@ -797,7 +797,7 @@ void IceXML::StreamI::writeLongSeq(const string& name, const ::Ice::LongSeq& seq) { startWrite(name); - for (::Ice::LongSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::LongSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << *p << "</e>"; } @@ -810,7 +810,7 @@ IceXML::StreamI::readLong(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -831,10 +831,10 @@ IceXML::StreamI::readLongSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readLong(seqElementName); } @@ -857,7 +857,7 @@ void IceXML::StreamI::writeFloatSeq(const string& name, const ::Ice::FloatSeq& seq) { startWrite(name); - for (::Ice::FloatSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::FloatSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << *p << "</e>"; } @@ -870,7 +870,7 @@ IceXML::StreamI::readFloat(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -891,10 +891,10 @@ IceXML::StreamI::readFloatSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readFloat(seqElementName); } @@ -917,7 +917,7 @@ void IceXML::StreamI::writeDoubleSeq(const string& name, const ::Ice::DoubleSeq& seq) { startWrite(name); - for (::Ice::DoubleSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::DoubleSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << *p << "</e>"; } @@ -930,7 +930,7 @@ IceXML::StreamI::readDouble(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.isNull() || child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -951,10 +951,10 @@ IceXML::StreamI::readDoubleSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readDouble(seqElementName); } @@ -977,13 +977,13 @@ IceXML::StreamI::writeString(const string& name, const string& value) // conversion if not necessary. // static const string allReserved = "<>'\"&"; - if (v.find_first_of(allReserved) != string::npos) + if(v.find_first_of(allReserved) != string::npos) { // // First convert all & to & // size_t pos = 0; - while ((pos = v.find_first_of('&', pos)) != string::npos) + while((pos = v.find_first_of('&', pos)) != string::npos) { v.insert(pos+1, "amp;"); pos += 4; @@ -994,7 +994,7 @@ IceXML::StreamI::writeString(const string& name, const string& value) // static const string reserved = "<>'\""; pos = 0; - while ((pos = v.find_first_of(reserved, pos)) != string::npos) + while((pos = v.find_first_of(reserved, pos)) != string::npos) { string replace; switch(v[pos]) @@ -1031,7 +1031,7 @@ void IceXML::StreamI::writeStringSeq(const string& name, const ::Ice::StringSeq& seq) { startWrite(name); - for (::Ice::StringSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) + for(::Ice::StringSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { _os << nl << "<e>" << *p << "</e>"; // TODO: Escape } @@ -1046,9 +1046,9 @@ IceXML::StreamI::readString(const string& name) startRead(name); DOM_Node child = _input->current.getFirstChild(); - if (!child.isNull()) + if(!child.isNull()) { - if (child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -1074,10 +1074,10 @@ IceXML::StreamI::readStringSeq(const string& name) ::Ice::Int size = readLength(); value.resize(size); - if (size > 0) + if(size > 0) { _input->current = _input->current.getFirstChild(); - for (int i = 0; i < size; ++i) + for(int i = 0; i < size; ++i) { value[i] = readString(seqElementName); } @@ -1104,9 +1104,9 @@ IceXML::StreamI::readProxy(const string& name) DOM_Node child = _input->current.getFirstChild(); string s; - if (!child.isNull()) + if(!child.isNull()) { - if (child.getNodeType() != DOM_Node::TEXT_NODE) + if(child.getNodeType() != DOM_Node::TEXT_NODE) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -1131,7 +1131,7 @@ IceXML::StreamI::writeObject(const string& name, const ::Ice::ObjectPtr& obj) // If the object doesn't exist in the map add it. // map<Ice::ObjectPtr, ObjectInfo>::iterator p = _objects.find(obj); - if (p == _objects.end()) + if(p == _objects.end()) { ostringstream os; os << "object" << _nextId++; @@ -1139,7 +1139,7 @@ IceXML::StreamI::writeObject(const string& name, const ::Ice::ObjectPtr& obj) obj, ObjectInfo(os.str(), !writeReference))).first; } - if (writeReference) + if(writeReference) { _os << nl << "<" << name << " href=\"#" << p->second.id << "\"/>"; } @@ -1173,12 +1173,12 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con // readObjects list. Otherwise, it should be in the object-set at // the top-level of the document. // - if (!href.empty()) + if(!href.empty()) { href = href.substr(1); // Skip the '#' map<string, ::Ice::ObjectPtr>::const_iterator p = _input->readObjects.find(href); - if (p != _input->readObjects.end()) + if(p != _input->readObjects.end()) { value = p->second; endRead(); @@ -1191,13 +1191,13 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con // _input->current = _input->parser->getDocument().getFirstChild(); _input->current = _input->current.getFirstChild(); - while (!_input->current.isNull()) + while(!_input->current.isNull()) { - if (_input->current.getNodeType() == DOM_Node::ELEMENT_NODE) + if(_input->current.getNodeType() == DOM_Node::ELEMENT_NODE) { string dummy; readAttributes(id, type, dummy); - if (id == href) + if(id == href) { break; } @@ -1207,7 +1207,7 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con // // If the object isn't found, that's an error. // - if (_input->current.isNull()) + if(_input->current.isNull()) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -1216,7 +1216,7 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con // // Empty type indicates nil object. // - if (type.empty()) + if(type.empty()) { value = 0; } @@ -1224,7 +1224,7 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con { static const string iceObject("::Ice::Object"); - if (type == iceObject) + if(type == iceObject) { value = new ::Ice::Object; } @@ -1238,19 +1238,19 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con // can be created then throw a NoObjectFactoryException. // ::Ice::ObjectFactoryPtr userFactory = _communicator->findObjectFactory(type); - if (userFactory) + if(userFactory) { value = userFactory->create(type); } - if (!value && type == signatureType) + if(!value && type == signatureType) { assert(factory); value = factory->create(type); assert(value); } - if (!value) + if(!value) { throw ::Ice::NoObjectFactoryException(__FILE__, __LINE__); } @@ -1284,7 +1284,7 @@ IceXML::StreamI::endWrite() _os << ee; - if (_level == 0) + if(_level == 0) { dumpUnwrittenObjects(); } @@ -1294,11 +1294,11 @@ IceXML::StreamI::endWrite() void IceXML::StreamI::startRead(const ::std::string& element) { - while (!_input->current.isNull() && _input->current.getNodeType() != DOM_Node::ELEMENT_NODE) + while(!_input->current.isNull() && _input->current.getNodeType() != DOM_Node::ELEMENT_NODE) { _input->current = _input->current.getNextSibling(); } - if (_input->current.isNull()) + if(_input->current.isNull()) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -1309,7 +1309,7 @@ IceXML::StreamI::startRead(const ::std::string& element) // static const string facets = "facets"; static const string facetsNS = "ice:facets"; - if ((element != facetsNS || nodeName != facets) && element != nodeName) + if((element != facetsNS || nodeName != facets) && element != nodeName) { throw ::Ice::MarshalException(__FILE__, __LINE__); } @@ -1344,9 +1344,9 @@ IceXML::StreamI::dumpUnwrittenObjects() { nwritten = 0; map<Ice::ObjectPtr, ObjectInfo>::iterator p; - for (p = _objects.begin(); p != _objects.end(); ++p) + for(p = _objects.begin(); p != _objects.end(); ++p) { - if (!p->second.written) + if(!p->second.written) { p->second.written = true; writeObjectData("ice:object", p->second.id, p->first); @@ -1358,7 +1358,7 @@ IceXML::StreamI::dumpUnwrittenObjects() } } } - while (_objects.size() != nwritten); + while(_objects.size() != nwritten); } void @@ -1367,7 +1367,7 @@ IceXML::StreamI::writeObjectData(const string& name, const string& id, const Ice string xsdType; string typeId; - if (obj) + if(obj) { // // Convert the type-id to the equivalent schema type @@ -1380,13 +1380,13 @@ IceXML::StreamI::writeObjectData(const string& name, const string& id, const Ice xsdType.reserve(typeId.size() + xsdPrefix.size() + xsdSuffix.size()); xsdType += xsdPrefix; unsigned int i = 0; - if (typeId[0] == ':') // Skip the preceeding "::". + if(typeId[0] == ':') // Skip the preceeding "::". { i = 2; } - for (; i < typeId.size(); ++i) + for(; i < typeId.size(); ++i) { - if (typeId[i] == ':') + if(typeId[i] == ':') { xsdType += '.'; ++i; @@ -1406,13 +1406,13 @@ IceXML::StreamI::writeObjectData(const string& name, const string& id, const Ice ostringstream os; os << name << " id=\"" << id << "\" type=\"" << typeId << "\"" << " xsi:type=\"" << xsdType << "\""; - if (!obj) + if(!obj) { os << " xsi:nil=\"true\""; } startWrite(os.str()); - if (obj) + if(obj) { obj->__marshal(this); } @@ -1428,19 +1428,19 @@ IceXML::StreamI::readAttributes(::std::string& id, ::std::string& type, ::std::s DOM_NamedNodeMap attributes = _input->current.getAttributes(); int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string name = toString(attribute.getNodeName()); - if (name == idStr) + if(name == idStr) { id = toString(attribute.getNodeValue()); } - else if (name == typeStr) + else if(name == typeStr) { type = toString(attribute.getNodeValue()); } - else if (name == hrefStr) + else if(name == hrefStr) { href = toString(attribute.getNodeValue()); } @@ -1454,11 +1454,11 @@ IceXML::StreamI::readLength() DOM_NamedNodeMap attributes = _input->current.getAttributes(); int attrCount = attributes.getLength(); - for (int i = 0; i < attrCount; i++) + for(int i = 0; i < attrCount; i++) { DOM_Node attribute = attributes.item(i); string name = toString(attribute.getNodeName()); - if (name == lengthStr) + if(name == lengthStr) { return atoi(toString(attribute.getNodeValue()).c_str()); } diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 16cfbe6edf5..719a66c8d1e 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -17,7 +17,7 @@ using namespace IceUtil; char Slice::ToIfdef::operator()(char c) { - if (!isalnum(c)) + if(!isalnum(c)) { return '_'; } @@ -33,15 +33,15 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) string file = orig; replace(file.begin(), file.end(), '\\', '/'); - for (vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p) + for(vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p) { string includePath = *p; replace(includePath.begin(), includePath.end(), '\\', '/'); - if (orig.compare(0, includePath.length(), *p) == 0) + if(orig.compare(0, includePath.length(), *p) == 0) { string s = orig.substr(includePath.length()); - if (s.size() < file.size()) + if(s.size() < file.size()) { file = s; } @@ -49,7 +49,7 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths) } string::size_type pos = file.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { file.erase(pos); } @@ -90,7 +90,7 @@ Slice::printVersionCheck(Output& out) void Slice::printDllExportStuff(Output& out, const string& dllExport) { - if (dllExport.size()) + if(dllExport.size()) { out << sp; out << "\n#ifdef _WIN32"; @@ -124,25 +124,25 @@ Slice::typeToString(const TypePtr& type) }; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { return builtinTable[builtin->kind()]; } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { return cl->scoped() + "Ptr"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); - if (proxy) + if(proxy) { return proxy->_class()->scoped() + "Prx"; } ContainedPtr contained = ContainedPtr::dynamicCast(type); - if (contained) + if(contained) { return contained->scoped(); } @@ -153,7 +153,7 @@ Slice::typeToString(const TypePtr& type) string Slice::returnTypeToString(const TypePtr& type) { - if (!type) + if(!type) { return "void"; } @@ -180,31 +180,31 @@ Slice::inputTypeToString(const TypePtr& type) }; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { return inputBuiltinTable[builtin->kind()]; } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { return "const " + cl->scoped() + "Ptr&"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); - if (proxy) + if(proxy) { return "const " + proxy->_class()->scoped() + "Prx&"; } EnumPtr en = EnumPtr::dynamicCast(type); - if (en) + if(en) { return en->scoped(); } ContainedPtr contained = ContainedPtr::dynamicCast(type); - if (contained) + if(contained) { return "const " + contained->scoped() + "&"; } @@ -231,25 +231,25 @@ Slice::outputTypeToString(const TypePtr& type) }; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { return outputBuiltinTable[builtin->kind()]; } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { return cl->scoped() + "Ptr&"; } ProxyPtr proxy = ProxyPtr::dynamicCast(type); - if (proxy) + if(proxy) { return proxy->_class()->scoped() + "Prx&"; } ContainedPtr contained = ContainedPtr::dynamicCast(type); - if (contained) + if(contained) { return contained->scoped() + "&"; } @@ -262,7 +262,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& const string& str, bool pointer) { string stream; - if (str.empty()) + if(str.empty()) { stream = marshal ? "__os" : "__is"; } @@ -272,7 +272,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } string deref; - if (pointer) + if(pointer) { deref = "->"; } @@ -282,7 +282,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } string obj; - if (stream.find("__") == 0) + if(stream.find("__") == 0) { obj = "__obj"; } @@ -294,11 +294,11 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& string func = marshal ? "write(" : "read("; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - if (builtin->kind() == Builtin::KindObject) + if(builtin->kind() == Builtin::KindObject) { - if (marshal) + if(marshal) { out << nl << stream << deref << func << param << ");"; } @@ -316,10 +316,10 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { out << sb; - if (marshal) + if(marshal) { out << nl << "::Ice::ObjectPtr " << obj << " = " << param << ';'; out << nl << stream << deref << func << obj << ");"; @@ -330,7 +330,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& ClassDefPtr def = cl->definition(); string factory; string type; - if (def && !def->isAbstract()) + if(def && !def->isAbstract()) { factory = cl->scoped(); factory += "::_factory"; @@ -351,17 +351,17 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } StructPtr st = StructPtr::dynamicCast(type); - if (st) + if(st) { out << nl << param << ".__" << func << (pointer ? "" : "&") << stream << ");"; return; } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); - if (builtin && builtin->kind() != Builtin::KindObject && builtin->kind() != Builtin::KindObjectProxy) + if(builtin && builtin->kind() != Builtin::KindObject && builtin->kind() != Builtin::KindObjectProxy) { out << nl << stream << deref << func << param << ");"; } @@ -374,7 +374,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } DictionaryPtr dict = DictionaryPtr::dynamicCast(type); - if (dict) + if(dict) { out << nl << dict->scope() << "__" << func << (pointer ? "" : "&") << stream << ", " << param << ", " << dict->scope() << "__U__" << dict->name() << "());"; @@ -382,7 +382,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); - if (!constructed) + if(!constructed) { ProxyPtr proxy = ProxyPtr::dynamicCast(type); assert(proxy); @@ -395,11 +395,11 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& void Slice::writeMarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { - for (list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) + for(list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) { writeMarshalUnmarshalCode(out, p->first, p->second, true); } - if (ret) + if(ret) { writeMarshalUnmarshalCode(out, ret, "__ret", true); } @@ -408,11 +408,11 @@ Slice::writeMarshalCode(Output& out, const list<pair<TypePtr, string> >& params, void Slice::writeUnmarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { - for (list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) + for(list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) { writeMarshalUnmarshalCode(out, p->first, p->second, false); } - if (ret) + if(ret) { writeMarshalUnmarshalCode(out, ret, "__ret", false); } @@ -422,12 +422,12 @@ void Slice::writeAllocateCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { list<pair<TypePtr, string> > ps = params; - if (ret) + if(ret) { ps.push_back(make_pair(ret, string("__ret"))); } - for (list<pair<TypePtr, string> >::const_iterator p = ps.begin(); p != ps.end(); ++p) + for(list<pair<TypePtr, string> >::const_iterator p = ps.begin(); p != ps.end(); ++p) { out << nl << typeToString(p->first) << ' ' << p->second << ';'; } @@ -438,7 +438,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const bool marshal, const string& tn, const string& str, bool pointer) { string stream; - if (str.empty()) + if(str.empty()) { stream = marshal ? "__os" : "__is"; } @@ -448,7 +448,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } string deref; - if (pointer) + if(pointer) { deref = "->"; } @@ -458,7 +458,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } string obj; - if (stream.find("__") == 0) + if(stream.find("__") == 0) { obj = "__obj"; } @@ -482,7 +482,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const "???" }; string tagName; - if (tn.empty()) + if(tn.empty()) { tagName = "\""; tagName += param; @@ -497,12 +497,12 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const string genFunc = marshal ? "ice_marshal(" : "ice_unmarshal("; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - if (builtin->kind() == Builtin::KindObject) + if(builtin->kind() == Builtin::KindObject) { streamFunc += outputBuiltinTable[builtin->kind()]; - if (marshal) + if(marshal) { out << nl << stream << deref << streamFunc << "(" << tagName << ", " << param << ");"; } @@ -515,7 +515,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } else { - if (marshal) + if(marshal) { out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "(" << tagName << ", " << param << ");"; @@ -530,10 +530,10 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { out << sb; - if (marshal) + if(marshal) { out << nl << "::Ice::ObjectPtr " << obj << " = " << param << ';'; out << nl << stream << deref << streamFunc << "Object(" << tagName << ", " << obj << ");"; @@ -544,7 +544,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const ClassDefPtr def = cl->definition(); string factory; string type; - if (def && !def->isAbstract()) + if(def && !def->isAbstract()) { factory = cl->scoped(); factory += "::_factory"; @@ -566,19 +566,19 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } StructPtr st = StructPtr::dynamicCast(type); - if (st) + if(st) { out << nl << param << "." << genFunc << tagName << ", " << (pointer ? "" : "&") << stream << ");"; return; } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); - if (builtin && builtin->kind() != Builtin::KindObject && builtin->kind() != Builtin::KindObjectProxy) + if(builtin && builtin->kind() != Builtin::KindObject && builtin->kind() != Builtin::KindObjectProxy) { - if (marshal) + if(marshal) { out << nl << stream << deref << streamFunc << outputBuiltinTable[builtin->kind()] << "Seq(" << tagName << ", " << param << ");"; @@ -598,7 +598,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } DictionaryPtr dict = DictionaryPtr::dynamicCast(type); - if (dict) + if(dict) { out << nl << dict->scope() << genFunc << tagName << ", " << (pointer ? "" : "&") << stream << ", " << param << ", " << dict->scope() << "__U__" << dict->name() << "());"; @@ -606,7 +606,7 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const } ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); - if (!constructed) + if(!constructed) { ProxyPtr proxy = ProxyPtr::dynamicCast(type); assert(proxy); @@ -620,11 +620,11 @@ Slice::writeGenericMarshalUnmarshalCode(Output& out, const TypePtr& type, const void Slice::writeGenericMarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { - for (list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) + for(list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) { writeGenericMarshalUnmarshalCode(out, p->first, p->second, true); } - if (ret) + if(ret) { writeGenericMarshalUnmarshalCode(out, ret, "__ret", true); } @@ -633,11 +633,11 @@ Slice::writeGenericMarshalCode(Output& out, const list<pair<TypePtr, string> >& void Slice::writeGenericUnmarshalCode(Output& out, const list<pair<TypePtr, string> >& params, const TypePtr& ret) { - for (list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) + for(list<pair<TypePtr, string> >::const_iterator p = params.begin(); p != params.end(); ++p) { writeGenericMarshalUnmarshalCode(out, p->first, p->second, false); } - if (ret) + if(ret) { writeGenericMarshalUnmarshalCode(out, ret, "__ret", false); } diff --git a/cpp/src/Slice/GrammarUtil.h b/cpp/src/Slice/GrammarUtil.h index d26447b9fe6..6c59d265b8a 100644 --- a/cpp/src/Slice/GrammarUtil.h +++ b/cpp/src/Slice/GrammarUtil.h @@ -1,135 +1,135 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef SLICE_GRAMMER_UTIL_H -#define SLICE_GRAMMER_UTIL_H - -#include <Slice/Parser.h> - -namespace Slice -{ - -class StringTok; -class StringListTok; -class TypeStringTok; -class TypeStringListTok; -class BoolTok; -class ExceptionListTok; -class ClassListTok; -class EnumeratorListTok; - -typedef ::IceUtil::Handle<StringTok> StringTokPtr; -typedef ::IceUtil::Handle<StringListTok> StringListTokPtr; -typedef ::IceUtil::Handle<TypeStringTok> TypeStringTokPtr; -typedef ::IceUtil::Handle<TypeStringListTok> TypeStringListTokPtr; -typedef ::IceUtil::Handle<BoolTok> BoolTokPtr; -typedef ::IceUtil::Handle<ExceptionListTok> ExceptionListTokPtr; -typedef ::IceUtil::Handle<ClassListTok> ClassListTokPtr; -typedef ::IceUtil::Handle<EnumeratorListTok> EnumeratorListTokPtr; - -// ---------------------------------------------------------------------- -// StringTok -// ---------------------------------------------------------------------- - -class SLICE_API StringTok : public GrammarBase -{ -public: - - StringTok() { } - std::string v; -}; - -// ---------------------------------------------------------------------- -// StringListTok -// ---------------------------------------------------------------------- - -class SLICE_API StringListTok : public GrammarBase -{ -public: - - StringListTok() { } - StringList v; -}; - -// ---------------------------------------------------------------------- -// TypeStringTok -// ---------------------------------------------------------------------- - -class SLICE_API TypeStringTok : public GrammarBase -{ -public: - - TypeStringTok() { } - TypeString v; -}; - -// ---------------------------------------------------------------------- -// TypeStringListTok -// ---------------------------------------------------------------------- - -class SLICE_API TypeStringListTok : public GrammarBase -{ -public: - - TypeStringListTok() { } - TypeStringList v; -}; - -// ---------------------------------------------------------------------- -// BoolTok -// ---------------------------------------------------------------------- - -class SLICE_API BoolTok : public GrammarBase -{ -public: - - BoolTok() { } - bool v; -}; - -// ---------------------------------------------------------------------- -// ExceptionListTok -// ---------------------------------------------------------------------- - -class SLICE_API ExceptionListTok : public GrammarBase -{ -public: - - ExceptionListTok() { } - ExceptionList v; -}; - -// ---------------------------------------------------------------------- -// ClassListTok -// ---------------------------------------------------------------------- - -class SLICE_API ClassListTok : public GrammarBase -{ -public: - - ClassListTok() { } - ClassList v; -}; - -// ---------------------------------------------------------------------- -// EnumeratorListTok -// ---------------------------------------------------------------------- - -class SLICE_API EnumeratorListTok : public GrammarBase -{ -public: - - EnumeratorListTok() { } - EnumeratorList v; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef SLICE_GRAMMER_UTIL_H
+#define SLICE_GRAMMER_UTIL_H
+
+#include <Slice/Parser.h>
+
+namespace Slice
+{
+
+class StringTok;
+class StringListTok;
+class TypeStringTok;
+class TypeStringListTok;
+class BoolTok;
+class ExceptionListTok;
+class ClassListTok;
+class EnumeratorListTok;
+
+typedef ::IceUtil::Handle<StringTok> StringTokPtr;
+typedef ::IceUtil::Handle<StringListTok> StringListTokPtr;
+typedef ::IceUtil::Handle<TypeStringTok> TypeStringTokPtr;
+typedef ::IceUtil::Handle<TypeStringListTok> TypeStringListTokPtr;
+typedef ::IceUtil::Handle<BoolTok> BoolTokPtr;
+typedef ::IceUtil::Handle<ExceptionListTok> ExceptionListTokPtr;
+typedef ::IceUtil::Handle<ClassListTok> ClassListTokPtr;
+typedef ::IceUtil::Handle<EnumeratorListTok> EnumeratorListTokPtr;
+
+// ----------------------------------------------------------------------
+// StringTok
+// ----------------------------------------------------------------------
+
+class SLICE_API StringTok : public GrammarBase
+{
+public:
+
+ StringTok() { }
+ std::string v;
+};
+
+// ----------------------------------------------------------------------
+// StringListTok
+// ----------------------------------------------------------------------
+
+class SLICE_API StringListTok : public GrammarBase
+{
+public:
+
+ StringListTok() { }
+ StringList v;
+};
+
+// ----------------------------------------------------------------------
+// TypeStringTok
+// ----------------------------------------------------------------------
+
+class SLICE_API TypeStringTok : public GrammarBase
+{
+public:
+
+ TypeStringTok() { }
+ TypeString v;
+};
+
+// ----------------------------------------------------------------------
+// TypeStringListTok
+// ----------------------------------------------------------------------
+
+class SLICE_API TypeStringListTok : public GrammarBase
+{
+public:
+
+ TypeStringListTok() { }
+ TypeStringList v;
+};
+
+// ----------------------------------------------------------------------
+// BoolTok
+// ----------------------------------------------------------------------
+
+class SLICE_API BoolTok : public GrammarBase
+{
+public:
+
+ BoolTok() { }
+ bool v;
+};
+
+// ----------------------------------------------------------------------
+// ExceptionListTok
+// ----------------------------------------------------------------------
+
+class SLICE_API ExceptionListTok : public GrammarBase
+{
+public:
+
+ ExceptionListTok() { }
+ ExceptionList v;
+};
+
+// ----------------------------------------------------------------------
+// ClassListTok
+// ----------------------------------------------------------------------
+
+class SLICE_API ClassListTok : public GrammarBase
+{
+public:
+
+ ClassListTok() { }
+ ClassList v;
+};
+
+// ----------------------------------------------------------------------
+// EnumeratorListTok
+// ----------------------------------------------------------------------
+
+class SLICE_API EnumeratorListTok : public GrammarBase
+{
+public:
+
+ EnumeratorListTok() { }
+ EnumeratorList v;
+};
+
+}
+
+#endif
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 7b69646e53b..3cc2450da05 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -49,7 +49,7 @@ Slice::JavaGenerator::open(const string& absolute) assert(_out == 0); string::size_type pos = absolute.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { package = absolute.substr(0, pos); file = absolute.substr(pos + 1); @@ -62,12 +62,12 @@ Slice::JavaGenerator::open(const string& absolute) string::size_type start = 0; do { - if (!path.empty()) + if(!path.empty()) { path += "/"; } pos = dir.find('.', start); - if (pos != string::npos) + if(pos != string::npos) { path += dir.substr(start, pos - start); start = pos + 1; @@ -80,7 +80,7 @@ Slice::JavaGenerator::open(const string& absolute) struct stat st; int result; result = stat(path.c_str(), &st); - if (result == 0) + if(result == 0) { continue; } @@ -89,14 +89,14 @@ Slice::JavaGenerator::open(const string& absolute) #else result = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); #endif - if (result != 0) + if(result != 0) { cerr << "can't create directory `" << path << "': " << strerror(errno) << endl; return false; } } - while (pos != string::npos); + while(pos != string::npos); } else { @@ -107,14 +107,14 @@ Slice::JavaGenerator::open(const string& absolute) // // Open class file // - if (!path.empty()) + if(!path.empty()) { path += "/"; } path += file; _out = new Output(); _out->open(path.c_str()); - if (!(*_out)) + if(!(*_out)) { cerr << "can't open `" << path << "' for writing: " << strerror(errno) << endl; @@ -124,7 +124,7 @@ Slice::JavaGenerator::open(const string& absolute) printHeader(); - if (!package.empty()) + if(!package.empty()) { *_out << sp << nl << "package " << package << ';'; } @@ -170,17 +170,17 @@ Slice::JavaGenerator::fixKwd(const string& name) const int i = 0; int j = sizeof(keywords) / sizeof(const char*); - while (i < j) + while(i < j) { int mid = (i + j) / 2; string str = keywords[mid]; int n = str.compare(name); - if (n == 0) + if(n == 0) { string result = "_" + name; return result; } - else if (n > 0) + else if(n > 0) { j = mid; } @@ -202,7 +202,7 @@ Slice::JavaGenerator::getAbsolute(const string& scoped, string result; string::size_type start = 0; - if (!scope.empty()) + if(!scope.empty()) { // // Only remove the scope if the resulting symbol is unscoped. @@ -212,10 +212,10 @@ Slice::JavaGenerator::getAbsolute(const string& scoped, // scope=::A, scoped=::A::B::C, result=::A::B::C // string::size_type scopeSize = scope.size(); - if (scoped.compare(0, scopeSize, scope) == 0) + if(scoped.compare(0, scopeSize, scope) == 0) { start = scoped.find(':', scopeSize); - if (start == string::npos) + if(start == string::npos) { start = scopeSize; } @@ -229,7 +229,7 @@ Slice::JavaGenerator::getAbsolute(const string& scoped, // // Skip leading "::" // - if (scoped[start] == ':') + if(scoped[start] == ':') { assert(scoped[start + 1] == ':'); start += 2; @@ -243,7 +243,7 @@ Slice::JavaGenerator::getAbsolute(const string& scoped, { pos = scoped.find(':', start); string fix; - if (pos == string::npos) + if(pos == string::npos) { fix = prefix + fixKwd(scoped.substr(start)) + suffix; } @@ -254,15 +254,15 @@ Slice::JavaGenerator::getAbsolute(const string& scoped, start = pos + 2; } - if (!result.empty()) + if(!result.empty()) { result += "."; } result += fix; } - while (pos != string::npos); + while(pos != string::npos); - if (!_package.empty()) + if(!_package.empty()) { return _package + "." + result; } @@ -307,16 +307,16 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, "Ice.LocalObjectHolder" }; - if (!type) + if(!type) { assert(mode == TypeModeReturn); return "void"; } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - if (mode == TypeModeOut) + if(mode == TypeModeOut) { return builtinHolderTable[builtin->kind()]; } @@ -327,10 +327,10 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { string result = getAbsolute(cl->scoped(), scope); - if (mode == TypeModeOut) + if(mode == TypeModeOut) { result += "Holder"; } @@ -338,10 +338,10 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } ProxyPtr proxy = ProxyPtr::dynamicCast(type); - if (proxy) + if(proxy) { string result = getAbsolute(proxy->_class()->scoped() + "Prx", scope); - if (mode == TypeModeOut) + if(mode == TypeModeOut) { result += "Holder"; } @@ -349,9 +349,9 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } DictionaryPtr dict = DictionaryPtr::dynamicCast(type); - if (dict) + if(dict) { - if (mode == TypeModeOut) + if(mode == TypeModeOut) { return getAbsolute(dict->scoped(), scope) + "Holder"; } @@ -362,21 +362,21 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { - if (mode == TypeModeOut) + if(mode == TypeModeOut) { return getAbsolute(seq->scoped(), scope) + "Holder"; } else { string listType = findMetaData(metaData); - if (listType.empty()) + if(listType.empty()) { list<string> l = seq->getMetaData(); listType = findMetaData(l); } - if (!listType.empty()) + if(!listType.empty()) { return listType; } @@ -389,9 +389,9 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, } ContainedPtr contained = ContainedPtr::dynamicCast(type); - if (contained) + if(contained) { - if (mode == TypeModeOut) + if(mode == TypeModeOut) { return getAbsolute(contained->scoped(), scope) + "Holder"; } @@ -416,7 +416,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { string stream = marshal ? "__os" : "__is"; string v; - if (holder) + if(holder) { v = param + ".value"; } @@ -426,13 +426,13 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - switch (builtin->kind()) + switch(builtin->kind()) { case Builtin::KindByte: { - if (marshal) + if(marshal) { out << nl << stream << ".writeByte(" << v << ");"; } @@ -444,7 +444,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindBool: { - if (marshal) + if(marshal) { out << nl << stream << ".writeBool(" << v << ");"; } @@ -456,7 +456,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindShort: { - if (marshal) + if(marshal) { out << nl << stream << ".writeShort(" << v << ");"; } @@ -468,7 +468,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindInt: { - if (marshal) + if(marshal) { out << nl << stream << ".writeInt(" << v << ");"; } @@ -480,7 +480,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindLong: { - if (marshal) + if(marshal) { out << nl << stream << ".writeLong(" << v << ");"; } @@ -492,7 +492,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindFloat: { - if (marshal) + if(marshal) { out << nl << stream << ".writeFloat(" << v << ");"; } @@ -504,7 +504,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindDouble: { - if (marshal) + if(marshal) { out << nl << stream << ".writeDouble(" << v << ");"; } @@ -516,7 +516,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindString: { - if (marshal) + if(marshal) { out << nl << stream << ".writeString(" << v << ");"; } @@ -528,7 +528,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindObject: { - if (marshal) + if(marshal) { out << nl << stream << ".writeObject(" << v << ");"; } @@ -540,7 +540,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } case Builtin::KindObjectProxy: { - if (marshal) + if(marshal) { out << nl << stream << ".writeProxy(" << v << ");"; } @@ -560,10 +560,10 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } ProxyPtr prx = ProxyPtr::dynamicCast(type); - if (prx) + if(prx) { string typeS = typeToString(type, TypeModeIn, scope); - if (marshal) + if(marshal) { out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");"; } @@ -575,9 +575,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { - if (marshal) + if(marshal) { out << nl << stream << ".writeObject(" << v << ");"; } @@ -585,7 +585,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { string typeS = typeToString(type, TypeModeIn, scope); ClassDefPtr def = cl->definition(); - if (def && !def->isAbstract()) + if(def && !def->isAbstract()) { out << nl << v << " = (" << typeS << ')' << stream << ".readObject(" << typeS << ".ice_staticId(), " << typeS << "._factory);"; @@ -599,9 +599,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } StructPtr st = StructPtr::dynamicCast(type); - if (st) + if(st) { - if (marshal) + if(marshal) { out << nl << v << ".__write(" << stream << ");"; } @@ -615,9 +615,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } EnumPtr en = EnumPtr::dynamicCast(type); - if (en) + if(en) { - if (marshal) + if(marshal) { out << nl << v << ".__write(" << stream << ");"; } @@ -630,7 +630,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { writeSequenceMarshalUnmarshalCode(out, scope, seq, v, marshal, iter, true, metaData); return; @@ -639,7 +639,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); assert(constructed); string typeS = getAbsolute(constructed->scoped(), scope); - if (marshal) + if(marshal) { out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; } @@ -679,14 +679,14 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, // string listType = findMetaData(metaData); list<string> typeMetaData = seq->getMetaData(); - if (listType.empty()) + if(listType.empty()) { listType = findMetaData(typeMetaData); } else { string s = findMetaData(typeMetaData); - if (listType != s) + if(listType != s) { useHelper = false; } @@ -695,10 +695,10 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, // // If we can use the sequence's helper, it's easy. // - if (useHelper) + if(useHelper) { string typeS = getAbsolute(seq->scoped(), scope); - if (marshal) + if(marshal) { out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; } @@ -715,7 +715,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, int depth = 0; TypePtr origContent = seq->type(); SequencePtr s = SequencePtr::dynamicCast(origContent); - while (s) + while(s) { depth++; origContent = s->type(); @@ -723,12 +723,12 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } string origContentS = typeToString(origContent, TypeModeIn, scope); - if (!listType.empty()) + if(!listType.empty()) { BuiltinPtr b = BuiltinPtr::dynamicCast(seq->type()); - if (b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) + if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) { - if (marshal) + if(marshal) { out << nl << stream << ".writeSize(" << v << ".size());"; ostringstream o; @@ -736,10 +736,10 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, string it = o.str(); iter++; out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();"; - out << nl << "while (" << it << ".hasNext())"; + out << nl << "while(" << it << ".hasNext())"; out << sb; - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -805,16 +805,16 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, ostringstream o; o << origContentS << "[]"; int d = depth; - while (d--) + while(d--) { o << "[]"; } - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readByteSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Byte(__seq" << iter << "[__i" << iter << "]));"; @@ -825,7 +825,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindBool: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readByteSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(__seq" << iter << "[__i" << iter @@ -837,7 +837,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindShort: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readShortSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Short(__seq" << iter << "[__i" << iter << "]));"; @@ -848,7 +848,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindInt: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readIntSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Integer(__seq" << iter << "[__i" << iter << "]));"; @@ -859,7 +859,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindLong: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readLongSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Long(__seq" << iter << "[__i" << iter << "]));"; @@ -870,7 +870,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindFloat: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readFloatSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Float(__seq" << iter << "[__i" << iter << "]));"; @@ -881,7 +881,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindDouble: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readDoubleSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Double(__seq" << iter << "[__i" << iter << "]));"; @@ -892,7 +892,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindString: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readStringSeq();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(__seq" << iter << "[__i" << iter << "]);"; @@ -913,7 +913,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { string typeS = getAbsolute(seq->scoped(), scope); - if (marshal) + if(marshal) { out << nl << stream << ".writeSize(" << v << ".size());"; ostringstream o; @@ -921,7 +921,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, iter++; string it = o.str(); out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();"; - out << nl << "while (" << it << ".hasNext())"; + out << nl << "while(" << it << ".hasNext())"; out << sb; out << nl << origContentS << " __elem = (" << origContentS << ")" << it << ".next();"; writeMarshalUnmarshalCode(out, scope, seq->type(), "__elem", true, iter, false); @@ -931,7 +931,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { out << nl << v << " = new " << listType << "();"; out << nl << "int __len" << iter << " = " << stream << ".readSize();"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter << "++)"; out << sb; out << nl << origContentS << " __elem;"; @@ -945,13 +945,13 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, else { BuiltinPtr b = BuiltinPtr::dynamicCast(seq->type()); - if (b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) + if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { - if (marshal) + if(marshal) { out << nl << stream << ".writeByteSeq(" << v << ");"; } @@ -963,7 +963,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindBool: { - if (marshal) + if(marshal) { out << nl << stream << ".writeBoolSeq(" << v << ");"; } @@ -975,7 +975,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindShort: { - if (marshal) + if(marshal) { out << nl << stream << ".writeShortSeq(" << v << ");"; } @@ -987,7 +987,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindInt: { - if (marshal) + if(marshal) { out << nl << stream << ".writeIntSeq(" << v << ");"; } @@ -999,7 +999,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindLong: { - if (marshal) + if(marshal) { out << nl << stream << ".writeLongSeq(" << v << ");"; } @@ -1011,7 +1011,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindFloat: { - if (marshal) + if(marshal) { out << nl << stream << ".writeFloatSeq(" << v << ");"; } @@ -1023,7 +1023,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindDouble: { - if (marshal) + if(marshal) { out << nl << stream << ".writeDoubleSeq(" << v << ");"; } @@ -1035,7 +1035,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindString: { - if (marshal) + if(marshal) { out << nl << stream << ".writeStringSeq(" << v << ");"; } @@ -1056,10 +1056,10 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } else { - if (marshal) + if(marshal) { out << nl << stream << ".writeSize(" << v << ".length);"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter << "++)"; out << sb; ostringstream o; @@ -1073,12 +1073,12 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << nl << "int __len" << iter << " = " << stream << ".readSize();"; out << nl << v << " = new " << origContentS << "[__len" << iter << "]"; int d = depth; - while (d--) + while(d--) { out << "[]"; } out << ';'; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter << "++)"; out << sb; ostringstream o; @@ -1104,7 +1104,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, { string stream = marshal ? "__os" : "__is"; string v; - if (holder) + if(holder) { v = param + ".value"; } @@ -1114,7 +1114,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } string name; - if (tn.empty()) + if(tn.empty()) { name = "\"" + param + "\""; } @@ -1124,13 +1124,13 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - switch (builtin->kind()) + switch(builtin->kind()) { case Builtin::KindByte: { - if (marshal) + if(marshal) { out << nl << stream << ".writeByte(" << name << ", " << v << ");"; } @@ -1142,7 +1142,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindBool: { - if (marshal) + if(marshal) { out << nl << stream << ".writeBool(" << name << ", " << v << ");"; } @@ -1154,7 +1154,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindShort: { - if (marshal) + if(marshal) { out << nl << stream << ".writeShort(" << name << ", " << v << ");"; } @@ -1166,7 +1166,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindInt: { - if (marshal) + if(marshal) { out << nl << stream << ".writeInt(" << name << ", " << v << ");"; } @@ -1178,7 +1178,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindLong: { - if (marshal) + if(marshal) { out << nl << stream << ".writeLong(" << name << ", " << v << ");"; } @@ -1190,7 +1190,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindFloat: { - if (marshal) + if(marshal) { out << nl << stream << ".writeFloat(" << name << ", " << v << ");"; } @@ -1202,7 +1202,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindDouble: { - if (marshal) + if(marshal) { out << nl << stream << ".writeDouble(" << name << ", " << v << ");"; } @@ -1214,7 +1214,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindString: { - if (marshal) + if(marshal) { out << nl << stream << ".writeString(" << name << ", " << v << ");"; } @@ -1226,7 +1226,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindObject: { - if (marshal) + if(marshal) { out << nl << stream << ".writeObject(" << name << ", " << v << ");"; } @@ -1238,7 +1238,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } case Builtin::KindObjectProxy: { - if (marshal) + if(marshal) { out << nl << stream << ".writeProxy(" << name << ", " << v << ");"; } @@ -1258,10 +1258,10 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } ProxyPtr prx = ProxyPtr::dynamicCast(type); - if (prx) + if(prx) { string typeS = typeToString(type, TypeModeIn, scope); - if (marshal) + if(marshal) { out << nl << typeS << "Helper.ice_marshal(" << name << ", " << stream << ", " << v << ");"; } @@ -1273,9 +1273,9 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { - if (marshal) + if(marshal) { out << nl << stream << ".writeObject(" << name << ", " << v << ");"; } @@ -1283,7 +1283,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, { string typeS = typeToString(type, TypeModeIn, scope); ClassDefPtr def = cl->definition(); - if (def && !def->isAbstract()) + if(def && !def->isAbstract()) { out << nl << v << " = (" << typeS << ')' << stream << ".readObject(" << name << ", " << typeS << ".ice_staticId(), " << typeS << "._factory);"; @@ -1297,9 +1297,9 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } StructPtr st = StructPtr::dynamicCast(type); - if (st) + if(st) { - if (marshal) + if(marshal) { out << nl << v << ".ice_marshal(" << name << ", " << stream << ");"; } @@ -1313,9 +1313,9 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } EnumPtr en = EnumPtr::dynamicCast(type); - if (en) + if(en) { - if (marshal) + if(marshal) { out << nl << v << ".ice_marshal(" << name << ", " << stream << ");"; } @@ -1328,7 +1328,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { writeGenericSequenceMarshalUnmarshalCode(out, scope, seq, name, v, marshal, iter, true, metaData); return; @@ -1337,7 +1337,7 @@ Slice::JavaGenerator::writeGenericMarshalUnmarshalCode(Output& out, ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); assert(constructed); string typeS = getAbsolute(constructed->scoped(), scope); - if (marshal) + if(marshal) { out << nl << typeS << "Helper.ice_marshal(" << name << ", " << stream << ", " << v << ");"; } @@ -1378,14 +1378,14 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, // string listType = findMetaData(metaData); list<string> typeMetaData = seq->getMetaData(); - if (listType.empty()) + if(listType.empty()) { listType = findMetaData(typeMetaData); } else { string s = findMetaData(typeMetaData); - if (listType != s) + if(listType != s) { useHelper = false; } @@ -1394,10 +1394,10 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, // // If we can use the sequence's helper, it's easy. // - if (useHelper) + if(useHelper) { string typeS = getAbsolute(seq->scoped(), scope); - if (marshal) + if(marshal) { out << nl << typeS << "Helper.ice_marshal(" << name << ", " << stream << ", " << v << ");"; } @@ -1414,7 +1414,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, int depth = 0; TypePtr origContent = seq->type(); SequencePtr s = SequencePtr::dynamicCast(origContent); - while (s) + while(s) { depth++; origContent = s->type(); @@ -1422,12 +1422,12 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } string origContentS = typeToString(origContent, TypeModeIn, scope); - if (!listType.empty()) + if(!listType.empty()) { BuiltinPtr b = BuiltinPtr::dynamicCast(seq->type()); - if (b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) + if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) { - if (marshal) + if(marshal) { out << nl << stream << ".startWriteSequence(" << name << ", " << v << ".size());"; ostringstream o; @@ -1435,10 +1435,10 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, string it = o.str(); iter++; out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();"; - out << nl << "while (" << it << ".hasNext())"; + out << nl << "while(" << it << ".hasNext())"; out << sb; - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -1505,16 +1505,16 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, ostringstream o; o << origContentS << "[]"; int d = depth; - while (d--) + while(d--) { o << "[]"; } - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readByteSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Byte(__seq" << iter << "[__i" << iter << "]));"; @@ -1525,7 +1525,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindBool: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readByteSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(__seq" << iter << "[__i" << iter @@ -1537,7 +1537,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindShort: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readShortSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Short(__seq" << iter << "[__i" << iter << "]));"; @@ -1548,7 +1548,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindInt: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readIntSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Integer(__seq" << iter << "[__i" << iter << "]));"; @@ -1559,7 +1559,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindLong: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readLongSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Long(__seq" << iter << "[__i" << iter << "]));"; @@ -1570,7 +1570,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, case Builtin::KindFloat: { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readFloatSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Float(__seq" << iter << "[__i" << iter << "]));"; @@ -1582,7 +1582,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readDoubleSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(new java.lang.Double(__seq" << iter << "[__i" << iter << "]));"; @@ -1594,7 +1594,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, { out << nl << o.str() << " __seq" << iter << " = " << stream << ".readStringSeq(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __seq" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __seq" << iter << ".length; __i" << iter << "++)"; out << sb; out << nl << v << ".add(__seq" << iter << "[__i" << iter << "]);"; @@ -1615,7 +1615,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, else { string typeS = getAbsolute(seq->scoped(), scope); - if (marshal) + if(marshal) { out << nl << stream << ".startWriteSequence(" << name << ", " << v << ".size());"; ostringstream o; @@ -1623,7 +1623,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, iter++; string it = o.str(); out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();"; - out << nl << "while (" << it << ".hasNext())"; + out << nl << "while(" << it << ".hasNext())"; out << sb; out << nl << origContentS << " __elem = (" << origContentS << ")" << it << ".next();"; writeGenericMarshalUnmarshalCode(out, scope, seq->type(), "\"e\"", "__elem", true, iter, false); @@ -1634,7 +1634,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, { out << nl << v << " = new " << listType << "();"; out << nl << "int __len" << iter << " = " << stream << ".startReadSequence(" << name << ");"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter << "++)"; out << sb; out << nl << origContentS << " __elem;"; @@ -1648,13 +1648,13 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, else { BuiltinPtr b = BuiltinPtr::dynamicCast(seq->type()); - if (b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) + if(b && b->kind() != Builtin::KindObject && b->kind() != Builtin::KindObjectProxy) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { - if (marshal) + if(marshal) { out << nl << stream << ".writeByteSeq(" << name << ", " << v << ");"; } @@ -1666,7 +1666,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindBool: { - if (marshal) + if(marshal) { out << nl << stream << ".writeBoolSeq(" << name << ", " << v << ");"; } @@ -1678,7 +1678,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindShort: { - if (marshal) + if(marshal) { out << nl << stream << ".writeShortSeq(" << name << ", " << v << ");"; } @@ -1690,7 +1690,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindInt: { - if (marshal) + if(marshal) { out << nl << stream << ".writeIntSeq(" << name << ", " << v << ");"; } @@ -1702,7 +1702,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindLong: { - if (marshal) + if(marshal) { out << nl << stream << ".writeLongSeq(" << name << ", " << v << ");"; } @@ -1714,7 +1714,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindFloat: { - if (marshal) + if(marshal) { out << nl << stream << ".writeFloatSeq(" << name << ", " << v << ");"; } @@ -1726,7 +1726,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindDouble: { - if (marshal) + if(marshal) { out << nl << stream << ".writeDoubleSeq(" << name << ", " << v << ");"; } @@ -1738,7 +1738,7 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, } case Builtin::KindString: { - if (marshal) + if(marshal) { out << nl << stream << ".writeStringSeq(" << name << ", " << v << ");"; } @@ -1760,10 +1760,10 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, else { string typeS = getAbsolute(seq->scoped(), scope); - if (marshal) + if(marshal) { out << nl << stream << ".startWriteSequence(" << name << ", " << v << ".length);"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter << "++)"; out << sb; ostringstream o; @@ -1778,12 +1778,12 @@ Slice::JavaGenerator::writeGenericSequenceMarshalUnmarshalCode(Output& out, out << nl << "int __len" << iter << " = " << stream << ".startReadSequence(" << name << ");"; out << nl << v << " = new " << origContentS << "[__len" << iter << "]"; int d = depth; - while (d--) + while(d--) { out << "[]"; } out << ';'; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter << "++)"; out << sb; ostringstream o; @@ -1821,9 +1821,9 @@ string Slice::JavaGenerator::findMetaData(const list<string>& metaData) { static const string prefix = "java:"; - for (list<string>::const_iterator q = metaData.begin(); q != metaData.end(); ++q) + for(list<string>::const_iterator q = metaData.begin(); q != metaData.end(); ++q) { - if ((*q).find(prefix) == 0) + if((*q).find(prefix) == 0) { return (*q).substr(prefix.size()); } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 8fd318910e1..4bf0998c922 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -160,7 +160,7 @@ Slice::Contained::Contained(const ContainerPtr& container, const string& name) : _name(name) { ContainedPtr cont = ContainedPtr::dynamicCast(_container); - if (cont) + if(cont) { _scoped = cont->scoped(); } @@ -188,10 +188,10 @@ ModulePtr Slice::Container::createModule(const string& name) { ContainedList matches = _unit->findContents(thisScope() + name); - for (ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) + for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { ModulePtr module = ModulePtr::dynamicCast(*p); - if (module) + if(module) { continue; // Reopening modules is permissible } @@ -212,12 +212,12 @@ ClassDefPtr Slice::Container::createClassDef(const string& name, bool intf, const ClassList& bases, bool local) { ContainedList matches = _unit->findContents(thisScope() + name); - for (ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) + for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*p); - if (decl) + if(decl) { - if (checkInterfaceAndLocal(name, false, intf, decl->isInterface(), local, decl->isLocal())) + if(checkInterfaceAndLocal(name, false, intf, decl->isInterface(), local, decl->isLocal())) { continue; } @@ -226,16 +226,16 @@ Slice::Container::createClassDef(const string& name, bool intf, const ClassList& } ClassDefPtr def = ClassDefPtr::dynamicCast(*p); - if (def) + if(def) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { def->updateIncludeLevel(); return def; } string msg = "redefinition of "; - if (intf) + if(intf) { msg += "interface"; } @@ -253,7 +253,7 @@ Slice::Container::createClassDef(const string& name, bool intf, const ClassList& string msg = "redefinition of `"; msg += name; msg += "' as "; - if (intf) + if(intf) { msg += "interface"; } @@ -268,7 +268,7 @@ Slice::Container::createClassDef(const string& name, bool intf, const ClassList& ClassDefPtr def = new ClassDef(this, name, intf, bases, local); _contents.push_back(def); - for (ContainedList::const_iterator q = matches.begin(); q != matches.end(); ++q) + for(ContainedList::const_iterator q = matches.begin(); q != matches.end(); ++q) { ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q); decl->_definition = def; @@ -291,12 +291,12 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) ClassDefPtr def; ContainedList matches = _unit->findContents(thisScope() + name); - for (ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) + for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { ClassDefPtr clDef = ClassDefPtr::dynamicCast(*p); - if (clDef) + if(clDef) { - if (checkInterfaceAndLocal(name, true, intf, clDef->isInterface(), local, clDef->isLocal())) + if(checkInterfaceAndLocal(name, true, intf, clDef->isInterface(), local, clDef->isLocal())) { assert(!def); def = clDef; @@ -307,9 +307,9 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) } ClassDeclPtr clDecl = ClassDeclPtr::dynamicCast(*p); - if (clDecl) + if(clDecl) { - if (checkInterfaceAndLocal(name, false, intf, clDecl->isInterface(), local, clDecl->isLocal())) + if(checkInterfaceAndLocal(name, false, intf, clDecl->isInterface(), local, clDecl->isLocal())) { continue; } @@ -320,7 +320,7 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) string msg = "declaration of already defined `"; msg += name; msg += "' as "; - if (intf) + if(intf) { msg += "interface"; } @@ -337,12 +337,12 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) // have a declaration for the class in this container, we don't // create another one. // - for (ContainedList::const_iterator q = _contents.begin(); q != _contents.end(); ++q) + for(ContainedList::const_iterator q = _contents.begin(); q != _contents.end(); ++q) { - if ((*q)->name() == name) + if((*q)->name() == name) { ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q); - if (decl) + if(decl) { return decl; } @@ -354,7 +354,7 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) ClassDeclPtr decl = new ClassDecl(this, name, intf, local); _contents.push_back(decl); - if (def) + if(def) { decl->_definition = def; } @@ -366,12 +366,12 @@ ExceptionPtr Slice::Container::createException(const string& name, const ExceptionPtr& base, bool local) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { ExceptionPtr p = ExceptionPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { p->updateIncludeLevel(); return p; @@ -400,12 +400,12 @@ StructPtr Slice::Container::createStruct(const string& name, bool local) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { StructPtr p = StructPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { p->updateIncludeLevel(); return p; @@ -434,12 +434,12 @@ SequencePtr Slice::Container::createSequence(const string& name, const TypePtr& type, bool local) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { SequencePtr p = SequencePtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -467,12 +467,12 @@ DictionaryPtr Slice::Container::createDictionary(const string& name, const TypePtr& keyType, const TypePtr& valueType, bool local) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { DictionaryPtr p = DictionaryPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -500,12 +500,12 @@ EnumPtr Slice::Container::createEnum(const string& name, bool local) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { EnumPtr p = EnumPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -533,12 +533,12 @@ EnumeratorPtr Slice::Container::createEnumerator(const string& name) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { EnumeratorPtr p = EnumeratorPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -593,9 +593,9 @@ Slice::Container::lookupType(const string& scoped, bool printError) "LocalObject" }; - for (unsigned int i = 0; i < sizeof(builtinTable) / sizeof(const char*); ++i) + for(unsigned int i = 0; i < sizeof(builtinTable) / sizeof(const char*); ++i) { - if (sc == builtinTable[i]) + if(sc == builtinTable[i]) { TypeList result; result.push_back(_unit->builtin(static_cast<Builtin::Kind>(i))); @@ -625,30 +625,30 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) // // Absolute scoped name? // - if (sc.size() >= 2 && sc[0] == ':') + if(sc.size() >= 2 && sc[0] == ':') { return _unit->lookupTypeNoBuiltin(sc.substr(2), printError); } TypeList results; - if (sc.rfind('*') == sc.length() - 1) + if(sc.rfind('*') == sc.length() - 1) { // // Proxies. // ContainedList matches = _unit->findContents(thisScope() + sc.substr(0, sc.length() - 1)); - for (ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) + for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { ClassDefPtr def = ClassDefPtr::dynamicCast(*p); - if (def) + if(def) { continue; // Ignore class definitions } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p); - if (!cl) + if(!cl) { - if (printError) + if(printError) { string msg = "`"; msg += sc; @@ -666,18 +666,18 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) // Non-Proxies. // ContainedList matches = _unit->findContents(thisScope() + sc); - for (ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) + for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { ClassDefPtr def = ClassDefPtr::dynamicCast(*p); - if (def) + if(def) { continue; // Ignore class definitions } ExceptionPtr ex = ExceptionPtr::dynamicCast(*p); - if (ex) + if(ex) { - if (printError) + if(printError) { string msg = "`"; msg += sc; @@ -688,9 +688,9 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) } TypePtr type = TypePtr::dynamicCast(*p); - if (!type) + if(!type) { - if (printError) + if(printError) { string msg = "`"; msg += sc; @@ -703,12 +703,12 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) } } - if (results.empty()) + if(results.empty()) { ContainedPtr contained = ContainedPtr::dynamicCast(this); - if (!contained) + if(!contained) { - if (printError) + if(printError) { string msg = "`"; msg += sc; @@ -741,27 +741,27 @@ Slice::Container::lookupContained(const string& scoped, bool printError) // // Absolute scoped name? // - if (sc.size() >= 2 && sc[0] == ':') + if(sc.size() >= 2 && sc[0] == ':') { return _unit->lookupContained(sc.substr(2), printError); } ContainedList matches = _unit->findContents(thisScope() + sc); ContainedList results; - for (ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) + for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { - if (!ClassDefPtr::dynamicCast(*p)) // Ignore class definitions + if(!ClassDefPtr::dynamicCast(*p)) // Ignore class definitions { results.push_back(*p); } } - if (results.empty()) + if(results.empty()) { ContainedPtr contained = ContainedPtr::dynamicCast(this); - if (!contained) + if(!contained) { - if (printError) + if(printError) { string msg = "`"; msg += sc; @@ -782,18 +782,18 @@ ExceptionPtr Slice::Container::lookupException(const string& scoped, bool printError) { ContainedList contained = lookupContained(scoped, printError); - if (contained.empty()) + if(contained.empty()) { return 0; } ExceptionList exceptions; - for (ContainedList::iterator p = contained.begin(); p != contained.end(); ++p) + for(ContainedList::iterator p = contained.begin(); p != contained.end(); ++p) { ExceptionPtr ex = ExceptionPtr::dynamicCast(*p); - if (!ex) + if(!ex) { - if (printError) + if(printError) { string msg = "`"; msg += scoped; @@ -812,10 +812,10 @@ ModuleList Slice::Container::modules() { ModuleList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { ModulePtr q = ModulePtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -827,10 +827,10 @@ ClassList Slice::Container::classes() { ClassList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { ClassDefPtr q = ClassDefPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -842,10 +842,10 @@ ExceptionList Slice::Container::exceptions() { ExceptionList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { ExceptionPtr q = ExceptionPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -857,10 +857,10 @@ StructList Slice::Container::structs() { StructList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { StructPtr q = StructPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -872,10 +872,10 @@ SequenceList Slice::Container::sequences() { SequenceList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { SequencePtr q = SequencePtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -887,10 +887,10 @@ DictionaryList Slice::Container::dictionaries() { DictionaryList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { DictionaryPtr q = DictionaryPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -902,10 +902,10 @@ EnumList Slice::Container::enums() { EnumList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { EnumPtr q = EnumPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -916,16 +916,16 @@ Slice::Container::enums() bool Slice::Container::hasNonLocalClassDecls() { - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p); - if (cl && !cl->isLocal()) + if(cl && !cl->isLocal()) { return true; } ContainerPtr container = ContainerPtr::dynamicCast(*p); - if (container && container->hasNonLocalClassDecls()) + if(container && container->hasNonLocalClassDecls()) { return true; } @@ -937,15 +937,15 @@ Slice::Container::hasNonLocalClassDecls() bool Slice::Container::hasClassDecls() { - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { - if (ClassDeclPtr::dynamicCast(*p)) + if(ClassDeclPtr::dynamicCast(*p)) { return true; } ContainerPtr container = ContainerPtr::dynamicCast(*p); - if (container && container->hasClassDecls()) + if(container && container->hasClassDecls()) { return true; } @@ -957,15 +957,15 @@ Slice::Container::hasClassDecls() bool Slice::Container::hasClassDefs() { - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { - if (ClassDefPtr::dynamicCast(*p)) + if(ClassDefPtr::dynamicCast(*p)) { return true; } ContainerPtr container = ContainerPtr::dynamicCast(*p); - if (container && container->hasClassDefs()) + if(container && container->hasClassDefs()) { return true; } @@ -977,20 +977,20 @@ Slice::Container::hasClassDefs() bool Slice::Container::hasOtherConstructedOrExceptions() { - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { - if (ConstructedPtr::dynamicCast(*p) && !ClassDeclPtr::dynamicCast(*p) && !ClassDefPtr::dynamicCast(*p)) + if(ConstructedPtr::dynamicCast(*p) && !ClassDeclPtr::dynamicCast(*p) && !ClassDefPtr::dynamicCast(*p)) { return true; } - if (ExceptionPtr::dynamicCast(*p)) + if(ExceptionPtr::dynamicCast(*p)) { return true; } ContainerPtr container = ContainerPtr::dynamicCast(*p); - if (container && container->hasOtherConstructedOrExceptions()) + if(container && container->hasOtherConstructedOrExceptions()) { return true; } @@ -1004,7 +1004,7 @@ Slice::Container::thisScope() { string s; ContainedPtr contained = ContainedPtr::dynamicCast(this); - if (contained) + if(contained) { s = contained->scoped(); } @@ -1015,26 +1015,26 @@ Slice::Container::thisScope() void Slice::Container::mergeModules() { - for (ContainedList::iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::iterator p = _contents.begin(); p != _contents.end(); ++p) { ModulePtr mod1 = ModulePtr::dynamicCast(*p); - if (!mod1) + if(!mod1) { continue; } ContainedList::iterator q = p; ++q; - while (q != _contents.end()) + while(q != _contents.end()) { ModulePtr mod2 = ModulePtr::dynamicCast(*q); - if (!mod2) + if(!mod2) { ++q; continue; } - if (mod1->name() != mod2->name()) + if(mod1->name() != mod2->name()) { ++q; continue; @@ -1042,7 +1042,7 @@ Slice::Container::mergeModules() mod1->_contents.splice(mod1->_contents.end(), mod2->_contents); - if (mod1->_comment.length() < mod2->_comment.length()) + if(mod1->_comment.length() < mod2->_comment.length()) { mod1->_comment.swap(mod2->_comment); } @@ -1066,10 +1066,10 @@ Slice::Container::sort() void Slice::Container::sortContents() { - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { ContainerPtr container = ContainerPtr::dynamicCast(*p); - if (container) + if(container) { container->sort(); container->sortContents(); @@ -1080,7 +1080,7 @@ Slice::Container::sortContents() void Slice::Container::visit(ParserVisitor* visitor) { - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { (*p)->visit(visitor); } @@ -1090,10 +1090,10 @@ void Slice::Container::containerRecDependencies(set<ConstructedPtr>& dependencies) { ContainedList::iterator p; - for (p = _contents.begin(); p != _contents.end(); ++p) + for(p = _contents.begin(); p != _contents.end(); ++p) { ConstructedPtr constructed = ConstructedPtr::dynamicCast(*p); - if (constructed && dependencies.find(constructed) != dependencies.end()) + if(constructed && dependencies.find(constructed) != dependencies.end()) { dependencies.insert(constructed); constructed->recDependencies(dependencies); @@ -1112,7 +1112,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined, bool local, bool localOther) { string definedOrDeclared; - if (defined) + if(defined) { definedOrDeclared = "defined"; } @@ -1121,7 +1121,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined, definedOrDeclared = "declared"; } - if (!intf && intfOther) + if(!intf && intfOther) { string msg = "class `"; msg += name; @@ -1132,7 +1132,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined, return false; } - if (intf && !intfOther) + if(intf && !intfOther) { string msg = "interface `"; msg += name; @@ -1143,7 +1143,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined, return false; } - if (!local && localOther) + if(!local && localOther) { string msg = "non-local `"; msg += name; @@ -1154,7 +1154,7 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined, return false; } - if (local && !localOther) + if(local && !localOther) { string msg = "local `"; msg += name; @@ -1187,12 +1187,12 @@ Slice::Module::uses(const ContainedPtr&) void Slice::Module::visit(ParserVisitor* visitor) { - if (_includeLevel > 0) + if(_includeLevel > 0) { return; } - if (visitor->visitModuleStart(this)) + if(visitor->visitModuleStart(this)) { Container::visit(visitor); visitor->visitModuleEnd(this); @@ -1276,12 +1276,12 @@ Slice::ClassDecl::visit(ParserVisitor* visitor) void Slice::ClassDecl::recDependencies(set<ConstructedPtr>& dependencies) { - if (_definition) + if(_definition) { _definition->containerRecDependencies(dependencies); ClassList bases = _definition->bases(); ClassList::iterator p; - for (p = bases.begin(); p != bases.end(); ++p) + for(p = bases.begin(); p != bases.end(); ++p) { (*p)->declaration()->recDependencies(dependencies); } @@ -1317,12 +1317,12 @@ Slice::ClassDef::createOperation(const string& name, const ExceptionList& throws) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { OperationPtr p = OperationPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -1346,11 +1346,11 @@ Slice::ClassDef::createOperation(const string& name, allParams.insert(allParams.end(), outParams.begin(), outParams.end()); TypeStringList::const_iterator p = allParams.begin(); - while (p != allParams.end()) + while(p != allParams.end()) { TypeStringList::const_iterator q = p; ++q; - while (q != allParams.end()) + while(q != allParams.end()) { // // Complain about duplicate parameters only if they are @@ -1359,7 +1359,7 @@ Slice::ClassDef::createOperation(const string& name, // signature (but the missing parameters have been reported // already). // - if (p->second == q->second && p->second != "") + if(p->second == q->second && p->second != "") { string msg = "duplicate parameter `"; msg += p->second; @@ -1373,10 +1373,10 @@ Slice::ClassDef::createOperation(const string& name, } } - if (name == this->name()) + if(name == this->name()) { string msg; - if (isInterface()) + if(isInterface()) { msg = "interface name `"; } @@ -1401,12 +1401,12 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type) assert(!isInterface()); ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -1425,10 +1425,10 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type) return 0; } - if (name == this->name()) + if(name == this->name()) { string msg; - if (isInterface()) + if(isInterface()) { msg = "interface name `"; } @@ -1467,7 +1467,7 @@ Slice::ClassDef::allBases() ClassList result = _bases; result.sort(); result.unique(); - for (ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p) + for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p) { ClassList li = (*p)->allBases(); result.merge(li); @@ -1480,10 +1480,10 @@ OperationList Slice::ClassDef::operations() { OperationList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { OperationPtr q = OperationPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -1497,7 +1497,7 @@ Slice::ClassDef::allOperations() OperationList result = operations(); result.sort(); result.unique(); - for (ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p) + for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p) { OperationList li = (*p)->allOperations(); result.merge(li); @@ -1510,10 +1510,10 @@ DataMemberList Slice::ClassDef::dataMembers() { DataMemberList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { DataMemberPtr q = DataMemberPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -1524,19 +1524,19 @@ Slice::ClassDef::dataMembers() bool Slice::ClassDef::isAbstract() { - if (isInterface() || _bases.size() > 1) // Is this an interface, or does it derive from interfaces? + if(isInterface() || _bases.size() > 1) // Is this an interface, or does it derive from interfaces? { return true; } - if (!_bases.empty() && _bases.front()->isAbstract()) + if(!_bases.empty() && _bases.front()->isAbstract()) { return true; } - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { - if (OperationPtr::dynamicCast(*p)) + if(OperationPtr::dynamicCast(*p)) { return true; } @@ -1580,12 +1580,12 @@ Slice::ClassDef::uses(const ContainedPtr&) void Slice::ClassDef::visit(ParserVisitor* visitor) { - if (_includeLevel > 0) + if(_includeLevel > 0) { return; } - if (visitor->visitClassDefStart(this)) + if(visitor->visitClassDefStart(this)) { Container::visit(visitor); visitor->visitClassDefEnd(this); @@ -1607,7 +1607,7 @@ Slice::ClassDef::ClassDef(const ContainerPtr& container, const string& name, boo // interfaces // #ifndef NDEBUG - for (ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p) + for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p) { assert(p == _bases.begin() || (*p)->isInterface()); } @@ -1646,12 +1646,12 @@ DataMemberPtr Slice::Exception::createDataMember(const string& name, const TypePtr& type) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -1670,7 +1670,7 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type) return 0; } - if (name == this->name()) + if(name == this->name()) { string msg = "exception name `"; msg += name; @@ -1688,10 +1688,10 @@ DataMemberList Slice::Exception::dataMembers() { DataMemberList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { DataMemberPtr q = DataMemberPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -1709,7 +1709,7 @@ ExceptionList Slice::Exception::allBases() { ExceptionList result; - if (_base) + if(_base) { result = _base->allBases(); result.push_front(_base); @@ -1739,12 +1739,12 @@ Slice::Exception::uses(const ContainedPtr&) void Slice::Exception::visit(ParserVisitor* visitor) { - if (_includeLevel > 0) + if(_includeLevel > 0) { return; } - if (visitor->visitExceptionStart(this)) + if(visitor->visitExceptionStart(this)) { Container::visit(visitor); visitor->visitExceptionEnd(this); @@ -1768,12 +1768,12 @@ DataMemberPtr Slice::Struct::createDataMember(const string& name, const TypePtr& type) { ContainedList matches = _unit->findContents(thisScope() + name); - if (!matches.empty()) + if(!matches.empty()) { DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front()); - if (p) + if(p) { - if (_unit->ignRedefs()) + if(_unit->ignRedefs()) { return p; } @@ -1792,7 +1792,7 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type) return 0; } - if (name == this->name()) + if(name == this->name()) { string msg = "struct name `"; msg += name; @@ -1801,7 +1801,7 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type) return 0; } - if (type.get() == this) + if(type.get() == this) { string msg = "struct `"; msg += name; @@ -1819,10 +1819,10 @@ DataMemberList Slice::Struct::dataMembers() { DataMemberList result; - for (ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) + for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p) { DataMemberPtr q = DataMemberPtr::dynamicCast(*p); - if (q) + if(q) { result.push_back(q); } @@ -1845,12 +1845,12 @@ Slice::Struct::uses(const ContainedPtr&) void Slice::Struct::visit(ParserVisitor* visitor) { - if (_includeLevel > 0) + if(_includeLevel > 0) { return; } - if (visitor->visitStructStart(this)) + if(visitor->visitStructStart(this)) { Container::visit(visitor); visitor->visitStructEnd(this); @@ -1892,7 +1892,7 @@ bool Slice::Sequence::uses(const ContainedPtr& contained) { ContainedPtr contained2 = ContainedPtr::dynamicCast(_type); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -1910,7 +1910,7 @@ void Slice::Sequence::recDependencies(set<ConstructedPtr>& dependencies) { ConstructedPtr constructed = ConstructedPtr::dynamicCast(_type); - if (constructed && dependencies.find(constructed) != dependencies.end()) + if(constructed && dependencies.find(constructed) != dependencies.end()) { dependencies.insert(constructed); constructed->recDependencies(dependencies); @@ -1953,7 +1953,7 @@ Slice::Dictionary::uses(const ContainedPtr& contained) { { ContainedPtr contained2 = ContainedPtr::dynamicCast(_keyType); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -1961,7 +1961,7 @@ Slice::Dictionary::uses(const ContainedPtr& contained) { ContainedPtr contained2 = ContainedPtr::dynamicCast(_valueType); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -1981,7 +1981,7 @@ Slice::Dictionary::recDependencies(set<ConstructedPtr>& dependencies) { { ConstructedPtr constructed = ConstructedPtr::dynamicCast(_keyType); - if (constructed && dependencies.find(constructed) != dependencies.end()) + if(constructed && dependencies.find(constructed) != dependencies.end()) { dependencies.insert(constructed); constructed->recDependencies(dependencies); @@ -1990,7 +1990,7 @@ Slice::Dictionary::recDependencies(set<ConstructedPtr>& dependencies) { ConstructedPtr constructed = ConstructedPtr::dynamicCast(_valueType); - if (constructed && dependencies.find(constructed) != dependencies.end()) + if(constructed && dependencies.find(constructed) != dependencies.end()) { dependencies.insert(constructed); constructed->recDependencies(dependencies); @@ -2118,7 +2118,7 @@ Slice::Operation::uses(const ContainedPtr& contained) { { ContainedPtr contained2 = ContainedPtr::dynamicCast(_returnType); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -2126,19 +2126,19 @@ Slice::Operation::uses(const ContainedPtr& contained) TypeStringList::const_iterator p; - for (p = _inParams.begin(); p != _inParams.end(); ++p) + for(p = _inParams.begin(); p != _inParams.end(); ++p) { ContainedPtr contained2 = ContainedPtr::dynamicCast(p->first); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } } - for (p = _outParams.begin(); p != _outParams.end(); ++p) + for(p = _outParams.begin(); p != _outParams.end(); ++p) { ContainedPtr contained2 = ContainedPtr::dynamicCast(p->first); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -2146,10 +2146,10 @@ Slice::Operation::uses(const ContainedPtr& contained) ExceptionList::const_iterator q; - for (q = _throws.begin(); q != _throws.end(); ++q) + for(q = _throws.begin(); q != _throws.end(); ++q) { ContainedPtr contained2 = ContainedPtr::dynamicCast(*q); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -2196,7 +2196,7 @@ bool Slice::DataMember::uses(const ContainedPtr& contained) { ContainedPtr contained2 = ContainedPtr::dynamicCast(_type); - if (contained2 && contained2 == contained) + if(contained2 && contained2 == contained) { return true; } @@ -2239,18 +2239,18 @@ Slice::Unit::setComment(const string& comment) _currentComment = ""; string::size_type end = 0; - while (true) + while(true) { string::size_type begin = comment.find_first_not_of(" \t\r\n*", end); - if (begin == string::npos) + if(begin == string::npos) { break; } end = comment.find('\n', begin); - if (end != string::npos) + if(end != string::npos) { - if (end + 1 > begin) + if(end + 1 > begin) { _currentComment += comment.substr(begin, end + 1 - begin); } @@ -2258,9 +2258,9 @@ Slice::Unit::setComment(const string& comment) else { end = comment.find_last_not_of(" \t\r\n*"); - if (end != string::npos) + if(end != string::npos) { - if (end + 1 > begin) + if(end + 1 > begin) { _currentComment += comment.substr(begin, end + 1 - begin); } @@ -2297,13 +2297,13 @@ Slice::Unit::scanPosition(const char* s) string::size_type idx; idx = line.find("line"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx + 4); } idx = line.find_first_not_of(" \t\r#"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); } @@ -2311,18 +2311,18 @@ Slice::Unit::scanPosition(const char* s) _currentLine = atoi(line.c_str()) - 1; idx = line.find_first_of(" \t\r"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); } idx = line.find_first_not_of(" \t\r\""); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); idx = line.find_first_of(" \t\r\""); - if (idx != string::npos) + if(idx != string::npos) { _currentFile = line.substr(0, idx); line.erase(0, idx + 1); @@ -2333,21 +2333,21 @@ Slice::Unit::scanPosition(const char* s) } idx = line.find_first_not_of(" \t\r"); - if (idx != string::npos) + if(idx != string::npos) { line.erase(0, idx); int val = atoi(line.c_str()); - if (val == 1) + if(val == 1) { - if (++_currentIncludeLevel == 1) + if(++_currentIncludeLevel == 1) { - if (find(_includeFiles.begin(), _includeFiles.end(), _currentFile) == _includeFiles.end()) + if(find(_includeFiles.begin(), _includeFiles.end(), _currentFile) == _includeFiles.end()) { _includeFiles.push_back(_currentFile); } } } - else if (val == 2) + else if(val == 2) { --_currentIncludeLevel; } @@ -2355,7 +2355,7 @@ Slice::Unit::scanPosition(const char* s) } else { - if (_currentIncludeLevel == 0) + if(_currentIncludeLevel == 0) { _topLevelFile = _currentFile; } @@ -2366,7 +2366,7 @@ Slice::Unit::scanPosition(const char* s) int Slice::Unit::currentIncludeLevel() { - if (_all) + if(_all) { return 0; } @@ -2434,9 +2434,9 @@ Slice::Unit::removeContent(const ContainedPtr& contained) map<string, ContainedList>::iterator p = _contentMap.find(scoped); assert(p != _contentMap.end()); ContainedList::iterator q; - for (q = p->second.begin(); q != p->second.end(); ++q) + for(q = p->second.begin(); q != p->second.end(); ++q) { - if (q->get() == contained.get()) + if(q->get() == contained.get()) { p->second.erase(q); return; @@ -2453,7 +2453,7 @@ Slice::Unit::findContents(const string& scoped) map<string, ContainedList>::const_iterator p = _contentMap.find(scoped); - if (p != _contentMap.end()) + if(p != _contentMap.end()) { return p->second; } @@ -2472,10 +2472,10 @@ Slice::Unit::findDerivedClasses(const ClassDefPtr& cl) for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { ClassDefPtr r = ClassDefPtr::dynamicCast(*q); - if (r) + if(r) { ClassList bases = r->bases(); - if (find(bases.begin(), bases.end(), cl) != bases.end()) + if(find(bases.begin(), bases.end(), cl) != bases.end()) { derived.push_back(r); } @@ -2496,10 +2496,10 @@ Slice::Unit::findDerivedExceptions(const ExceptionPtr& ex) for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { ExceptionPtr r = ExceptionPtr::dynamicCast(*q); - if (r) + if(r) { ExceptionPtr base = r->base(); - if (base && base == ex) + if(base && base == ex) { derived.push_back(r); } @@ -2519,7 +2519,7 @@ Slice::Unit::findUsedBy(const ContainedPtr& contained) { for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { - if ((*q)->uses(contained)) + if((*q)->uses(contained)) { usedBy.push_back(*q); } @@ -2538,14 +2538,14 @@ Slice::Unit::usesProxies() for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q); - if (decl && !decl->isLocal()) + if(decl && !decl->isLocal()) { return true; } } } - if (_builtins.find(Builtin::KindObjectProxy) != _builtins.end()) + if(_builtins.find(Builtin::KindObjectProxy) != _builtins.end()) { return true; } @@ -2561,25 +2561,25 @@ Slice::Unit::usesNonLocals() for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { ConstructedPtr constr = ConstructedPtr::dynamicCast(*q); - if (constr && !constr->isLocal()) + if(constr && !constr->isLocal()) { return true; } ExceptionPtr exc = ExceptionPtr::dynamicCast(*q); - if (exc && !exc->isLocal()) + if(exc && !exc->isLocal()) { return true; } } } - if (_builtins.find(Builtin::KindObject) != _builtins.end()) + if(_builtins.find(Builtin::KindObject) != _builtins.end()) { return true; } - if (_builtins.find(Builtin::KindObjectProxy) != _builtins.end()) + if(_builtins.find(Builtin::KindObjectProxy) != _builtins.end()) { return true; } @@ -2610,14 +2610,14 @@ Slice::Unit::parse(FILE* file, bool debug) yyin = file; int status = yyparse(); - if (_errors) + if(_errors) { status = EXIT_FAILURE; } - if (status == EXIT_FAILURE) + if(status == EXIT_FAILURE) { - while (!_containerStack.empty()) + while(!_containerStack.empty()) { popContainer(); } @@ -2643,7 +2643,7 @@ Slice::Unit::destroy() void Slice::Unit::visit(ParserVisitor* visitor) { - if (visitor->visitUnitStart(this)) + if(visitor->visitUnitStart(this)) { Container::visit(visitor); visitor->visitUnitEnd(this); @@ -2654,7 +2654,7 @@ BuiltinPtr Slice::Unit::builtin(Builtin::Kind kind) { map<Builtin::Kind, BuiltinPtr>::const_iterator p = _builtins.find(kind); - if (p != _builtins.end()) + if(p != _builtins.end()) { return p->second; } diff --git a/cpp/src/Slice/dummyinclude/unistd.h b/cpp/src/Slice/dummyinclude/unistd.h index 92d53d10b9b..a5868056a35 100644 --- a/cpp/src/Slice/dummyinclude/unistd.h +++ b/cpp/src/Slice/dummyinclude/unistd.h @@ -1,4 +1,4 @@ -// -// Files generated by flex need unistd.h, which is not available on -// Windows. Thus this dummy file. -// +//
+// Files generated by flex need unistd.h, which is not available on
+// Windows. Thus this dummy file.
+//
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 860e69ff20c..de127ea1e9c 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -27,38 +27,38 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c _dllExport(dllExport), _impl(imp) { - for (vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) + for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) { - if (p->length() && (*p)[p->length() - 1] != '/') + if(p->length() && (*p)[p->length() - 1] != '/') { *p += '/'; } } string::size_type pos = _base.rfind('/'); - if (pos != string::npos) + if(pos != string::npos) { _base.erase(0, pos + 1); } - if (_impl) + if(_impl) { string fileImplH = _base + "I.h"; string fileImplC = _base + "I.cpp"; - if (!dir.empty()) + if(!dir.empty()) { fileImplH = dir + '/' + fileImplH; fileImplC = dir + '/' + fileImplC; } struct stat st; - if (stat(fileImplH.c_str(), &st) == 0) + if(stat(fileImplH.c_str(), &st) == 0) { cerr << name << ": `" << fileImplH << "' already exists - will not overwrite" << endl; return; } - if (stat(fileImplC.c_str(), &st) == 0) + if(stat(fileImplC.c_str(), &st) == 0) { cerr << name << ": `" << fileImplC << "' already exists - will not overwrite" << endl; @@ -66,7 +66,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c } implH.open(fileImplH.c_str()); - if (!implH) + if(!implH) { cerr << name << ": can't open `" << fileImplH << "' for writing: " << strerror(errno) << endl; @@ -74,7 +74,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c } implC.open(fileImplC.c_str()); - if (!implC) + if(!implC) { cerr << name << ": can't open `" << fileImplC << "' for writing: " << strerror(errno) << endl; @@ -82,7 +82,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c } string s = fileImplH; - if (_include.size()) + if(_include.size()) { s = _include + '/' + s; } @@ -94,21 +94,21 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c string fileH = _base + ".h"; string fileC = _base + ".cpp"; - if (!dir.empty()) + if(!dir.empty()) { fileH = dir + '/' + fileH; fileC = dir + '/' + fileC; } H.open(fileH.c_str()); - if (!H) + if(!H) { cerr << name << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl; return; } C.open(fileC.c_str()); - if (!C) + if(!C) { cerr << name << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl; return; @@ -120,7 +120,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c C << "\n// Generated from file `" << changeInclude(_base, _includePaths) << ".ice'\n"; string s = fileH; - if (_include.size()) + if(_include.size()) { s = _include + '/' + s; } @@ -135,7 +135,7 @@ Slice::Gen::~Gen() H << "\n\n#endif\n"; C << '\n'; - if (_impl) + if(_impl) { implH << "\n\n#endif\n"; implC << '\n'; @@ -145,11 +145,11 @@ Slice::Gen::~Gen() bool Slice::Gen::operator!() const { - if (!H || !C) + if(!H || !C) { return true; } - if (_impl && (!implH || !implC)) + if(_impl && (!implH || !implC)) { return true; } @@ -160,7 +160,7 @@ void Slice::Gen::generate(const UnitPtr& unit) { C << "\n#include <"; - if (_include.size()) + if(_include.size()) { C << _include << '/'; } @@ -170,7 +170,7 @@ Slice::Gen::generate(const UnitPtr& unit) H << "\n#include <Ice/ProxyF.h>"; H << "\n#include <Ice/ObjectF.h>"; - if (unit->usesProxies()) + if(unit->usesProxies()) { H << "\n#include <Ice/Exception.h>"; H << "\n#include <Ice/LocalObject.h>"; @@ -200,7 +200,7 @@ Slice::Gen::generate(const UnitPtr& unit) } StringList includes = unit->includeFiles(); - for (StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) + for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) { H << "\n#include <" << changeInclude(*q, _includePaths) << ".h>"; } @@ -209,7 +209,7 @@ Slice::Gen::generate(const UnitPtr& unit) printVersionCheck(C); printDllExportStuff(H, _dllExport); - if (_dllExport.size()) + if(_dllExport.size()) { _dllExport += " "; } @@ -244,17 +244,17 @@ Slice::Gen::generate(const UnitPtr& unit) ObjectVisitor objectVisitor(H, C, _dllExport); unit->visit(&objectVisitor); - if (_impl) + if(_impl) { implH << "\n#include <"; - if (_include.size()) + if(_include.size()) { implH << _include << '/'; } implH << _base << ".h>"; implC << "#include <"; - if (_include.size()) + if(_include.size()) { implC << _include << '/'; } @@ -273,7 +273,7 @@ Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllEx bool Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasOtherConstructedOrExceptions()) + if(!p->hasOtherConstructedOrExceptions()) { return false; } @@ -306,9 +306,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << sp << nl << "class " << name << " : "; H.useCurrentPosAsIndent(); - if (!base) + if(!base) { - if (p->isLocal()) + if(p->isLocal()) { H << "public ::Ice::LocalException"; } @@ -329,12 +329,12 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H.inc(); H << sp; - if (p->isLocal()) + if(p->isLocal()) { H << nl << _dllExport << name << "(const char*, int);"; C << sp << nl << scoped.substr(2) << "::" << name << "(const char* file, int line) : "; C.inc(); - if (!base) + if(!base) { C << nl << "::Ice::LocalException(file, line)"; } @@ -354,7 +354,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) C << nl << "return name;"; C << eb; - if (p->isLocal()) + if(p->isLocal()) { H << nl << _dllExport << "virtual void ice_print(::std::ostream&) const;"; } @@ -371,7 +371,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) C << nl << "throw *this;"; C << eb; - if (!p->isLocal()) + if(!p->isLocal()) { ExceptionList allBases = p->allBases(); StringList exceptionIds; @@ -389,10 +389,10 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) << "] ="; C << sb; q = exceptionIds.begin(); - while (q != exceptionIds.end()) + while(q != exceptionIds.end()) { C << nl << '"' << *q << '"'; - if (++q != exceptionIds.end()) + if(++q != exceptionIds.end()) { C << ','; } @@ -410,7 +410,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) void Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { - if (!p->isLocal()) + if(!p->isLocal()) { string name = p->name(); string scoped = p->scoped(); @@ -426,7 +426,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) TypeStringList memberList; DataMemberList dataMembers = p->dataMembers(); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { memberList.push_back(make_pair((*q)->type(), (*q)->name())); } @@ -497,13 +497,13 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << eb; C << sp << nl << "bool" << nl << scoped.substr(2) << "::operator!=(const " << name << "& __rhs) const"; C << sb; - C << nl << "if (this == &__rhs)"; + C << nl << "if(this == &__rhs)"; C << sb; C << nl << "return false;"; C << eb; - for (q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - C << nl << "if (" << (*q)->name() << " != __rhs." << (*q)->name() << ')'; + C << nl << "if(" << (*q)->name() << " != __rhs." << (*q)->name() << ')'; C << sb; C << nl << "return true;"; C << eb; @@ -512,17 +512,17 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << eb; C << sp << nl << "bool" << nl << scoped.substr(2) << "::operator<(const " << name << "& __rhs) const"; C << sb; - C << nl << "if (this == &__rhs)"; + C << nl << "if(this == &__rhs)"; C << sb; C << nl << "return false;"; C << eb; - for (q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - C << nl << "if (" << (*q)->name() << " < __rhs." << (*q)->name() << ')'; + C << nl << "if(" << (*q)->name() << " < __rhs." << (*q)->name() << ')'; C << sb; C << nl << "return true;"; C << eb; - C << nl << "else if (__rhs." << (*q)->name() << " < " << (*q)->name() << ')'; + C << nl << "else if(__rhs." << (*q)->name() << " < " << (*q)->name() << ')'; C << sb; C << nl << "return false;"; C << eb; @@ -530,7 +530,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << nl << "return false;"; C << eb; - if (!p->isLocal()) + if(!p->isLocal()) { // // Neither of these four member functions are virtual! @@ -542,7 +542,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) H << nl << _dllExport << "void ice_unmarshal(const ::std::string&, const ::Ice::StreamPtr&);"; TypeStringList memberList; - for (q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { memberList.push_back(make_pair((*q)->type(), (*q)->name())); } @@ -590,14 +590,14 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) string name = p->name(); TypePtr type = p->type(); string s = typeToString(type); - if (s[0] == ':') + if(s[0] == ':') { s.insert(0, " "); } H << sp << nl << "typedef ::std::vector<" << s << "> " << name << ';'; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (!p->isLocal() && + if(!p->isLocal() && (!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)) { string scoped = p->scoped(); @@ -634,7 +634,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << sb; C << nl << "__os->writeSize(::Ice::Int(v.size()));"; C << nl << scoped << "::const_iterator p;"; - C << nl << "for (p = v.begin(); p != v.end(); ++p)"; + C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; writeMarshalUnmarshalCode(C, type, "(*p)", true); C << eb; @@ -649,7 +649,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot // be checked whether sz is a reasonable value. // - C << nl << "while (sz--)"; + C << nl << "while(sz--)"; C << sb; C << nl << "v.resize(v.size() + 1);"; writeMarshalUnmarshalCode(C, type, "v.back()", false); @@ -662,7 +662,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << sb; C << nl << "__os->startWriteSequence(__name, ::Ice::Int(v.size()));"; C << nl << scoped << "::const_iterator p;"; - C << nl << "for (p = v.begin(); p != v.end(); ++p)"; + C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; writeGenericMarshalUnmarshalCode(C, type, "(*p)", true, "\"e\""); C << eb; @@ -677,7 +677,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) // Don't use v.resize(sz) or v.reserve(sz) here, as it cannot // be checked whether sz is a reasonable value. // - C << nl << "while (sz--)"; + C << nl << "while(sz--)"; C << sb; C << nl << "v.resize(v.size() + 1);"; writeGenericMarshalUnmarshalCode(C, type, "v.back()", false, "\"e\""); @@ -708,14 +708,14 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) TypePtr keyType = p->keyType(); TypePtr valueType = p->valueType(); string ks = typeToString(keyType); - if (ks[0] == ':') + if(ks[0] == ':') { ks.insert(0, " "); } string vs = typeToString(valueType); H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';'; - if (!p->isLocal()) + if(!p->isLocal()) { string scoped = p->scoped(); string scope = p->scope(); @@ -751,7 +751,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << sb; C << nl << "__os->writeSize(::Ice::Int(v.size()));"; C << nl << scoped << "::const_iterator p;"; - C << nl << "for (p = v.begin(); p != v.end(); ++p)"; + C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; writeMarshalUnmarshalCode(C, keyType, "p->first", true); writeMarshalUnmarshalCode(C, valueType, "p->second", true); @@ -763,7 +763,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << sb; C << nl << "::Ice::Int sz;"; C << nl << "__is->readSize(sz);"; - C << nl << "while (sz--)"; + C << nl << "while(sz--)"; C << sb; C << nl << "::std::pair<" << ks << ", " << vs << "> pair;"; writeMarshalUnmarshalCode(C, keyType, "pair.first", false); @@ -778,7 +778,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << sb; C << nl << "__os->startWriteDictionary(__name, ::Ice::Int(v.size()));"; C << nl << scoped << "::const_iterator p;"; - C << nl << "for (p = v.begin(); p != v.end(); ++p)"; + C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; C << nl << "__os->startWriteDictionaryElement();"; writeGenericMarshalUnmarshalCode(C, keyType, "p->first", true, "\"key\""); @@ -792,7 +792,7 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) << "const ::Ice::StreamPtr& __is, " << scoped << "& v, " << scope << "__U__" << name << ')'; C << sb; C << nl << "::Ice::Int sz = __is->startReadDictionary(__name);"; - C << nl << "while (sz--)"; + C << nl << "while(sz--)"; C << sb; C << nl << "::std::pair<" << ks << ", " << vs << "> pair;"; C << nl << "__is->startReadDictionaryElement();"; @@ -828,17 +828,17 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) H << sp << nl << "enum " << name; H << sb; EnumeratorList::const_iterator en = enumerators.begin(); - while (en != enumerators.end()) + while(en != enumerators.end()) { H << nl << (*en)->name(); - if (++en != enumerators.end()) + if(++en != enumerators.end()) { H << ','; } } H << eb << ';'; - if (!p->isLocal()) + if(!p->isLocal()) { string scoped = p->scoped(); string scope = p->scope(); @@ -857,11 +857,11 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped << " v)"; C << sb; - if (sz <= 0x7f) + if(sz <= 0x7f) { C << nl << "__os->write(static_cast< ::Ice::Byte>(v));"; } - else if (sz <= 0x7fff) + else if(sz <= 0x7fff) { C << nl << "__os->write(static_cast< ::Ice::Short>(v));"; } @@ -874,13 +874,13 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped << "& v)"; C << sb; - if (sz <= 0x7f) + if(sz <= 0x7f) { C << nl << "::Ice::Byte val;"; C << nl << "__is->read(val);"; C << nl << "v = static_cast< " << scoped << ">(val);"; } - else if (sz <= 0x7fff) + else if(sz <= 0x7fff) { C << nl << "::Ice::Short val;"; C << nl << "__is->read(val);"; @@ -901,10 +901,10 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) C << nl << "static const ::std::string " << "__RT__" << name << "[] ="; C << sb; en = enumerators.begin(); - while (en != enumerators.end()) + while(en != enumerators.end()) { C << nl << "\"" << (*en)->name() << "\""; - if (++en != enumerators.end()) + if(++en != enumerators.end()) { C << ','; } @@ -931,7 +931,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) void Slice::Gen::TypesVisitor::emitExceptionBase(const ExceptionPtr& base, const std::string& call) { - if (base) + if(base) { C.zeroIndent(); C << nl << "#ifdef _WIN32"; // COMPILERBUG @@ -955,7 +955,7 @@ Slice::Gen::ProxyDeclVisitor::ProxyDeclVisitor(Output& h, Output& c, const strin bool Slice::Gen::ProxyDeclVisitor::visitUnitStart(const UnitPtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -974,7 +974,7 @@ Slice::Gen::ProxyDeclVisitor::visitUnitEnd(const UnitPtr& p) bool Slice::Gen::ProxyDeclVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -995,7 +995,7 @@ Slice::Gen::ProxyDeclVisitor::visitModuleEnd(const ModulePtr& p) void Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return; } @@ -1016,7 +1016,7 @@ Slice::Gen::ProxyVisitor::ProxyVisitor(Output& h, Output& c, const string& dllEx bool Slice::Gen::ProxyVisitor::visitUnitStart(const UnitPtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1035,7 +1035,7 @@ Slice::Gen::ProxyVisitor::visitUnitEnd(const UnitPtr& p) bool Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1056,7 +1056,7 @@ Slice::Gen::ProxyVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -1066,7 +1066,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); H << sp << nl << "class " << _dllExport << name << " : "; - if (bases.empty()) + if(bases.empty()) { H << "virtual public ::IceProxy::Ice::Object"; } @@ -1074,10 +1074,10 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) { H.useCurrentPosAsIndent(); ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { H << "virtual public ::IceProxy" << (*q)->scoped(); - if (++q != bases.end()) + if(++q != bases.end()) { H << ',' << nl; } @@ -1157,7 +1157,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string paramsDecl = "("; // With declarators string args = "("; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { string typeString = inputTypeToString(q->first); params += typeString; @@ -1170,7 +1170,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) args += ", "; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { string typeString = outputTypeToString(q->first); params += typeString; @@ -1191,7 +1191,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl; C << sb; C << nl << "int __cnt = 0;"; - C << nl << "while (true)"; + C << nl << "while(true)"; C << sb; C << nl << "::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase = __getDelegate();"; C << nl << "::IceDelegate" << scope.substr(0, scope.size() - 2) << "* __del = dynamic_cast< ::IceDelegate" @@ -1199,12 +1199,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << nl << "try"; C << sb; C << nl; - if (ret) + if(ret) { C << "return "; } C << "__del->" << name << args << ";"; - if (!ret) + if(!ret) { C << nl << "return;"; } @@ -1217,7 +1217,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << sb; list<string> metaData = p->getMetaData(); bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end(); - if (nonmutating) + if(nonmutating) { C << nl << "__handleException(*__ex.get(), __cnt);"; } @@ -1242,7 +1242,7 @@ Slice::Gen::DelegateVisitor::DelegateVisitor(Output& h, Output& c, const string& bool Slice::Gen::DelegateVisitor::visitUnitStart(const UnitPtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1261,7 +1261,7 @@ Slice::Gen::DelegateVisitor::visitUnitEnd(const UnitPtr& p) bool Slice::Gen::DelegateVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1282,7 +1282,7 @@ Slice::Gen::DelegateVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -1291,7 +1291,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); H << sp << nl << "class " << _dllExport << name << " : "; - if (bases.empty()) + if(bases.empty()) { H << "virtual public ::IceDelegate::Ice::Object"; } @@ -1299,10 +1299,10 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) { H.useCurrentPosAsIndent(); ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { H << "virtual public ::IceDelegate" << (*q)->scoped(); - if (++q != bases.end()) + if(++q != bases.end()) { H << ',' << nl; } @@ -1337,14 +1337,14 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) string params = "("; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { string typeString = inputTypeToString(q->first); params += typeString; params += ", "; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { string typeString = outputTypeToString(q->first); params += typeString; @@ -1364,7 +1364,7 @@ Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, const strin bool Slice::Gen::DelegateMVisitor::visitUnitStart(const UnitPtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1383,7 +1383,7 @@ Slice::Gen::DelegateMVisitor::visitUnitEnd(const UnitPtr& p) bool Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1404,7 +1404,7 @@ Slice::Gen::DelegateMVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -1416,17 +1416,17 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) H << sp << nl << "class " << _dllExport << name << " : "; H.useCurrentPosAsIndent(); H << "virtual public ::IceDelegate" << scoped << ','; - if (bases.empty()) + if(bases.empty()) { H << nl << "virtual public ::IceDelegateM::Ice::Object"; } else { ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { H << nl << "virtual public ::IceDelegateM" << (*q)->scoped(); - if (++q != bases.end()) + if(++q != bases.end()) { H << ','; } @@ -1463,7 +1463,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) string params = "("; string paramsDecl = "("; // With declarators - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { string typeString = inputTypeToString(q->first); params += typeString; @@ -1474,7 +1474,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) paramsDecl += ", "; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { string typeString = outputTypeToString(q->first); params += typeString; @@ -1500,35 +1500,35 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end(); C << nl << "::IceInternal::Outgoing __out(__connection, __reference, __operation, " << (nonmutating ? "true" : "false") << ", __context);"; - if (ret || !outParams.empty() || !throws.empty()) + if(ret || !outParams.empty() || !throws.empty()) { C << nl << "::IceInternal::BasicStream* __is = __out.is();"; } - if (!inParams.empty()) + if(!inParams.empty()) { C << nl << "::IceInternal::BasicStream* __os = __out.os();"; } writeMarshalCode(C, inParams, 0); - C << nl << "if (!__out.invoke())"; + C << nl << "if(!__out.invoke())"; C << sb; - if (!throws.empty()) + if(!throws.empty()) { ExceptionList::const_iterator r; C << nl << "static ::std::string __throws[] ="; C << sb; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { C << nl << '"' << (*r)->scoped() << '"'; - if (r != throws.end()) + if(r != throws.end()) { C << ','; } } C << eb << ';'; - C << nl << "switch (__is->throwException(__throws, __throws + " << throws.size() << "))"; + C << nl << "switch(__is->throwException(__throws, __throws + " << throws.size() << "))"; C << sb; int cnt = 0; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { C << nl << "case " << cnt++ << ':'; C << sb; @@ -1547,7 +1547,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << eb; writeAllocateCode(C, TypeStringList(), ret); writeUnmarshalCode(C, outParams, ret); - if (ret) + if(ret) { C << nl << "return __ret;"; } @@ -1562,7 +1562,7 @@ Slice::Gen::DelegateDVisitor::DelegateDVisitor(Output& h, Output& c, const strin bool Slice::Gen::DelegateDVisitor::visitUnitStart(const UnitPtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1581,7 +1581,7 @@ Slice::Gen::DelegateDVisitor::visitUnitEnd(const UnitPtr& p) bool Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasNonLocalClassDecls()) + if(!p->hasNonLocalClassDecls()) { return false; } @@ -1602,7 +1602,7 @@ Slice::Gen::DelegateDVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -1614,17 +1614,17 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) H << sp << nl << "class " << _dllExport << name << " : "; H.useCurrentPosAsIndent(); H << "virtual public ::IceDelegate" << scoped << ','; - if (bases.empty()) + if(bases.empty()) { H << nl << "virtual public ::IceDelegateD::Ice::Object"; } else { ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { H << nl << "virtual public ::IceDelegateD" << (*q)->scoped(); - if (++q != bases.end()) + if(++q != bases.end()) { H << ','; } @@ -1665,7 +1665,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) string paramsDecl = "("; // With declarators string args = "("; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { string typeString = inputTypeToString(q->first); params += typeString; @@ -1678,7 +1678,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) args += ", "; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { string typeString = outputTypeToString(q->first); params += typeString; @@ -1703,11 +1703,11 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end(); C << nl << "__initCurrent(__current, \"" << name << "\", " << (nonmutating ? "true" : "false") << ", __context);"; - C << nl << "while (true)"; + C << nl << "while(true)"; C << sb; C << nl << "::IceInternal::Direct __direct(__adapter, __current);"; C << nl << cl->scoped() << "* __servant = dynamic_cast< " << cl->scoped() << "*>(__direct.facetServant().get());"; - C << nl << "if (!__servant)"; + C << nl << "if(!__servant)"; C << sb; C << nl << "::Ice::OperationNotExistException __opEx(__FILE__, __LINE__);"; C << nl << "__opEx.operation = __current.operation;"; @@ -1716,12 +1716,12 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << nl << "try"; C << sb; C << nl; - if (ret) + if(ret) { C << "return "; } C << "__servant->" << name << args << ';'; - if (!ret) + if(!ret) { C << nl << "return;"; } @@ -1730,7 +1730,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) throws.sort(); throws.unique(); ExceptionList::const_iterator r; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { C << nl << "catch (const " << (*r)->scoped() << "&)"; C << sb; @@ -1761,7 +1761,7 @@ Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, const str bool Slice::Gen::ObjectDeclVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasClassDecls()) + if(!p->hasClassDecls()) { return false; } @@ -1798,7 +1798,7 @@ Slice::Gen::ObjectVisitor::ObjectVisitor(Output& h, Output& c, const string& dll bool Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasClassDefs()) + if(!p->hasClassDefs()) { return false; } @@ -1826,9 +1826,9 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) string exp1; string exp2; - if (_dllExport.size()) + if(_dllExport.size()) { - if (p->hasDataMembers()) + if(p->hasDataMembers()) { exp2 = _dllExport; } @@ -1841,9 +1841,9 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << sp; H << nl << "class " << exp1 << name << " : "; H.useCurrentPosAsIndent(); - if (bases.empty()) + if(bases.empty()) { - if (p->isLocal()) + if(p->isLocal()) { H << "virtual public ::Ice::LocalObject"; } @@ -1855,10 +1855,10 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) else { ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { H << "virtual public " << (*q)->scoped(); - if (++q != bases.end()) + if(++q != bases.end()) { H << ',' << nl; } @@ -1870,7 +1870,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << "public:"; H.inc(); - if (!p->isLocal()) + if(!p->isLocal()) { ClassList allBases = p->allBases(); StringList ids; @@ -1895,7 +1895,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) H << nl << exp2 << "virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current());"; H << nl << exp2 << "static const ::std::string& ice_staticId();"; - if (!p->isAbstract()) + if(!p->isAbstract()) { H << sp << nl << exp2 << "static ::Ice::ObjectFactoryPtr _factory;"; H << nl << exp2 << "static const ::Ice::ObjectFactoryPtr& ice_factory();"; @@ -1904,10 +1904,10 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) C << nl << "const ::std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] ="; C << sb; q = ids.begin(); - while (q != ids.end()) + while(q != ids.end()) { C << nl << '"' << *q << '"'; - if (++q != ids.end()) + if(++q != ids.end()) { C << ','; } @@ -1948,12 +1948,12 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) string scoped = p->scoped(); string scope = p->scope(); - if (!p->isLocal()) + if(!p->isLocal()) { string exp2; - if (_dllExport.size()) + if(_dllExport.size()) { - if (p->hasDataMembers()) + if(p->hasDataMembers()) { exp2 = _dllExport; } @@ -1961,13 +1961,13 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) ClassList bases = p->bases(); ClassDefPtr base; - if (!bases.empty() && !bases.front()->isInterface()) + if(!bases.empty() && !bases.front()->isInterface()) { base = bases.front(); } OperationList allOps = p->allOperations(); - if (!allOps.empty()) + if(!allOps.empty()) { StringList allOpNames; transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::memFun(&Operation::name)); @@ -1989,10 +1989,10 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "::std::string " << scoped.substr(2) << "::__all[] ="; C << sb; q = allOpNames.begin(); - while (q != allOpNames.end()) + while(q != allOpNames.end()) { C << nl << '"' << *q << '"'; - if (++q != allOpNames.end()) + if(++q != allOpNames.end()) { C << ','; } @@ -2004,15 +2004,15 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << sb; C << nl << "::std::pair<const ::std::string*, const ::std::string*> r = " << "::std::equal_range(__all, __all + " << allOpNames.size() << ", current.operation);"; - C << nl << "if (r.first == r.second)"; + C << nl << "if(r.first == r.second)"; C << sb; C << nl << "return ::IceInternal::DispatchOperationNotExist;"; C << eb; C << sp; - C << nl << "switch (r.first - __all)"; + C << nl << "switch(r.first - __all)"; C << sb; int i = 0; - for (q = allOpNames.begin(); q != allOpNames.end(); ++q) + for(q = allOpNames.begin(); q != allOpNames.end(); ++q) { C << nl << "case " << i++ << ':'; C << sb; @@ -2040,7 +2040,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) TypeStringList memberList; DataMemberList dataMembers = p->dataMembers(); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { memberList.push_back(make_pair((*q)->type(), (*q)->name())); } @@ -2079,7 +2079,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) writeGenericMarshalUnmarshalCode(C, p->declaration(), "value", false, "__name"); C << eb; - if (!p->isAbstract()) + if(!p->isAbstract()) { string name = p->name(); string factoryName = "__F__"; @@ -2112,7 +2112,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) H << eb << ';'; - if (p->isLocal()) + if(p->isLocal()) { C << sp; C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped @@ -2188,9 +2188,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) string paramsDecl = "("; // With declarators string args = "("; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { - if (q != inParams.begin()) + if(q != inParams.begin()) { params += ", "; paramsDecl += ", "; @@ -2205,9 +2205,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) args += q->second; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { - if (q != outParams.begin() || !inParams.empty()) + if(q != outParams.begin() || !inParams.empty()) { params += ", "; paramsDecl += ", "; @@ -2222,9 +2222,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) args += q->second; } - if (!cl->isLocal()) + if(!cl->isLocal()) { - if (!inParams.empty() || !outParams.empty()) + if(!inParams.empty() || !outParams.empty()) { params += ", "; paramsDecl += ", "; @@ -2242,9 +2242,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) } string exp2; - if (_dllExport.size()) + if(_dllExport.size()) { - if (cl->hasDataMembers()) + if(cl->hasDataMembers()) { exp2 = _dllExport; } @@ -2253,7 +2253,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << exp2 << "virtual " << retS << ' ' << name << params << " = 0;"; - if (!cl->isLocal()) + if(!cl->isLocal()) { ExceptionList throws = p->throws(); throws.sort(); @@ -2265,34 +2265,34 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "___" << name << "(::IceInternal::Incoming& __in, const ::Ice::Current& __current)"; C << sb; - if (!inParams.empty()) + if(!inParams.empty()) { C << nl << "::IceInternal::BasicStream* __is = __in.is();"; } - if (ret || !outParams.empty() || !throws.empty()) + if(ret || !outParams.empty() || !throws.empty()) { C << nl << "::IceInternal::BasicStream* __os = __in.os();"; } writeAllocateCode(C, inParams, 0); writeUnmarshalCode(C, inParams, 0); writeAllocateCode(C, outParams, 0); - if (!throws.empty()) + if(!throws.empty()) { C << nl << "try"; C << sb; } C << nl; - if (ret) + if(ret) { C << retS << " __ret = "; } C << name << args << ';'; writeMarshalCode(C, outParams, ret); - if (!throws.empty()) + if(!throws.empty()) { C << eb; ExceptionList::const_iterator r; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { C << nl << "catch (const " << (*r)->scoped() << "& __ex)"; C << sb; @@ -2318,7 +2318,7 @@ Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p) void Slice::Gen::ObjectVisitor::emitClassBase(const ClassDefPtr& base, const std::string& call) { - if (base) + if(base) { C.zeroIndent(); C << nl << "#ifdef _WIN32"; // COMPILERBUG @@ -2357,7 +2357,7 @@ Slice::Gen::IceInternalVisitor::IceInternalVisitor(Output& h, Output& c, const s bool Slice::Gen::IceInternalVisitor::visitUnitStart(const UnitPtr& p) { - if (!p->hasClassDecls()) + if(!p->hasClassDecls()) { return false; } @@ -2383,7 +2383,7 @@ Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p) H << sp; H << nl << _dllExport << "void incRef(" << scoped << "*);"; H << nl << _dllExport << "void decRef(" << scoped << "*);"; - if (!p->isLocal()) + if(!p->isLocal()) { H << sp; H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);"; @@ -2415,7 +2415,7 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) C << nl << "p->__decRef();"; C << eb; - if (!p->isLocal()) + if(!p->isLocal()) { C << sp; C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)"; @@ -2434,12 +2434,12 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) << scoped << "Prx& d)"; C << sb; C << nl << "d = 0;"; - C << nl << "if (b)"; + C << nl << "if(b)"; C << sb; - C << nl << "if (f == b->ice_getFacet())"; + C << nl << "if(f == b->ice_getFacet())"; C << sb; C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; - C << nl << "if (!d && b->ice_isA(\"" << scoped << "\"))"; + C << nl << "if(!d && b->ice_isA(\"" << scoped << "\"))"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ";"; C << nl << "d->__copyFrom(b);"; @@ -2450,7 +2450,7 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) C << nl << "::Ice::ObjectPrx bb = b->ice_newFacet(f);"; C << nl << "try"; C << sb; - C << nl << "if (bb->ice_isA(\"" << scoped << "\"))"; + C << nl << "if(bb->ice_isA(\"" << scoped << "\"))"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ";"; C << nl << "d->__copyFrom(bb);"; @@ -2468,12 +2468,12 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) << scoped << "Prx& d)"; C << sb; C << nl << "d = 0;"; - C << nl << "if (b)"; + C << nl << "if(b)"; C << sb; - C << nl << "if (f == b->ice_getFacet())"; + C << nl << "if(f == b->ice_getFacet())"; C << sb; C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; - C << nl << "if (!d)"; + C << nl << "if(!d)"; C << sb; C << nl << "d = new ::IceProxy" << scoped << ";"; C << nl << "d->__copyFrom(b);"; @@ -2500,7 +2500,7 @@ Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, const string& dll bool Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasClassDecls()) + if(!p->hasClassDecls()) { return false; } @@ -2528,7 +2528,7 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) H << sp; H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name << "Ptr;"; - if (!p->isLocal()) + if(!p->isLocal()) { H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;"; @@ -2547,7 +2547,7 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) bool Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (!p->isLocal()) + if(!p->isLocal()) { string scoped = p->scoped(); string scope = p->scope(); @@ -2565,7 +2565,7 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) C << sb; C << nl << "::Ice::ObjectPrx proxy;"; C << nl << "__is->read(proxy);"; - C << nl << "if (!proxy)"; + C << nl << "if(!proxy)"; C << sb; C << nl << "v = 0;"; C << eb; @@ -2588,7 +2588,7 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) << "const ::Ice::StreamPtr& __is, " << scoped << "Prx& v)"; C << sb; C << nl << "::Ice::ObjectPrx proxy = __is->readProxy(__name);"; - C << nl << "if (!proxy)"; + C << nl << "if(!proxy)"; C << sb; C << nl << "v = 0;"; C << eb; @@ -2613,9 +2613,9 @@ void Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - switch (builtin->kind()) + switch(builtin->kind()) { case Builtin::KindBool: { @@ -2653,28 +2653,28 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type) } ProxyPtr prx = ProxyPtr::dynamicCast(type); - if (prx) + if(prx) { out << nl << "return 0;"; return; } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { out << nl << "return 0;"; return; } StructPtr st = StructPtr::dynamicCast(type); - if (st) + if(st) { out << nl << "return " << st->scoped() << "();"; return; } EnumPtr en = EnumPtr::dynamicCast(type); - if (en) + if(en) { EnumeratorList enumerators = en->getEnumerators(); out << nl << "return " << en->scope() << enumerators.front()->name() << ';'; @@ -2682,7 +2682,7 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type) } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { out << nl << "return " << seq->scoped() << "();"; return; @@ -2696,7 +2696,7 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type) bool Slice::Gen::ImplVisitor::visitModuleStart(const ModulePtr& p) { - if (!p->hasClassDefs()) + if(!p->hasClassDefs()) { return false; } @@ -2718,7 +2718,7 @@ Slice::Gen::ImplVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (!p->isAbstract()) + if(!p->isAbstract()) { return false; } @@ -2730,7 +2730,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); ClassDefPtr base; - if (!bases.empty() && !bases.front()->isInterface()) + if(!bases.empty() && !bases.front()->isInterface()) { base = bases.front(); } @@ -2740,7 +2740,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) H.useCurrentPosAsIndent(); H << "virtual public " << name; ClassList::const_iterator q; - for (q = bases.begin(); q != bases.end(); ++q) + for(q = bases.begin(); q != bases.end(); ++q) { H << ',' << nl << "virtual public " << (*q)->scoped() << "I"; } @@ -2757,7 +2757,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) // // Operations // - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); string opName = op->name(); @@ -2771,27 +2771,27 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) H << sp << nl << "virtual " << retS << ' ' << opName << '('; H.useCurrentPosAsIndent(); - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { - if (q != inParams.begin()) + if(q != inParams.begin()) { H << ',' << nl; } string typeString = inputTypeToString(q->first); H << typeString; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { - if (!inParams.empty() || q != outParams.begin()) + if(!inParams.empty() || q != outParams.begin()) { H << ',' << nl; } string typeString = outputTypeToString(q->first); H << typeString; } - if (!p->isLocal()) + if(!p->isLocal()) { - if (!inParams.empty() || !outParams.empty()) + if(!inParams.empty() || !outParams.empty()) { H << ',' << nl; } @@ -2802,27 +2802,27 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) C << sp << nl << retS << nl << scoped.substr(2) << "I::" << opName << '('; C.useCurrentPosAsIndent(); - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { - if (q != inParams.begin()) + if(q != inParams.begin()) { C << ',' << nl; } string typeString = inputTypeToString(q->first); C << typeString << ' ' << q->second; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { - if (!inParams.empty() || q != outParams.begin()) + if(!inParams.empty() || q != outParams.begin()) { C << ',' << nl; } string typeString = outputTypeToString(q->first); C << typeString << ' ' << q->second; } - if (!p->isLocal()) + if(!p->isLocal()) { - if (!inParams.empty() || !outParams.empty()) + if(!inParams.empty() || !outParams.empty()) { C << ',' << nl; } @@ -2835,7 +2835,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) // // Return value // - if (ret) + if(ret) { writeReturn(C, ret); } diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 71ca45f81cc..7e7d4abc0bb 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -1,294 +1,294 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GEN_H -#define GEN_H - -#include <Slice/Parser.h> -#include <IceUtil/OutputUtil.h> - -namespace Slice -{ - -class Gen : public ::IceUtil::noncopyable -{ -public: - - Gen(const std::string&, - const std::string&, - const std::string&, - const std::vector<std::string>&, - const std::string&, - const std::string&, - bool); - ~Gen(); - - bool operator!() const; // Returns true if there was a constructor error - - void generate(const UnitPtr&); - -private: - - ::IceUtil::Output H; - ::IceUtil::Output C; - - ::IceUtil::Output implH; - ::IceUtil::Output implC; - - std::string _base; - std::string _include; - std::vector<std::string> _includePaths; - std::string _dllExport; - bool _impl; - - class TypesVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - TypesVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitExceptionStart(const ExceptionPtr&); - virtual void visitExceptionEnd(const ExceptionPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitStructEnd(const StructPtr&); - virtual void visitSequence(const SequencePtr&); - virtual void visitDictionary(const DictionaryPtr&); - virtual void visitEnum(const EnumPtr&); - virtual void visitDataMember(const DataMemberPtr&); - - private: - - void emitExceptionBase(const ExceptionPtr&, const std::string&); - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class ProxyDeclVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - ProxyDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual void visitClassDecl(const ClassDeclPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class ProxyVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - ProxyVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class DelegateVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - DelegateVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class DelegateMVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - DelegateMVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class DelegateDVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - DelegateDVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class ObjectDeclVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - ObjectDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual void visitClassDecl(const ClassDeclPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class ObjectVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - ObjectVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual bool visitExceptionStart(const ExceptionPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitOperation(const OperationPtr&); - virtual void visitDataMember(const DataMemberPtr&); - - private: - - void emitClassBase(const ClassDefPtr&, const std::string&); - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class IceInternalVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - IceInternalVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual void visitClassDecl(const ClassDeclPtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class HandleVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - HandleVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual void visitClassDecl(const ClassDeclPtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class ImplVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - ImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - - // - // Generate code to return a dummy value - // - void writeReturn(::IceUtil::Output&, const TypePtr&); - }; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GEN_H
+#define GEN_H
+
+#include <Slice/Parser.h>
+#include <IceUtil/OutputUtil.h>
+
+namespace Slice
+{
+
+class Gen : public ::IceUtil::noncopyable
+{
+public:
+
+ Gen(const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&,
+ const std::string&,
+ bool);
+ ~Gen();
+
+ bool operator!() const; // Returns true if there was a constructor error
+
+ void generate(const UnitPtr&);
+
+private:
+
+ ::IceUtil::Output H;
+ ::IceUtil::Output C;
+
+ ::IceUtil::Output implH;
+ ::IceUtil::Output implC;
+
+ std::string _base;
+ std::string _include;
+ std::vector<std::string> _includePaths;
+ std::string _dllExport;
+ bool _impl;
+
+ class TypesVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ TypesVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual void visitExceptionEnd(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitStructEnd(const StructPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
+
+ private:
+
+ void emitExceptionBase(const ExceptionPtr&, const std::string&);
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class ProxyDeclVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ ProxyDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class ProxyVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ ProxyVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class DelegateVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ DelegateVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class DelegateMVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ DelegateMVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class DelegateDVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ DelegateDVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class ObjectDeclVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ ObjectDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class ObjectVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ ObjectVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
+
+ private:
+
+ void emitClassBase(const ClassDefPtr&, const std::string&);
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class IceInternalVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ IceInternalVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class HandleVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ HandleVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+ };
+
+ class ImplVisitor : public ::IceUtil::noncopyable, public ParserVisitor
+ {
+ public:
+
+ ImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+
+ private:
+
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
+
+ std::string _dllExport;
+
+ //
+ // Generate code to return a dummy value
+ //
+ void writeReturn(::IceUtil::Output&, const TypePtr&);
+ };
+};
+
+}
+
+#endif
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 8d8c02dee57..cd81f3c674e 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -46,58 +46,58 @@ main(int argc, char* argv[]) bool debug = false; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; string path = argv[idx] + 2; - if (path.length()) + if(path.length()) { includePaths.push_back(path); } - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--include-dir") == 0) + else if(strcmp(argv[idx], "--include-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -105,15 +105,15 @@ main(int argc, char* argv[]) } include = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--output-dir") == 0) + else if(strcmp(argv[idx], "--output-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -121,15 +121,15 @@ main(int argc, char* argv[]) } output = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--dll-export") == 0) + else if(strcmp(argv[idx], "--dll-export") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -137,22 +137,22 @@ main(int argc, char* argv[]) } dllExport = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--impl") == 0) + else if(strcmp(argv[idx], "--impl") == 0) { impl = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -164,7 +164,7 @@ main(int argc, char* argv[]) } } - if (argc < 2) + if(argc < 2) { cerr << argv[0] << ": no input file" << endl; usage(argv[0]); @@ -173,17 +173,17 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { string base(argv[idx]); string suffix; string::size_type pos = base.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = base.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; return EXIT_FAILURE; @@ -191,7 +191,7 @@ main(int argc, char* argv[]) base.erase(pos); ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -204,7 +204,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -219,7 +219,7 @@ main(int argc, char* argv[]) pclose(cppHandle); #endif - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -227,7 +227,7 @@ main(int argc, char* argv[]) { Gen gen(argv[0], base, include, includePaths, dllExport, output, impl); - if (!gen) + if(!gen) { unit->destroy(); return EXIT_FAILURE; diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp index e3617dbbdd7..378d6f653c6 100644 --- a/cpp/src/slice2docbook/Gen.cpp +++ b/cpp/src/slice2docbook/Gen.cpp @@ -19,7 +19,7 @@ Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool no _standAlone(standAlone), _noGlobals(noGlobals) { - if (chapter) + if(chapter) { _chapter = "chapter"; } @@ -29,7 +29,7 @@ Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool no } O.open(file.c_str()); - if (!O) + if(!O) { cerr << name << ": can't open `" << file << "' for writing: " << strerror(errno) << endl; return; @@ -64,7 +64,7 @@ Slice::Gen::generate(const UnitPtr& unit) bool Slice::Gen::visitUnitStart(const UnitPtr& p) { - if (_standAlone) + if(_standAlone) { O << "<!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\">"; printHeader(); @@ -75,7 +75,7 @@ Slice::Gen::visitUnitStart(const UnitPtr& p) printHeader(); } - if (!_noGlobals) + if(!_noGlobals) { start(_chapter, "Global Module"); // start("section", "Overview"); @@ -89,7 +89,7 @@ Slice::Gen::visitUnitStart(const UnitPtr& p) void Slice::Gen::visitUnitEnd(const UnitPtr& p) { - if (_standAlone) + if(_standAlone) { end(); } @@ -120,11 +120,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) modules.erase(remove_if(modules.begin(), modules.end(), ::IceUtil::memFun(&Contained::includeLevel)), modules.end()); - if (!modules.empty()) + if(!modules.empty()) { start("section", "Module Index"); start("variablelist"); - for (ModuleList::const_iterator q = modules.begin(); q != modules.end(); ++q) + for(ModuleList::const_iterator q = modules.begin(); q != modules.end(); ++q) { start("varlistentry"); start("term"); @@ -150,11 +150,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) remove_copy_if(classesAndInterfaces.begin(), classesAndInterfaces.end(), back_inserter(interfaces), not1(::IceUtil::memFun(&ClassDef::isInterface))); - if (!classes.empty()) + if(!classes.empty()) { start("section", "Class Index"); start("variablelist"); - for (ClassList::const_iterator q = classes.begin(); q != classes.end(); ++q) + for(ClassList::const_iterator q = classes.begin(); q != classes.end(); ++q) { start("varlistentry"); start("term"); @@ -169,11 +169,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) end(); } - if (!interfaces.empty()) + if(!interfaces.empty()) { start("section", "Interface Index"); start("variablelist"); - for (ClassList::const_iterator q = interfaces.begin(); q != interfaces.end(); ++q) + for(ClassList::const_iterator q = interfaces.begin(); q != interfaces.end(); ++q) { start("varlistentry"); start("term"); @@ -192,11 +192,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) exceptions.erase(remove_if(exceptions.begin(), exceptions.end(), ::IceUtil::memFun(&Contained::includeLevel)), exceptions.end()); - if (!exceptions.empty()) + if(!exceptions.empty()) { start("section", "Exception Index"); start("variablelist"); - for (ExceptionList::const_iterator q = exceptions.begin(); q != exceptions.end(); ++q) + for(ExceptionList::const_iterator q = exceptions.begin(); q != exceptions.end(); ++q) { start("varlistentry"); start("term"); @@ -215,11 +215,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) structs.erase(remove_if(structs.begin(), structs.end(), ::IceUtil::memFun(&Contained::includeLevel)), structs.end()); - if (!structs.empty()) + if(!structs.empty()) { start("section", "Struct Index"); start("variablelist"); - for (StructList::const_iterator q = structs.begin(); q != structs.end(); ++q) + for(StructList::const_iterator q = structs.begin(); q != structs.end(); ++q) { start("varlistentry"); start("term"); @@ -238,11 +238,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) sequences.erase(remove_if(sequences.begin(), sequences.end(), ::IceUtil::memFun(&Contained::includeLevel)), sequences.end()); - if (!sequences.empty()) + if(!sequences.empty()) { start("section", "Sequence Index"); start("variablelist"); - for (SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q) + for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q) { start("varlistentry"); start("term"); @@ -262,11 +262,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) ::IceUtil::memFun(&Contained::includeLevel)), dictionaries.end()); - if (!dictionaries.empty()) + if(!dictionaries.empty()) { start("section", "Dictionary Index"); start("variablelist"); - for (DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q) + for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q) { start("varlistentry"); start("term"); @@ -285,11 +285,11 @@ Slice::Gen::visitContainer(const ContainerPtr& p) enums.erase(remove_if(enums.begin(), enums.end(), ::IceUtil::memFun(&Contained::includeLevel)), enums.end()); - if (!enums.empty()) + if(!enums.empty()) { start("section", "Enum Index"); start("variablelist"); - for (EnumList::const_iterator q = enums.begin(); q != enums.end(); ++q) + for(EnumList::const_iterator q = enums.begin(); q != enums.end(); ++q) { start("varlistentry"); start("term"); @@ -307,13 +307,13 @@ Slice::Gen::visitContainer(const ContainerPtr& p) end(); { - for (SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q) + for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); O << nl << "<synopsis>"; printMetaData(*q); - if ((*q)->isLocal()) + if((*q)->isLocal()) { O << "local "; } @@ -326,13 +326,13 @@ Slice::Gen::visitContainer(const ContainerPtr& p) } { - for (DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q) + for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); O << nl << "<synopsis>"; printMetaData(*q); - if ((*q)->isLocal()) + if((*q)->isLocal()) { O << "local "; } @@ -357,11 +357,11 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) O.zeroIndent(); O << nl << "<synopsis>"; printMetaData(p); - if (p->isLocal()) + if(p->isLocal()) { O << "local "; } - if (p->isInterface()) + if(p->isInterface()) { O << "interface"; } @@ -371,7 +371,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) } O << " <classname>" << p->name() << "</classname>"; ClassList bases = p->bases(); - if (!bases.empty() && !bases.front()->isInterface()) + if(!bases.empty() && !bases.front()->isInterface()) { O.inc(); O << nl << "extends "; @@ -381,10 +381,10 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) O.dec(); O.dec(); } - if (!bases.empty()) + if(!bases.empty()) { O.inc(); - if (p->isInterface()) + if(p->isInterface()) { O << nl << "extends "; } @@ -394,10 +394,10 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) } O.inc(); ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { O << nl << toString(*q, p); - if (++q != bases.end()) + if(++q != bases.end()) { O << ","; } @@ -410,11 +410,11 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) printComment(p); OperationList operations = p->operations(); - if (!operations.empty()) + if(!operations.empty()) { start("section", "Operation Index"); start("variablelist"); - for (OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q) + for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q) { start("varlistentry"); start("term"); @@ -430,11 +430,11 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) } DataMemberList dataMembers = p->dataMembers(); - if (!dataMembers.empty()) + if(!dataMembers.empty()) { start("section", "Data Member Index"); start("variablelist"); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { start("varlistentry"); start("term"); @@ -452,7 +452,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) end(); { - for (OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q) + for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); @@ -464,23 +464,23 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) O.inc(); TypeStringList inputParams = (*q)->inputParameters(); TypeStringList::const_iterator r = inputParams.begin(); - while (r != inputParams.end()) + while(r != inputParams.end()) { O << nl << toString(r->first, p) << " <parameter>" << r->second << "</parameter>"; - if (++r != inputParams.end()) + if(++r != inputParams.end()) { O << ','; } } TypeStringList outputParams = (*q)->outputParameters(); - if (!outputParams.empty()) + if(!outputParams.empty()) { O << ';'; r = outputParams.begin(); - while (r != outputParams.end()) + while(r != outputParams.end()) { O << nl << toString(r->first, p) << " <parameter>" << r->second << "</parameter>"; - if (++r != outputParams.end()) + if(++r != outputParams.end()) { O << ','; } @@ -489,16 +489,16 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) O << ')'; O.dec(); ExceptionList throws = (*q)->throws(); - if (!throws.empty()) + if(!throws.empty()) { O.inc(); O << nl << "throws"; O.inc(); ExceptionList::const_iterator r = throws.begin(); - while (r != throws.end()) + while(r != throws.end()) { O << nl << toString(*r, p); - if (++r != throws.end()) + if(++r != throws.end()) { O << ','; } @@ -514,7 +514,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) } { - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); @@ -543,13 +543,13 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p) O.zeroIndent(); O << nl << "<synopsis>"; printMetaData(p); - if (p->isLocal()) + if(p->isLocal()) { O << "local "; } O << "exception <classname>" << p->name() << "</classname>"; ExceptionPtr base = p->base(); - if (base) + if(base) { O.inc(); O << nl << "extends "; @@ -563,11 +563,11 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p) printComment(p); DataMemberList dataMembers = p->dataMembers(); - if (!dataMembers.empty()) + if(!dataMembers.empty()) { start("section", "Data Member Index"); start("variablelist"); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { start("varlistentry"); start("term"); @@ -585,7 +585,7 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p) end(); { - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); @@ -614,7 +614,7 @@ Slice::Gen::visitStructStart(const StructPtr& p) O.zeroIndent(); O << nl << "<synopsis>"; printMetaData(p); - if (p->isLocal()) + if(p->isLocal()) { O << "local "; } @@ -624,11 +624,11 @@ Slice::Gen::visitStructStart(const StructPtr& p) printComment(p); DataMemberList dataMembers = p->dataMembers(); - if (!dataMembers.empty()) + if(!dataMembers.empty()) { start("section", "Data Member Index"); start("variablelist"); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { start("varlistentry"); start("term"); @@ -646,7 +646,7 @@ Slice::Gen::visitStructStart(const StructPtr& p) end(); { - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); @@ -674,7 +674,7 @@ Slice::Gen::visitEnum(const EnumPtr& p) O.zeroIndent(); O << nl << "<synopsis>"; printMetaData(p); - if (p->isLocal()) + if(p->isLocal()) { O << "local "; } @@ -684,11 +684,11 @@ Slice::Gen::visitEnum(const EnumPtr& p) printComment(p); EnumeratorList enumerators = p->getEnumerators(); - if (!enumerators.empty()) + if(!enumerators.empty()) { start("section", "Enumerator Index"); start("variablelist"); - for (EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q) + for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q) { start("varlistentry"); start("term"); @@ -706,7 +706,7 @@ Slice::Gen::visitEnum(const EnumPtr& p) end(); { - for (EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q) + for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q) { start("section id=" + containedToId(*q), (*q)->name()); O.zeroIndent(); @@ -749,19 +749,19 @@ Slice::Gen::getComment(const ContainedPtr& contained, const ContainerPtr& contai { string s = contained->comment(); string comment; - for (unsigned int i = 0; i < s.size(); ++i) + for(unsigned int i = 0; i < s.size(); ++i) { - if (s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[') + if(s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[') { comment += '['; ++i; } - else if (s[i] == '[') + else if(s[i] == '[') { string literal; - for (++i; i < s.size(); ++i) + for(++i; i < s.size(); ++i) { - if (s[i] == ']') + if(s[i] == ']') { break; } @@ -789,16 +789,16 @@ Slice::Gen::getTagged(const string& tag, string& comment) { StringList result; string::size_type begin = 0; - while (begin < comment.size()) + while(begin < comment.size()) { begin = comment.find("@" + tag, begin); - if (begin == string::npos) + if(begin == string::npos) { return result; } string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1); - if (pos1 == string::npos) + if(pos1 == string::npos) { comment.erase(begin); return result; @@ -809,7 +809,7 @@ Slice::Gen::getTagged(const string& tag, string& comment) comment.erase(begin, pos2 - 1 - begin); string::size_type pos3 = line.find_last_not_of(" \t\r\n"); - if (pos3 != string::npos) + if(pos3 != string::npos) { line.erase(pos3 + 1); } @@ -824,14 +824,14 @@ Slice::Gen::printMetaData(const ContainedPtr& p) { list<string> metaData = p->getMetaData(); - if (!metaData.empty()) + if(!metaData.empty()) { O << "["; list<string>::const_iterator q = metaData.begin(); - while (q != metaData.end()) + while(q != metaData.end()) { O << " \"" << *q << "\""; - if (++q != metaData.end()) + if(++q != metaData.end()) { O << ","; } @@ -844,7 +844,7 @@ void Slice::Gen::printComment(const ContainedPtr& p) { ContainerPtr container = ContainerPtr::dynamicCast(p); - if (!container) + if(!container) { container = p->container(); } @@ -858,7 +858,7 @@ Slice::Gen::printComment(const ContainedPtr& p) start("para"); string::size_type pos = comment.find_last_not_of(" \t\r\n"); - if (pos != string::npos) + if(pos != string::npos) { comment.erase(pos + 1); O.zeroIndent(); @@ -868,22 +868,22 @@ Slice::Gen::printComment(const ContainedPtr& p) end(); - if (!par.empty()) + if(!par.empty()) { start("section", "Parameters"); start("variablelist"); - for (StringList::const_iterator q = par.begin(); q != par.end(); ++q) + for(StringList::const_iterator q = par.begin(); q != par.end(); ++q) { string::size_type pos; string term; pos = q->find_first_of(" \t\r\n"); - if (pos != string::npos) + if(pos != string::npos) { term = q->substr(0, pos); } string item; pos = q->find_first_not_of(" \t\r\n", pos); - if (pos != string::npos) + if(pos != string::npos) { item = q->substr(pos); } @@ -905,7 +905,7 @@ Slice::Gen::printComment(const ContainedPtr& p) end(); } - if (!ret.empty()) + if(!ret.empty()) { start("section", "Return Value"); start("para"); @@ -914,22 +914,22 @@ Slice::Gen::printComment(const ContainedPtr& p) end(); } - if (!throws.empty()) + if(!throws.empty()) { start("section", "Exceptions"); start("variablelist"); - for (StringList::const_iterator q = throws.begin(); q != throws.end(); ++q) + for(StringList::const_iterator q = throws.begin(); q != throws.end(); ++q) { string::size_type pos; string term; pos = q->find_first_of(" \t\r\n"); - if (pos != string::npos) + if(pos != string::npos) { term = q->substr(0, pos); } string item; pos = q->find_first_not_of(" \t\r\n", pos); - if (pos != string::npos) + if(pos != string::npos) { item = q->substr(pos); } @@ -951,16 +951,16 @@ Slice::Gen::printComment(const ContainedPtr& p) ClassList derivedClasses; ClassDefPtr def = ClassDefPtr::dynamicCast(p); - if (def) + if(def) { derivedClasses = p->unit()->findDerivedClasses(def); } - if (!derivedClasses.empty()) + if(!derivedClasses.empty()) { start("section", "Derived Classes and Interfaces"); start("para"); start("simplelist type=\"inline\""); - for (ClassList::const_iterator q = derivedClasses.begin(); q != derivedClasses.end(); ++q) + for(ClassList::const_iterator q = derivedClasses.begin(); q != derivedClasses.end(); ++q) { start("member"); O << nl << toString(*q, container); @@ -973,16 +973,16 @@ Slice::Gen::printComment(const ContainedPtr& p) ExceptionList derivedExceptions; ExceptionPtr ex = ExceptionPtr::dynamicCast(p); - if (ex) + if(ex) { derivedExceptions = p->unit()->findDerivedExceptions(ex); } - if (!derivedExceptions.empty()) + if(!derivedExceptions.empty()) { start("section", "Derived Exceptions"); start("para"); start("simplelist type=\"inline\""); - for (ExceptionList::const_iterator q = derivedExceptions.begin(); q != derivedExceptions.end(); ++q) + for(ExceptionList::const_iterator q = derivedExceptions.begin(); q != derivedExceptions.end(); ++q) { start("member"); O << nl << toString(*q, container); @@ -995,7 +995,7 @@ Slice::Gen::printComment(const ContainedPtr& p) ContainedList usedBy; ConstructedPtr constructed; - if (def) + if(def) { constructed = def->declaration(); } @@ -1003,16 +1003,16 @@ Slice::Gen::printComment(const ContainedPtr& p) { constructed = ConstructedPtr::dynamicCast(p); } - if (constructed) + if(constructed) { usedBy = p->unit()->findUsedBy(constructed); } - if (!usedBy.empty()) + if(!usedBy.empty()) { start("section", "Used By"); start("para"); start("simplelist type=\"inline\""); - for (ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q) + for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q) { start("member"); O << nl << toString(*q, container); @@ -1023,12 +1023,12 @@ Slice::Gen::printComment(const ContainedPtr& p) end(); } - if (!see.empty()) + if(!see.empty()) { start("section", "See Also"); start("para"); start("simplelist type=\"inline\""); - for (StringList::const_iterator q = see.begin(); q != see.end(); ++q) + for(StringList::const_iterator q = see.begin(); q != see.end(); ++q) { start("member"); O << nl << toString(*q, container); @@ -1044,7 +1044,7 @@ void Slice::Gen::printSummary(const ContainedPtr& p) { ContainerPtr container = ContainerPtr::dynamicCast(p); - if (!container) + if(!container) { container = p->container(); } @@ -1085,7 +1085,7 @@ Slice::Gen::containedToId(const ContainedPtr& contained) assert(contained); string scoped = contained->scoped(); - if (scoped[0] == ':') + if(scoped[0] == ':') { scoped.erase(0, 2); } @@ -1093,9 +1093,9 @@ Slice::Gen::containedToId(const ContainedPtr& contained) string id; id.reserve(scoped.size()); - for (unsigned int i = 0; i < scoped.size(); ++i) + for(unsigned int i = 0; i < scoped.size(); ++i) { - if (scoped[i] == ':') + if(scoped[i] == ':') { id += '.'; ++i; @@ -1126,7 +1126,7 @@ Slice::Gen::getScopedMinimized(const ContainedPtr& contained, const ContainerPtr ContainerPtr p = container; ContainedPtr q = ContainedPtr::dynamicCast(p); - if (!q) // Container is the global module + if(!q) // Container is the global module { return s.substr(2); } @@ -1136,7 +1136,7 @@ Slice::Gen::getScopedMinimized(const ContainedPtr& contained, const ContainerPtr string s2 = q->scoped(); s2 += "::"; - if (s.find(s2) == 0) + if(s.find(s2) == 0) { return s.substr(s2.size()); } @@ -1172,16 +1172,16 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, }; BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); - if (builtin) + if(builtin) { s = builtinTable[builtin->kind()]; tag = "type"; } ProxyPtr proxy = ProxyPtr::dynamicCast(p); - if (proxy) + if(proxy) { - if (withLink && proxy->_class()->includeLevel() == 0) + if(withLink && proxy->_class()->includeLevel() == 0) { linkend = containedToId(proxy->_class()); } @@ -1191,14 +1191,14 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(p); - if (cl) + if(cl) { // // We must generate the id from the definition, not from the // declaration, provided that a definition is available. // ContainedPtr definition = cl->definition(); - if (withLink && definition && definition->includeLevel() == 0) + if(withLink && definition && definition->includeLevel() == 0) { linkend = containedToId(definition); } @@ -1207,9 +1207,9 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, } ExceptionPtr ex = ExceptionPtr::dynamicCast(p); - if (ex) + if(ex) { - if (withLink && ex->includeLevel() == 0) + if(withLink && ex->includeLevel() == 0) { linkend = containedToId(ex); } @@ -1218,9 +1218,9 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, } StructPtr st = StructPtr::dynamicCast(p); - if (st) + if(st) { - if (withLink && st->includeLevel() == 0) + if(withLink && st->includeLevel() == 0) { linkend = containedToId(st); } @@ -1229,9 +1229,9 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, } EnumeratorPtr en = EnumeratorPtr::dynamicCast(p); - if (en) + if(en) { - if (withLink && en->includeLevel() == 0) + if(withLink && en->includeLevel() == 0) { linkend = containedToId(en); } @@ -1239,11 +1239,11 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, tag = "constant"; } - if (s.empty()) + if(s.empty()) { ContainedPtr contained = ContainedPtr::dynamicCast(p); assert(contained); - if (withLink && contained->includeLevel() == 0) + if(withLink && contained->includeLevel() == 0) { linkend = containedToId(contained); } @@ -1251,7 +1251,7 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, tag = "type"; } - if (linkend.empty()) + if(linkend.empty()) { return "<" + tag + ">" + s + "</" + tag + ">"; } @@ -1267,13 +1267,13 @@ Slice::Gen::toString(const string& str, const ContainerPtr& container, bool with string s = str; TypeList types = container->lookupType(s, false); - if (!types.empty()) + if(!types.empty()) { return toString(types.front(), container, withLink); } ContainedList contList = container->lookupContained(s, false); - if (!contList.empty()) + if(!contList.empty()) { return toString(contList.front(), container, withLink); } diff --git a/cpp/src/slice2docbook/Gen.h b/cpp/src/slice2docbook/Gen.h index c4aa636875d..e2fad7840d0 100644 --- a/cpp/src/slice2docbook/Gen.h +++ b/cpp/src/slice2docbook/Gen.h @@ -1,67 +1,67 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GEN_H -#define GEN_H - -#include <Slice/Parser.h> -#include <IceUtil/OutputUtil.h> -#include <stack> - -namespace Slice -{ - -class Gen : public ::IceUtil::noncopyable, public ParserVisitor -{ -public: - - Gen(const std::string&, const std::string&, bool, bool, bool); - virtual ~Gen(); - - bool operator!() const; // Returns true if there was a constructor error - - void generate(const UnitPtr&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitContainer(const ContainerPtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitExceptionStart(const ExceptionPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitEnum(const EnumPtr&); - -private: - - void printHeader(); - std::string getComment(const ContainedPtr&, const ContainerPtr&, bool); - StringList getTagged(const std::string&, std::string&); - void printMetaData(const ContainedPtr&); - void printComment(const ContainedPtr&); - void printSummary(const ContainedPtr&); - void start(const std::string&); - void start(const std::string&, const std::string&); - void end(); - - std::string containedToId(const ContainedPtr&); - std::string getScopedMinimized(const ContainedPtr&, const ContainerPtr&); - std::string toString(const SyntaxTreeBasePtr&, const ContainerPtr&, bool = true); - std::string toString(const std::string&, const ContainerPtr&, bool = true); - - ::IceUtil::XMLOutput O; - - bool _standAlone; - bool _noGlobals; - std::string _chapter; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GEN_H
+#define GEN_H
+
+#include <Slice/Parser.h>
+#include <IceUtil/OutputUtil.h>
+#include <stack>
+
+namespace Slice
+{
+
+class Gen : public ::IceUtil::noncopyable, public ParserVisitor
+{
+public:
+
+ Gen(const std::string&, const std::string&, bool, bool, bool);
+ virtual ~Gen();
+
+ bool operator!() const; // Returns true if there was a constructor error
+
+ void generate(const UnitPtr&);
+
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitContainer(const ContainerPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitEnum(const EnumPtr&);
+
+private:
+
+ void printHeader();
+ std::string getComment(const ContainedPtr&, const ContainerPtr&, bool);
+ StringList getTagged(const std::string&, std::string&);
+ void printMetaData(const ContainedPtr&);
+ void printComment(const ContainedPtr&);
+ void printSummary(const ContainedPtr&);
+ void start(const std::string&);
+ void start(const std::string&, const std::string&);
+ void end();
+
+ std::string containedToId(const ContainedPtr&);
+ std::string getScopedMinimized(const ContainedPtr&, const ContainerPtr&);
+ std::string toString(const SyntaxTreeBasePtr&, const ContainerPtr&, bool = true);
+ std::string toString(const std::string&, const ContainerPtr&, bool = true);
+
+ ::IceUtil::XMLOutput O;
+
+ bool _standAlone;
+ bool _noGlobals;
+ std::string _chapter;
+};
+
+}
+
+#endif
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 9fc7c400144..0918a2f10d2 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -45,77 +45,77 @@ main(int argc, char* argv[]) bool chapter = false; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-s") == 0 || strcmp(argv[idx], "--stand-alone") == 0) + else if(strcmp(argv[idx], "-s") == 0 || strcmp(argv[idx], "--stand-alone") == 0) { standAlone = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--no-globals") == 0) + else if(strcmp(argv[idx], "--no-globals") == 0) { noGlobals = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--chapter") == 0) + else if(strcmp(argv[idx], "--chapter") == 0) { chapter = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -127,7 +127,7 @@ main(int argc, char* argv[]) } } - if (argc < 2) + if(argc < 2) { cerr << argv[0] << ": no docbook file specified" << endl; usage(argv[0]); @@ -137,18 +137,18 @@ main(int argc, char* argv[]) string docbook(argv[1]); string suffix; string::size_type pos = docbook.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = docbook.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".sgml") + if(suffix != ".sgml") { cerr << argv[0] << ": docbook file must end with `.sgml'" << endl; return EXIT_FAILURE; } - if (argc < 3) + if(argc < 3) { cerr << argv[0] << ": no input file" << endl; usage(argv[0]); @@ -159,17 +159,17 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - for (idx = 2 ; idx < argc ; ++idx) + for(idx = 2 ; idx < argc ; ++idx) { string file(argv[idx]); string suffix; string::size_type pos = file.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = file.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; unit->destroy(); @@ -177,7 +177,7 @@ main(int argc, char* argv[]) } ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; unit->destroy(); @@ -191,7 +191,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; unit->destroy(); @@ -208,10 +208,10 @@ main(int argc, char* argv[]) } - if (status == EXIT_SUCCESS) + if(status == EXIT_SUCCESS) { Gen gen(argv[0], docbook, standAlone, noGlobals, chapter); - if (!gen) + if(!gen) { unit->destroy(); return EXIT_FAILURE; diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index cb2aaf11a88..d7d6e2168c3 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -49,15 +49,15 @@ usage(const char* n) bool checkIdentifier(string n, string t, string s) { - if (s.empty() || (!isalpha(s[0]) && s[0] != '_')) + if(s.empty() || (!isalpha(s[0]) && s[0] != '_')) { cerr << n << ": `" << t << "' is not a valid type name" << endl; return false; } - for (unsigned int i = 1; i < s.size(); ++i) + for(unsigned int i = 1; i < s.size(); ++i) { - if (!isalnum(s[i]) && s[i] != '_') + if(!isalnum(s[i]) && s[i] != '_') { cerr << n << ": `" << t << "' is not a valid type name" << endl; return false; @@ -72,7 +72,7 @@ printFreezeTypes(Output& out, const vector<Dict>& dicts) { out << '\n'; out << "\n// Freeze types in this file:"; - for (vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p) + for(vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p) { out << "\n// name=\"" << p->name << "\", key=\"" << p->key << "\", value=\"" << p->value << "\""; } @@ -122,19 +122,19 @@ bool writeCodecs(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& C, const string& dllExport) { string absolute = dict.name; - if (absolute.find("::") == 0) + if(absolute.find("::") == 0) { absolute.erase(0, 2); } string name = absolute; vector<string> scope; string::size_type pos; - while ((pos = name.find("::")) != string::npos) + while((pos = name.find("::")) != string::npos) { string s = name.substr(0, pos); name.erase(0, pos + 2); - if (!checkIdentifier(n, absolute, s)) + if(!checkIdentifier(n, absolute, s)) { return false; } @@ -142,13 +142,13 @@ writeCodecs(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& scope.push_back(s); } - if (!checkIdentifier(n, absolute, name)) + if(!checkIdentifier(n, absolute, name)) { return false; } TypeList keyTypes = unit->lookupType(dict.key, false); - if (keyTypes.empty()) + if(keyTypes.empty()) { cerr << n << ": `" << dict.key << "' is not a valid type" << endl; return false; @@ -156,7 +156,7 @@ writeCodecs(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& TypePtr keyType = keyTypes.front(); TypeList valueTypes = unit->lookupType(dict.value, false); - if (valueTypes.empty()) + if(valueTypes.empty()) { cerr << n << ": `" << dict.value << "' is not a valid type" << endl; return false; @@ -165,7 +165,7 @@ writeCodecs(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& vector<string>::const_iterator q; - for (q = scope.begin(); q != scope.end(); ++q) + for(q = scope.begin(); q != scope.end(); ++q) { H << sp; H << nl << "namespace " << *q << nl << '{'; @@ -177,7 +177,7 @@ writeCodecs(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& H << sp << nl << "typedef Freeze::DBMap< " << typeToString(keyType) << ", " << typeToString(valueType) << ", " << name << "KeyCodec, " << name << "ValueCodec> " << name << ";"; - for (q = scope.begin(); q != scope.end(); ++q) + for(q = scope.begin(); q != scope.end(); ++q) { H << sp; H << nl << '}'; @@ -201,39 +201,39 @@ main(int argc, char* argv[]) vector<Dict> dicts; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; string path = argv[idx] + 2; - if (path.length()) + if(path.length()) { includePaths.push_back(path); } - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--dict") == 0) + else if(strcmp(argv[idx], "--dict") == 0) { - if (idx + 1 >= argc || argv[idx + 1][0] == '-') + if(idx + 1 >= argc || argv[idx + 1][0] == '-') { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -247,34 +247,34 @@ main(int argc, char* argv[]) string::size_type pos; pos = s.find(','); - if (pos != string::npos) + if(pos != string::npos) { dict.name = s.substr(0, pos); s.erase(0, pos + 1); } pos = s.find(','); - if (pos != string::npos) + if(pos != string::npos) { dict.key = s.substr(0, pos); s.erase(0, pos + 1); } dict.value = s; - if (dict.name.empty()) + if(dict.name.empty()) { cerr << argv[0] << ": " << argv[idx] << ": no name specified" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (dict.key.empty()) + if(dict.key.empty()) { cerr << argv[0] << ": " << argv[idx] << ": no key specified" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (dict.value.empty()) + if(dict.value.empty()) { cerr << argv[0] << ": " << argv[idx] << ": no value specified" << endl; usage(argv[0]); @@ -283,34 +283,34 @@ main(int argc, char* argv[]) dicts.push_back(dict); - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--include-dir") == 0) + else if(strcmp(argv[idx], "--include-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -318,15 +318,15 @@ main(int argc, char* argv[]) } include = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--dll-export") == 0) + else if(strcmp(argv[idx], "--dll-export") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -334,15 +334,15 @@ main(int argc, char* argv[]) } dllExport = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--output-dir") == 0) + else if(strcmp(argv[idx], "--output-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -350,13 +350,13 @@ main(int argc, char* argv[]) } output = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -368,14 +368,14 @@ main(int argc, char* argv[]) } } - if (dicts.empty()) + if(dicts.empty()) { cerr << argv[0] << ": no Freeze types specified" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (argc < 2) + if(argc < 2) { cerr << argv[0] << ": no file name base specified" << endl; usage(argv[0]); @@ -386,7 +386,7 @@ main(int argc, char* argv[]) fileH += ".h"; string fileC = argv[1]; fileC += ".cpp"; - if (!output.empty()) + if(!output.empty()) { fileH = output + '/' + fileH; fileC = output + '/' + fileC; @@ -398,17 +398,17 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - for (idx = 2 ; idx < argc ; ++idx) + for(idx = 2 ; idx < argc ; ++idx) { string base(argv[idx]); string suffix; string::size_type pos = base.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = base.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; return EXIT_FAILURE; @@ -418,7 +418,7 @@ main(int argc, char* argv[]) includes.push_back(base + ".h"); ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -431,7 +431,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; unit->destroy(); @@ -447,15 +447,15 @@ main(int argc, char* argv[]) #endif } - if (status == EXIT_SUCCESS) + if(status == EXIT_SUCCESS) { unit->mergeModules(); unit->sort(); { - for (vector<string>::iterator p = includePaths.begin(); p != includePaths.end(); ++p) + for(vector<string>::iterator p = includePaths.begin(); p != includePaths.end(); ++p) { - if (p->length() && (*p)[p->length() - 1] != '/') + if(p->length() && (*p)[p->length() - 1] != '/') { *p += '/'; } @@ -464,7 +464,7 @@ main(int argc, char* argv[]) Output H; H.open(fileH.c_str()); - if (!H) + if(!H) { cerr << argv[0] << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl; unit->destroy(); @@ -475,7 +475,7 @@ main(int argc, char* argv[]) Output C; C.open(fileC.c_str()); - if (!C) + if(!C) { cerr << argv[0] << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl; unit->destroy(); @@ -492,7 +492,7 @@ main(int argc, char* argv[]) H << "\n#include <Freeze/Map.h>"; { - for (StringList::const_iterator p = includes.begin(); p != includes.end(); ++p) + for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p) { H << "\n#include <" << changeInclude(*p, includePaths) << ".h>"; } @@ -500,7 +500,7 @@ main(int argc, char* argv[]) C << "\n#include <Ice/BasicStream.h>"; C << "\n#include <"; - if (include.size()) + if(include.size()) { C << include << '/'; } @@ -510,17 +510,17 @@ main(int argc, char* argv[]) printVersionCheck(C); printDllExportStuff(H, dllExport); - if (dllExport.size()) + if(dllExport.size()) { dllExport += " "; } { - for (vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p) + for(vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p) { try { - if (!writeCodecs(argv[0], unit, *p, H, C, dllExport)) + if(!writeCodecs(argv[0], unit, *p, H, C, dllExport)) { unit->destroy(); return EXIT_FAILURE; diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 3db69abe047..02cda7ace4c 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -59,7 +59,7 @@ FreezeGenerator::generate(UnitPtr& unit, const Dict& dict) string name; string::size_type pos = dict.name.rfind('.'); - if (pos == string::npos) + if(pos == string::npos) { name = dict.name; } @@ -69,7 +69,7 @@ FreezeGenerator::generate(UnitPtr& unit, const Dict& dict) } TypeList keyTypes = unit->lookupType(dict.key, false); - if (keyTypes.empty()) + if(keyTypes.empty()) { cerr << _prog << ": `" << dict.key << "' is not a valid type" << endl; return false; @@ -77,14 +77,14 @@ FreezeGenerator::generate(UnitPtr& unit, const Dict& dict) TypePtr keyType = keyTypes.front(); TypeList valueTypes = unit->lookupType(dict.value, false); - if (valueTypes.empty()) + if(valueTypes.empty()) { cerr << _prog << ": `" << dict.value << "' is not a valid type" << endl; return false; } TypePtr valueType = valueTypes.front(); - if (!open(dict.name)) + if(!open(dict.name)) { cerr << _prog << ": unable to open class " << dict.name << endl; return false; @@ -106,12 +106,12 @@ FreezeGenerator::generate(UnitPtr& unit, const Dict& dict) // // encode/decode // - for (int i = 0; i < 2; i++) + for(int i = 0; i < 2; i++) { string keyValue; TypePtr type; - if (i == 0) + if(i == 0) { keyValue = "Key"; type = keyType; @@ -124,10 +124,10 @@ FreezeGenerator::generate(UnitPtr& unit, const Dict& dict) string typeS, valS; BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if (b) + if(b) { typeS = builtinTable[b->kind()]; - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -221,9 +221,9 @@ FreezeGenerator::generate(UnitPtr& unit, const Dict& dict) out << nl << "__buf.position(0);"; iter = 0; out << nl << typeS << " __r;"; - if (b) + if(b) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -323,39 +323,39 @@ main(int argc, char* argv[]) vector<Dict> dicts; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; string path = argv[idx] + 2; - if (path.length()) + if(path.length()) { includePaths.push_back(path); } - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--dict") == 0) + else if(strcmp(argv[idx], "--dict") == 0) { - if (idx + 1 >= argc || argv[idx + 1][0] == '-') + if(idx + 1 >= argc || argv[idx + 1][0] == '-') { cerr << argv[0] << ": argument expected for `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -369,34 +369,34 @@ main(int argc, char* argv[]) string::size_type pos; pos = s.find(','); - if (pos != string::npos) + if(pos != string::npos) { dict.name = s.substr(0, pos); s.erase(0, pos + 1); } pos = s.find(','); - if (pos != string::npos) + if(pos != string::npos) { dict.key = s.substr(0, pos); s.erase(0, pos + 1); } dict.value = s; - if (dict.name.empty()) + if(dict.name.empty()) { cerr << argv[0] << ": " << argv[idx] << ": no name specified" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (dict.key.empty()) + if(dict.key.empty()) { cerr << argv[0] << ": " << argv[idx] << ": no key specified" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (dict.value.empty()) + if(dict.value.empty()) { cerr << argv[0] << ": " << argv[idx] << ": no value specified" << endl; usage(argv[0]); @@ -405,34 +405,34 @@ main(int argc, char* argv[]) dicts.push_back(dict); - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--include-dir") == 0) + else if(strcmp(argv[idx], "--include-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -440,15 +440,15 @@ main(int argc, char* argv[]) } include = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--output-dir") == 0) + else if(strcmp(argv[idx], "--output-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -456,13 +456,13 @@ main(int argc, char* argv[]) } output = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -474,7 +474,7 @@ main(int argc, char* argv[]) } } - if (dicts.empty()) + if(dicts.empty()) { cerr << argv[0] << ": no Freeze types specified" << endl; usage(argv[0]); @@ -487,24 +487,24 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { string base(argv[idx]); string suffix; string::size_type pos = base.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = base.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; return EXIT_FAILURE; } ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -517,7 +517,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; unit->destroy(); @@ -533,18 +533,18 @@ main(int argc, char* argv[]) #endif } - if (status == EXIT_SUCCESS) + if(status == EXIT_SUCCESS) { unit->mergeModules(); unit->sort(); FreezeGenerator gen(argv[0], output); - for (vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p) + for(vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p) { try { - if (!gen.generate(unit, *p)) + if(!gen.generate(unit, *p)) { unit->destroy(); return EXIT_FAILURE; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 92a2ae38f03..452bc302622 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -34,9 +34,9 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& scope) string params; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { - if (q != inParams.begin()) + if(q != inParams.begin()) { params += ", "; } @@ -47,9 +47,9 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& scope) params += fixKwd(q->second); } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { - if (q != outParams.begin() || !inParams.empty()) + if(q != outParams.begin() || !inParams.empty()) { params += ", "; } @@ -72,9 +72,9 @@ Slice::JavaVisitor::getArgs(const OperationPtr& op, const string& scope) string args; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { - if (q != inParams.begin()) + if(q != inParams.begin()) { args += ", "; } @@ -82,9 +82,9 @@ Slice::JavaVisitor::getArgs(const OperationPtr& op, const string& scope) args += fixKwd(q->second); } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { - if (q != outParams.begin() || !inParams.empty()) + if(q != outParams.begin() || !inParams.empty()) { args += ", "; } @@ -118,7 +118,7 @@ Slice::JavaVisitor::writeThrowsClause(const string& scope, localCount = count_if(throws.begin(), throws.end(), exceptionIsLocal); Output& out = output(); - if (throws.size() - localCount > 0) + if(throws.size() - localCount > 0) { out.inc(); out << nl; @@ -126,11 +126,11 @@ Slice::JavaVisitor::writeThrowsClause(const string& scope, out.useCurrentPosAsIndent(); ExceptionList::const_iterator r; int count = 0; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { - if (!(*r)->isLocal()) + if(!(*r)->isLocal()) { - if (count > 0) + if(count > 0) { out << "," << nl; } @@ -159,9 +159,9 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& scope, // Don't include local exceptions in the throws clause // ExceptionList::const_iterator r; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { - if (!(*r)->isLocal()) + if(!(*r)->isLocal()) { out << "," << nl; out << getAbsolute((*r)->scoped(), scope); @@ -176,9 +176,9 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string const list<string>& metaData) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - switch (builtin->kind()) + switch(builtin->kind()) { case Builtin::KindByte: case Builtin::KindShort: @@ -218,7 +218,7 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string case Builtin::KindObjectProxy: case Builtin::KindLocalObject: { - out << nl << "if (" << name << " != null)"; + out << nl << "if(" << name << " != null)"; out << sb; out << nl << "__h = 5 * __h + " << name << ".hashCode();"; out << eb; @@ -229,9 +229,9 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string } ProxyPtr prx = ProxyPtr::dynamicCast(type); - if (prx) + if(prx) { - out << nl << "if (" << name << " != null)"; + out << nl << "if(" << name << " != null)"; out << sb; out << nl << "__h = 5 * __h + " << name << ".hashCode();"; out << eb; @@ -239,9 +239,9 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if (cl) + if(cl) { - out << nl << "if (" << name << " != null)"; + out << nl << "if(" << name << " != null)"; out << sb; out << nl << "__h = 5 * __h + " << name << ".hashCode();"; out << eb; @@ -249,22 +249,22 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string } SequencePtr seq = SequencePtr::dynamicCast(type); - if (seq) + if(seq) { string listType = findMetaData(metaData); - if (listType.empty()) + if(listType.empty()) { list<string> l = seq->getMetaData(); listType = findMetaData(l); } - if (!listType.empty()) + if(!listType.empty()) { out << nl << "__h = 5 * __h + " << name << ".hashCode();"; } else { - out << nl << "for (int __i" << iter << " = 0; __i" << iter + out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << name << ".length; __i" << iter << "++)"; out << sb; ostringstream elem; @@ -308,10 +308,10 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) out << sp << nl << "public static final String[] __ids ="; out << sb; q = ids.begin(); - while (q != ids.end()) + while(q != ids.end()) { out << nl << '"' << *q << '"'; - if (++q != ids.end()) + if(++q != ids.end()) { out << ','; } @@ -360,7 +360,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // OperationList ops = p->operations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); ContainerPtr container = op->container(); @@ -391,11 +391,11 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // remove_if(throws.begin(), throws.end(), exceptionIsLocal); - if (!inParams.empty()) + if(!inParams.empty()) { out << nl << "IceInternal.BasicStream __is = __in.is();"; } - if (!outParams.empty() || ret || throws.size() > 0) + if(!outParams.empty() || ret || throws.size() > 0) { out << nl << "IceInternal.BasicStream __os = __in.os();"; } @@ -404,7 +404,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // Unmarshal 'in' params // iter = 0; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { string typeS = typeToString(q->first, TypeModeIn, scope); out << nl << typeS << ' ' << fixKwd(q->second) << ';'; @@ -414,13 +414,13 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // // Create holders for 'out' params // - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { string typeS = typeToString(q->first, TypeModeOut, scope); out << nl << typeS << ' ' << fixKwd(q->second) << " = new " << typeS << "();"; } - if (!throws.empty()) + if(!throws.empty()) { out << nl << "try"; out << sb; @@ -430,16 +430,16 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // Call servant // out << nl; - if (ret) + if(ret) { out << retS << " __ret = "; } out << "__obj." << opName << '('; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { out << fixKwd(q->second) << ", "; } - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { out << fixKwd(q->second) << ", "; } @@ -448,14 +448,14 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // // Marshal 'out' params // - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), true, iter, true); } // // Marshal result // - if (ret) + if(ret) { writeMarshalUnmarshalCode(out, scope, ret, "__ret", true, iter); } @@ -465,11 +465,11 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // // User exceptions // - if (!throws.empty()) + if(!throws.empty()) { out << eb; ExceptionList::const_iterator r; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { string exS = getAbsolute((*r)->scoped(), scope); out << nl << "catch (" << exS << " ex)"; @@ -487,7 +487,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // __dispatch // OperationList allOps = p->allOperations(); - if (!allOps.empty()) + if(!allOps.empty()) { StringList allOpNames; transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), @@ -505,10 +505,10 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) out << sp << nl << "private final static String[] __all ="; out << sb; q = allOpNames.begin(); - while (q != allOpNames.end()) + while(q != allOpNames.end()) { out << nl << '"' << *q << '"'; - if (++q != allOpNames.end()) + if(++q != allOpNames.end()) { out << ','; } @@ -519,36 +519,36 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) << nl << "__dispatch(IceInternal.Incoming in, Ice.Current current)"; out << sb; out << nl << "int pos = java.util.Arrays.binarySearch(__all, current.operation);"; - out << nl << "if (pos < 0)"; + out << nl << "if(pos < 0)"; out << sb; out << nl << "return IceInternal.DispatchStatus.DispatchOperationNotExist;"; out << eb; - out << sp << nl << "switch (pos)"; + out << sp << nl << "switch(pos)"; out << sb; int i = 0; - for (q = allOpNames.begin(); q != allOpNames.end(); ++q) + for(q = allOpNames.begin(); q != allOpNames.end(); ++q) { string opName = fixKwd(*q); out << nl << "case " << i++ << ':'; out << sb; - if (opName == "ice_facets") + if(opName == "ice_facets") { out << nl << "return ___ice_facets(this, in, current);"; } - else if (opName == "ice_id") + else if(opName == "ice_id") { out << nl << "return ___ice_id(this, in, current);"; } - else if (opName == "ice_ids") + else if(opName == "ice_ids") { out << nl << "return ___ice_ids(this, in, current);"; } - else if (opName == "ice_isA") + else if(opName == "ice_isA") { out << nl << "return ___ice_isA(this, in, current);"; } - else if (opName == "ice_ping") + else if(opName == "ice_ping") { out << nl << "return ___ice_ping(this, in, current);"; } @@ -557,21 +557,21 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // // There's probably a better way to do this // - for (OperationList::const_iterator r = allOps.begin(); r != allOps.end(); ++r) + for(OperationList::const_iterator r = allOps.begin(); r != allOps.end(); ++r) { - if ((*r)->name() == (*q)) + if((*r)->name() == (*q)) { ContainerPtr container = (*r)->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); assert(cl); - if (cl->scoped() == p->scoped()) + if(cl->scoped() == p->scoped()) { out << nl << "return ___" << opName << "(this, in, current);"; } else { string base; - if (cl->isInterface()) + if(cl->isInterface()) { base = getAbsolute(cl->scoped(), scope, "_", "Disp"); } @@ -684,12 +684,12 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) // // Don't generate an Operations interface for non-abstract classes // - if (!p->isAbstract()) + if(!p->isAbstract()) { return false; } - if (!open(absolute + "Operations")) + if(!open(absolute + "Operations")) { return false; } @@ -700,17 +700,17 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) // Generate the operations interface // out << sp << nl << "public interface " << name << "Operations"; - if ((bases.size() == 1 && bases.front()->isAbstract()) || bases.size() > 1) + if((bases.size() == 1 && bases.front()->isAbstract()) || bases.size() > 1) { out << " extends "; out.useCurrentPosAsIndent(); ClassList::const_iterator q = bases.begin(); bool first = true; - while (q != bases.end()) + while(q != bases.end()) { - if ((*q)->isAbstract()) + if((*q)->isAbstract()) { - if (!first) + if(!first) { out << ',' << nl; } @@ -756,9 +756,9 @@ Slice::Gen::OpsVisitor::visitOperation(const OperationPtr& p) out << sp; out << nl; out << retS << ' ' << name << '(' << params; - if (!cl->isLocal()) + if(!cl->isLocal()) { - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -791,12 +791,12 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) // // Don't generate a TIE class for a non-abstract class // - if (!p->isAbstract()) + if(!p->isAbstract()) { return false; } - if (!open(absolute + "Tie")) + if(!open(absolute + "Tie")) { return false; } @@ -807,9 +807,9 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) // Generate the TIE class // out << sp << nl << "public class " << name << "Tie"; - if (p->isInterface()) + if(p->isInterface()) { - if (p->isLocal()) + if(p->isLocal()) { out << " implements " << name; } @@ -846,11 +846,11 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp << nl << "public boolean" << nl << "equals(java.lang.Object rhs)"; out << sb; - out << nl << "if (this == rhs)"; + out << nl << "if(this == rhs)"; out << sb; out << nl << "return true;"; out << eb; - out << nl << "if (!(rhs instanceof " << name << "Tie))"; + out << nl << "if(!(rhs instanceof " << name << "Tie))"; out << sb; out << nl << "return false;"; out << eb; @@ -864,7 +864,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->allOperations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { string opName = fixKwd((*r)->name()); @@ -877,9 +877,9 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp; out << nl; out << "public " << retS << nl << opName << '(' << params; - if (!p->isLocal()) + if(!p->isLocal()) { - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -893,14 +893,14 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) writeThrowsClause(scope, throws); out << sb; out << nl; - if (ret) + if(ret) { out << "return "; } out << "_ice_delegate." << opName << '(' << args; - if (!p->isLocal()) + if(!p->isLocal()) { - if (!args.empty()) + if(!args.empty()) { out << ", "; } @@ -934,7 +934,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -944,15 +944,15 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // // Local interfaces map to Java interfaces // - if (p->isInterface()) + if(p->isInterface()) { out << sp << nl << "public interface " << name << " extends "; out.useCurrentPosAsIndent(); out << name << "Operations"; - if (!bases.empty()) + if(!bases.empty()) { ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { out << ',' << nl << getAbsolute((*q)->scoped(), scope); q++; @@ -963,15 +963,15 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) else { out << sp << nl << "public "; - if (p->isAbstract()) + if(p->isAbstract()) { out << "abstract "; } out << "class " << name; out.useCurrentPosAsIndent(); - if (bases.empty() || bases.front()->isInterface()) + if(bases.empty() || bases.front()->isInterface()) { - if (p->isLocal()) + if(p->isLocal()) { out << " extends Ice.LocalObject"; } @@ -992,33 +992,33 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // Implement interfaces // StringList implements; - if (p->isAbstract()) + if(p->isAbstract()) { implements.push_back(name + "Operations"); } - if (!bases.empty()) + if(!bases.empty()) { ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { implements.push_back(getAbsolute((*q)->scoped(), scope)); q++; } } - if (_clone && !p->isAbstract()) + if(_clone && !p->isAbstract()) { implements.push_back("java.lang.Cloneable"); } - if (!implements.empty()) + if(!implements.empty()) { out << nl << " implements "; out.useCurrentPosAsIndent(); StringList::const_iterator q = implements.begin(); - while (q != implements.end()) + while(q != implements.end()) { - if (q != implements.begin()) + if(q != implements.begin()) { out << nl << ','; } @@ -1037,13 +1037,13 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // // hashCode // - if (!p->isInterface()) + if(!p->isInterface()) { bool baseHasDataMembers = false; ClassList l = p->bases(); - while (!l.empty() && !l.front()->isInterface()) + while(!l.empty() && !l.front()->isInterface()) { - if (l.front()->hasDataMembers()) + if(l.front()->hasDataMembers()) { baseHasDataMembers = true; break; @@ -1051,12 +1051,12 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) l = l.front()->bases(); } - if (p->hasDataMembers() || baseHasDataMembers) + if(p->hasDataMembers() || baseHasDataMembers) { out << sp << nl << "public int" << nl << "hashCode()"; out << sb; - if (p->hasDataMembers()) + if(p->hasDataMembers()) { DataMemberList members = p->dataMembers(); DataMemberList::const_iterator d; @@ -1064,13 +1064,13 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "int __h = 0;"; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); list<string> metaData = (*d)->getMetaData(); writeHashCode(out, (*d)->type(), memberName, iter, metaData); } - if (baseHasDataMembers) + if(baseHasDataMembers) { out << nl << "__h = 5 * __h + super.hashCode();"; } @@ -1087,7 +1087,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // // clone // - if (_clone && !p->isAbstract()) + if(_clone && !p->isAbstract()) { out << sp << nl << "public java.lang.Object" << nl << "clone()"; @@ -1098,15 +1098,15 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // Perform a shallow copy. Start with the base members. // ClassList cl = p->bases(); - while (!cl.empty()) + while(!cl.empty()) { - if (cl.front()->isAbstract()) + if(cl.front()->isAbstract()) { break; } DataMemberList members = cl.front()->dataMembers(); DataMemberList::const_iterator d; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); out << nl << "__result." << memberName << " = " << memberName << ';'; @@ -1117,7 +1117,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) DataMemberList members = p->dataMembers(); DataMemberList::const_iterator d; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); out << nl << "__result." << memberName << " = " << memberName << ';'; @@ -1127,7 +1127,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; } - if (!p->isAbstract()) + if(!p->isAbstract()) { out << sp; out << nl << "private static class __F implements Ice.ObjectFactory"; @@ -1149,7 +1149,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; } - if (!p->isInterface() && !p->isLocal()) + if(!p->isInterface() && !p->isLocal()) { // // __dispatch, etc. @@ -1167,7 +1167,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) << nl << "__write(IceInternal.BasicStream __os)"; out << sb; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { list<string> metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData); @@ -1182,7 +1182,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) << nl << "__read(IceInternal.BasicStream __is)"; out << sb; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { list<string> metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData); @@ -1197,7 +1197,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << sb; out << nl << "super.__marshal(__os);"; // Base must come first (due to schema rules). iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string s = (*d)->name(); list<string> metaData = (*d)->getMetaData(); @@ -1213,7 +1213,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << sb; out << nl << "super.__unmarshal(__is);"; // Base must come first (due to schema rules). iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string s = (*d)->name(); list<string> metaData = (*d)->getMetaData(); @@ -1254,7 +1254,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -1263,9 +1263,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) out << sp << nl << "public class " << name << " extends "; - if (!base) + if(!base) { - if (p->isLocal()) + if(p->isLocal()) { out << "Ice.LocalException"; } @@ -1285,7 +1285,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) out << nl << "return \"" << scoped.substr(2) << "\";"; out << eb; - if (!p->isLocal()) + if(!p->isLocal()) { ExceptionList allBases = p->allBases(); StringList exceptionIds; @@ -1300,10 +1300,10 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) out << sp << nl << "private static final String[] __exceptionIds ="; out << sb; q = exceptionIds.begin(); - while (q != exceptionIds.end()) + while(q != exceptionIds.end()) { out << nl << '"' << *q << '"'; - if (++q != exceptionIds.end()) + if(++q != exceptionIds.end()) { out << ','; } @@ -1323,7 +1323,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { Output& out = output(); - if (!p->isLocal()) + if(!p->isLocal()) { string name = fixKwd(p->name()); string scoped = p->scoped(); @@ -1341,12 +1341,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) << nl << "__write(IceInternal.BasicStream __os)"; out << sb; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { list<string> metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData); } - if (base) + if(base) { out << nl << "super.__write(__os);"; } @@ -1359,12 +1359,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) << nl << "__read(IceInternal.BasicStream __is)"; out << sb; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { list<string> metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData); } - if (base) + if(base) { out << nl << "super.__read(__is);"; } @@ -1376,12 +1376,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) out << sp << nl << "public void" << nl << "__marshal(Ice.Stream __os)"; out << sb; - if (base) + if(base) { out << nl << "super.__marshal(__os);"; // Base must come first (due to schema rules). } iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string s = (*d)->name(); list<string> metaData = (*d)->getMetaData(); @@ -1396,12 +1396,12 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) out << sp << nl << "public void" << nl << "__unmarshal(Ice.Stream __is)"; out << sb; - if (base) + if(base) { out << nl << "super.__unmarshal(__is);"; // Base must come first (due to schema rules). } iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string s = (*d)->name(); list<string> metaData = (*d)->getMetaData(); @@ -1432,7 +1432,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) string scoped = p->scoped(); string absolute = getAbsolute(scoped); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -1440,7 +1440,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) Output& out = output(); out << sp << nl << "public final class " << name; - if (_clone) + if(_clone) { out << " implements java.lang.Cloneable"; } @@ -1462,7 +1462,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) string typeS = typeToString(p, TypeModeIn, scope); - if (!members.empty()) + if(!members.empty()) { // // equals @@ -1478,15 +1478,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << nl << "catch (ClassCastException ex)"; out << sb; out << eb; - out << sp << nl << "if (_r != null)"; + out << sp << nl << "if(_r != null)"; out << sb; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); BuiltinPtr b = BuiltinPtr::dynamicCast((*d)->type()); - if (b) + if(b) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: case Builtin::KindBool: @@ -1496,7 +1496,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) case Builtin::KindFloat: case Builtin::KindDouble: { - out << nl << "if (" << memberName << " != _r." << memberName << ")"; + out << nl << "if(" << memberName << " != _r." << memberName << ")"; out << sb; out << nl << "return false;"; out << eb; @@ -1508,7 +1508,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) case Builtin::KindObjectProxy: case Builtin::KindLocalObject: { - out << nl << "if (!" << memberName << ".equals(_r." << memberName << "))"; + out << nl << "if(!" << memberName << ".equals(_r." << memberName << "))"; out << sb; out << nl << "return false;"; out << eb; @@ -1518,7 +1518,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } else { - out << nl << "if (!" << memberName << ".equals(_r." << memberName << "))"; + out << nl << "if(!" << memberName << ".equals(_r." << memberName << "))"; out << sb; out << nl << "return false;"; out << eb; @@ -1537,7 +1537,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << sb; out << nl << "int __h = 0;"; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); list<string> metaData = (*d)->getMetaData(); @@ -1550,7 +1550,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) // // clone() // - if (_clone) + if(_clone) { string name = fixKwd(p->name()); @@ -1563,7 +1563,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) // Perform a shallow copy. // DataMemberList::const_iterator d; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); out << nl << "__result." << memberName << " = " << memberName << ';'; @@ -1573,7 +1573,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << eb; } - if (!p->isLocal()) + if(!p->isLocal()) { // // __write @@ -1581,7 +1581,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << sp << nl << "public final void" << nl << "__write(IceInternal.BasicStream __os)"; out << sb; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { list<string> metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData); @@ -1594,7 +1594,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << sp << nl << "public final void" << nl << "__read(IceInternal.BasicStream __is)"; out << sb; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { list<string> metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, scope, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData); @@ -1609,7 +1609,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << sb; out << nl << "__os.startWriteStruct(__name);"; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string s = (*d)->name(); list<string> metaData = (*d)->getMetaData(); @@ -1627,7 +1627,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << sb; out << nl << "__is.startReadStruct(__name);"; iter = 0; - for (d = members.begin(); d != members.end(); ++d) + for(d = members.begin(); d != members.end(); ++d) { string s = (*d)->name(); list<string> metaData = (*d)->getMetaData(); @@ -1664,7 +1664,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) EnumeratorList::const_iterator en; int sz = enumerators.size(); - if (!open(absolute)) + if(!open(absolute)) { return; } @@ -1678,7 +1678,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << nl << "private int __value;"; out << sp; int n; - for (en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) + for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) { string member = fixKwd((*en)->name()); out << nl << "public static final int _" << member << " = " @@ -1704,7 +1704,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << nl << "__values[val] = this;"; out << eb; - if (!p->isLocal()) + if(!p->isLocal()) { // // __write @@ -1712,11 +1712,11 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp << nl << "public final void" << nl << "__write(IceInternal.BasicStream __os)"; out << sb; - if (sz <= 0x7f) + if(sz <= 0x7f) { out << nl << "__os.writeByte((byte)__value);"; } - else if (sz <= 0x7fff) + else if(sz <= 0x7fff) { out << nl << "__os.writeShort((short)__value);"; } @@ -1732,11 +1732,11 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp << nl << "public static " << name << nl << "__read(IceInternal.BasicStream __is)"; out << sb; - if (sz <= 0x7f) + if(sz <= 0x7f) { out << nl << "int __v = __is.readByte();"; } - else if (sz <= 0x7fff) + else if(sz <= 0x7fff) { out << nl << "int __v = __is.readShort();"; } @@ -1750,10 +1750,10 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << sp << nl << "final static private String[] __T ="; out << sb; en = enumerators.begin(); - while (en != enumerators.end()) + while(en != enumerators.end()) { out << nl << "\"" << (*en)->name() << "\""; - if (++en != enumerators.end()) + if(++en != enumerators.end()) { out << ','; } @@ -1794,12 +1794,12 @@ Slice::Gen::HolderVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDeclPtr decl = p->declaration(); writeHolder(decl); - if (!p->isLocal()) + if(!p->isLocal()) { string name = fixKwd(p->name()); string absolute = getAbsolute(p->scoped()); - if (open(absolute + "PrxHolder")) + if(open(absolute + "PrxHolder")) { Output& out = output(); out << sp << nl << "public final class " << name << "PrxHolder"; @@ -1854,7 +1854,7 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) string absolute = getAbsolute(contained->scoped()); string holder = absolute + "Holder"; - if (open(holder)) + if(open(holder)) { Output& out = output(); string typeS = typeToString(p, TypeModeIn, contained->scope()); @@ -1882,7 +1882,7 @@ Slice::Gen::HelperVisitor::HelperVisitor(const string& dir, bool Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -1896,7 +1896,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped); - if (!open(absolute + "PrxHelper")) + if(!open(absolute + "PrxHelper")) { return false; } @@ -1917,7 +1917,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->allOperations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); string opName = fixKwd(op->name()); @@ -1942,12 +1942,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) writeThrowsClause(scope, throws); out << sb; out << nl; - if (ret) + if(ret) { out << "return "; } out << opName << '(' << args; - if (!args.empty()) + if(!args.empty()) { out << ", "; } @@ -1957,7 +1957,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp; out << nl; out << "public final " << retS << nl << opName << '(' << params; - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -1965,7 +1965,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) writeThrowsClause(scope, throws); out << sb; out << nl << "int __cnt = 0;"; - out << nl << "while (true)"; + out << nl << "while(true)"; out << sb; out << nl << "Ice._ObjectDel __delBase = __getDelegate();"; out << nl << '_' << name << "Del __del = (_" << name @@ -1973,17 +1973,17 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "try"; out << sb; out << nl; - if (ret) + if(ret) { out << "return "; } out << "__del." << opName << '(' << args; - if (!args.empty()) + if(!args.empty()) { out << ", "; } out << "__context);"; - if (!ret) + if(!ret) { out << nl << "return;"; } @@ -1996,7 +1996,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << sb; list<string> metaData = op->getMetaData(); bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end(); - if (nonmutating) + if(nonmutating) { out << nl << "__cnt = __handleException(__ex.get(), __cnt);"; } @@ -2026,9 +2026,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) << nl << "checkedCast(Ice.ObjectPrx p, String facet)"; out << sb; out << nl << name << "Prx result = null;"; - out << nl << "if (p != null)"; + out << nl << "if(p != null)"; out << sb; - out << nl << "if (facet.equals(p.ice_getFacet()))"; + out << nl << "if(facet.equals(p.ice_getFacet()))"; out << sb; out << nl << "try"; out << sb; @@ -2036,7 +2036,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; out << nl << "catch (ClassCastException ex)"; out << sb; - out << nl << "if (p.ice_isA(\"" << scoped << "\"))"; + out << nl << "if(p.ice_isA(\"" << scoped << "\"))"; out << sb; out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; out << nl << "h.__copyFrom(p);"; @@ -2049,7 +2049,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "Ice.ObjectPrx pp = p.ice_newFacet(facet);"; out << nl << "try"; out << sb; - out << nl << "if (pp.ice_isA(\"" << scoped << "\"))"; + out << nl << "if(pp.ice_isA(\"" << scoped << "\"))"; out << sb; out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; out << nl << "h.__copyFrom(pp);"; @@ -2078,9 +2078,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) << nl << "uncheckedCast(Ice.ObjectPrx p, String facet)"; out << sb; out << nl << name << "Prx result = null;"; - out << nl << "if (p != null)"; + out << nl << "if(p != null)"; out << sb; - out << nl << "if (facet.equals(p.ice_getFacet()))"; + out << nl << "if(facet.equals(p.ice_getFacet()))"; out << sb; out << nl << "try"; out << sb; @@ -2139,7 +2139,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) << nl << "__read(IceInternal.BasicStream __is)"; out << sb; out << nl << "Ice.ObjectPrx proxy = __is.readProxy();"; - out << nl << "if (proxy != null)"; + out << nl << "if(proxy != null)"; out << sb; out << nl << name << "PrxHelper result = new " << name << "PrxHelper();"; out << nl << "result.__copyFrom(proxy);"; @@ -2164,7 +2164,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) << nl << "ice_unmarshal(String __name, Ice.Stream __is)"; out << sb; out << nl << "Ice.ObjectPrx proxy = __is.readProxy(__name);"; - out << nl << "if (proxy != null)"; + out << nl << "if(proxy != null)"; out << sb; out << nl << name << "PrxHelper result = new " << name << "PrxHelper();"; out << nl << "result.__copyFrom(proxy);"; @@ -2185,7 +2185,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) // // Don't generate helper for a sequence of a local type // - if (p->isLocal()) + if(p->isLocal()) { return; } @@ -2196,7 +2196,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) string scope = p->scope(); string typeS = typeToString(p, TypeModeIn, scope); - if (open(helper)) + if(open(helper)) { Output& out = output(); int iter; @@ -2259,7 +2259,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) // // Don't generate helper for a dictionary containing a local type // - if (p->isLocal()) + if(p->isLocal()) { return; } @@ -2270,7 +2270,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) string absolute = getAbsolute(p->scoped()); string helper = absolute + "Helper"; - if (open(helper)) + if(open(helper)) { Output& out = output(); string name = fixKwd(p->name()); @@ -2290,16 +2290,16 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << sb; out << nl << "__os.writeSize(__v.size());"; out << nl << "java.util.Iterator __i = __v.entrySet().iterator();"; - out << nl << "while (__i.hasNext())"; + out << nl << "while(__i.hasNext())"; out << sb; out << nl << "java.util.Map.Entry __e = (java.util.Map.Entry)" << "__i.next();"; iter = 0; - for (i = 0; i < 2; i++) + for(i = 0; i < 2; i++) { string val; string arg; TypePtr type; - if (i == 0) + if(i == 0) { arg = "__e.getKey()"; type = key; @@ -2311,9 +2311,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) } BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if (b) + if(b) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -2364,7 +2364,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) } } - if (val.empty()) + if(val.empty()) { val = "((" + typeToString(type, TypeModeIn, scope) + ")" + arg + ")"; } @@ -2381,14 +2381,14 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << sb; out << nl << "int __sz = __is.readSize();"; out << nl << "java.util.Map __r = new java.util.HashMap(__sz);"; - out << nl << "for (int __i = 0; __i < __sz; __i++)"; + out << nl << "for(int __i = 0; __i < __sz; __i++)"; out << sb; iter = 0; - for (i = 0; i < 2; i++) + for(i = 0; i < 2; i++) { string arg; TypePtr type; - if (i == 0) + if(i == 0) { arg = "__key"; type = key; @@ -2400,9 +2400,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) } BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if (b) + if(b) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -2480,18 +2480,18 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << sb; out << nl << "__os.startWriteDictionary(__name, __v.size());"; out << nl << "java.util.Iterator __i = __v.entrySet().iterator();"; - out << nl << "while (__i.hasNext())"; + out << nl << "while(__i.hasNext())"; out << sb; out << nl << "java.util.Map.Entry __e = (java.util.Map.Entry)" << "__i.next();"; out << nl << "__os.startWriteDictionaryElement();"; iter = 0; - for (i = 0; i < 2; i++) + for(i = 0; i < 2; i++) { string val; string arg; TypePtr type; string tag; - if (i == 0) + if(i == 0) { arg = "__e.getKey()"; type = key; @@ -2505,9 +2505,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) } BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if (b) + if(b) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -2558,7 +2558,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) } } - if (val.empty()) + if(val.empty()) { val = "((" + typeToString(type, TypeModeIn, scope) + ")" + arg + ")"; } @@ -2576,16 +2576,16 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << sb; out << nl << "int __sz = __is.startReadDictionary(__name);"; out << nl << "java.util.Map __r = new java.util.HashMap(__sz);"; - out << nl << "for (int __i = 0; __i < __sz; __i++)"; + out << nl << "for(int __i = 0; __i < __sz; __i++)"; out << sb; out << nl << "__is.startReadDictionaryElement();"; iter = 0; - for (i = 0; i < 2; i++) + for(i = 0; i < 2; i++) { string arg; TypePtr type; string tag; - if (i == 0) + if(i == 0) { arg = "__key"; type = key; @@ -2599,9 +2599,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) } BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if (b) + if(b) { - switch (b->kind()) + switch(b->kind()) { case Builtin::KindByte: { @@ -2695,7 +2695,7 @@ Slice::Gen::ProxyVisitor::ProxyVisitor(const string& dir, bool Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -2706,7 +2706,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped); - if (!open(absolute + "Prx")) + if(!open(absolute + "Prx")) { return false; } @@ -2717,7 +2717,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) // Generate a Java interface as the user-visible type // out << sp << nl << "public interface " << name << "Prx extends "; - if (bases.empty()) + if(bases.empty()) { out << "Ice.ObjectPrx"; } @@ -2725,10 +2725,10 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) { out.useCurrentPosAsIndent(); ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { out << getAbsolute((*q)->scoped(), scope) << "Prx"; - if (++q != bases.end()) + if(++q != bases.end()) { out << ',' << nl; } @@ -2779,7 +2779,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) out << ';'; out << nl; out << "public " << retS << ' ' << name << '(' << params; - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -2797,7 +2797,7 @@ Slice::Gen::DelegateVisitor::DelegateVisitor(const string& dir, bool Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -2808,7 +2808,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped, "", "_", "Del"); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -2817,7 +2817,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp << nl << "public interface _" << name << "Del extends "; - if (bases.empty()) + if(bases.empty()) { out << "Ice._ObjectDel"; } @@ -2825,10 +2825,10 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) { out.useCurrentPosAsIndent(); ClassList::const_iterator q = bases.begin(); - while (q != bases.end()) + while(q != bases.end()) { out << getAbsolute((*q)->scoped(), scope, "_", "Del"); - if (++q != bases.end()) + if(++q != bases.end()) { out << ',' << nl; } @@ -2841,7 +2841,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->operations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); string opName = fixKwd(op->name()); @@ -2857,7 +2857,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp; out << nl; out << retS << ' ' << opName << '(' << params; - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -2881,7 +2881,7 @@ Slice::Gen::DelegateMVisitor::DelegateMVisitor(const string& dir, bool Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -2892,7 +2892,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped, "", "_", "DelM"); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -2906,7 +2906,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->allOperations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); string opName = fixKwd(op->name()); @@ -2934,7 +2934,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp; out << nl; out << "public " << retS << nl << opName << '(' << params; - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -2947,23 +2947,23 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) << (nonmutating ? "true" : "false") << ", __context);"; out << nl << "try"; out << sb; - if (!inParams.empty()) + if(!inParams.empty()) { out << nl << "IceInternal.BasicStream __os = __out.os();"; } - if (!outParams.empty() || ret || throws.size() > 0) + if(!outParams.empty() || ret || throws.size() > 0) { out << nl << "IceInternal.BasicStream __is = __out.is();"; } iter = 0; - for (q = inParams.begin(); q != inParams.end(); ++q) + for(q = inParams.begin(); q != inParams.end(); ++q) { writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), true, iter); } - out << nl << "if (!__out.invoke())"; + out << nl << "if(!__out.invoke())"; out << sb; - if (throws.size() > 0) + if(throws.size() > 0) { // // The try/catch block is necessary because throwException() @@ -2974,9 +2974,9 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "final String[] __throws ="; out << sb; ExceptionList::const_iterator r; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { - if (r != throws.begin()) + if(r != throws.begin()) { out << ","; } @@ -2984,10 +2984,10 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) } out << eb; out << ';'; - out << nl << "switch (__is.throwException(__throws))"; + out << nl << "switch(__is.throwException(__throws))"; out << sb; int count = 0; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { out << nl << "case " << count << ':'; out << sb; @@ -3000,7 +3000,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) } out << eb; out << eb; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { out << nl << "catch (" << getAbsolute((*r)->scoped(), scope) << " __ex)"; @@ -3015,13 +3015,13 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "throw new Ice.UnknownUserException();"; out << eb; - for (q = outParams.begin(); q != outParams.end(); ++q) + for(q = outParams.begin(); q != outParams.end(); ++q) { writeMarshalUnmarshalCode(out, scope, q->first, fixKwd(q->second), false, iter, true); } - if (ret) + if(ret) { out << nl << retS << " __ret;"; writeMarshalUnmarshalCode(out, scope, ret, "__ret", false, iter); @@ -3052,7 +3052,7 @@ Slice::Gen::DelegateDVisitor::DelegateDVisitor(const string& dir, bool Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal()) + if(p->isLocal()) { return false; } @@ -3063,7 +3063,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped, "", "_", "DelD"); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -3077,7 +3077,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->allOperations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = (*r); string opName = fixKwd(op->name()); @@ -3104,7 +3104,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp; out << nl; out << "public " << retS << nl << opName << '(' << params; - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -3116,7 +3116,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "Ice.Current __current = new Ice.Current();"; out << nl << "__initCurrent(__current, \"" << op->name() << "\", " << (nonmutating ? "true" : "false") << ", __context);"; - out << nl << "while (true)"; + out << nl << "while(true)"; out << sb; out << nl << "IceInternal.Direct __direct = new IceInternal.Direct(__adapter, __current);"; out << nl << "try"; @@ -3135,23 +3135,23 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "try"; out << sb; out << nl; - if (ret) + if(ret) { out << "return "; } out << "__servant." << opName << '(' << args; - if (!args.empty()) + if(!args.empty()) { out << ", "; } out << "__current);"; - if (!ret) + if(!ret) { out << nl << "return;"; } out << eb; ExceptionList::const_iterator r; - for (r = throws.begin(); r != throws.end(); ++r) + for(r = throws.begin(); r != throws.end(); ++r) { out << nl << "catch (" << getAbsolute((*r)->scoped(), scope) << " __ex)"; out << sb; @@ -3198,7 +3198,7 @@ Slice::Gen::DispatcherVisitor::DispatcherVisitor(const string& dir, bool Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (p->isLocal() || !p->isInterface()) + if(p->isLocal() || !p->isInterface()) { return false; } @@ -3209,7 +3209,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped, "", "_", "Disp"); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -3238,9 +3238,9 @@ void Slice::Gen::BaseImplVisitor::writeReturn(Output& out, const TypePtr& type) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if (builtin) + if(builtin) { - switch (builtin->kind()) + switch(builtin->kind()) { case Builtin::KindBool: { @@ -3298,9 +3298,9 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co string params = getParams(op, scope); out << sp << nl << "public " << retS << nl << opName << "(" << params; - if (!local) + if(!local) { - if (!params.empty()) + if(!params.empty()) { out << ", "; } @@ -3318,7 +3318,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& scope, co // // Return value // - if (ret) + if(ret) { writeReturn(out, ret); } @@ -3335,7 +3335,7 @@ Slice::Gen::ImplVisitor::ImplVisitor(const string& dir, bool Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (!p->isAbstract()) + if(!p->isAbstract()) { return false; } @@ -3346,7 +3346,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped, "", "", "I"); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -3354,9 +3354,9 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) Output& out = output(); out << sp << nl << "public final class " << name << 'I'; - if (p->isInterface()) + if(p->isInterface()) { - if (p->isLocal()) + if(p->isLocal()) { out << " implements " << name; } @@ -3378,7 +3378,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->allOperations(); OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { writeOperation(out, scope, *r, p->isLocal()); } @@ -3398,7 +3398,7 @@ Slice::Gen::ImplTieVisitor::ImplTieVisitor(const string& dir, bool Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) { - if (!p->isAbstract()) + if(!p->isAbstract()) { return false; } @@ -3409,7 +3409,7 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) string scope = p->scope(); string absolute = getAbsolute(scoped, "", "", "I"); - if (!open(absolute)) + if(!open(absolute)) { return false; } @@ -3426,7 +3426,7 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) bool inheritImpl = (!p->isInterface() && !bases.empty() && !bases.front()->isInterface()) || (bases.size() == 1); out << sp << nl << "public class " << name << 'I'; - if (inheritImpl) + if(inheritImpl) { out << " extends " << fixKwd(bases.front()->name()) << 'I'; } @@ -3441,16 +3441,16 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) ops.sort(); OperationList baseOps; - if (inheritImpl) + if(inheritImpl) { baseOps = bases.front()->allOperations(); baseOps.sort(); } OperationList::const_iterator r; - for (r = ops.begin(); r != ops.end(); ++r) + for(r = ops.begin(); r != ops.end(); ++r) { - if (inheritImpl && binary_search(baseOps.begin(), baseOps.end(), *r)) + if(inheritImpl && binary_search(baseOps.begin(), baseOps.end(), *r)) { out << sp; out << nl << "/*"; diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 02e6128317e..e08e1a08ccc 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -1,244 +1,244 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GEN_H -#define GEN_H - -#include <Slice/JavaUtil.h> - -namespace Slice -{ - -class JavaVisitor : public JavaGenerator, public ParserVisitor -{ -public: - - virtual ~JavaVisitor(); - -protected: - - JavaVisitor(const std::string&, const std::string&); - - // - // Compose the parameter list for an operation - // - std::string getParams(const OperationPtr&, const std::string&); - - // - // Compose the argument list for an operation - // - std::string getArgs(const OperationPtr&, const std::string&); - - // - // Generate a throws clause containing only non-local exceptions - // - void writeThrowsClause(const std::string&, const ExceptionList&); - - // - // Generate a throws clause for delegate operations containing only - // non-local exceptions - // - void writeDelegateThrowsClause(const std::string&, const ExceptionList&); - - // - // Generate code to compute a hash code for a type - // - void writeHashCode(::IceUtil::Output&, const TypePtr&, const std::string&, int&, - const std::list<std::string>& = std::list<std::string>()); - - // - // Generate dispatch methods for a class or interface - // - void writeDispatch(::IceUtil::Output&, const ClassDefPtr&); -}; - -class Gen : public ::IceUtil::noncopyable -{ -public: - - Gen(const std::string&, - const std::string&, - const std::vector<std::string>&, - const std::string&, - const std::string&, - bool); - ~Gen(); - - bool operator!() const; // Returns true if there was a constructor error - - void generate(const UnitPtr&); - void generateTie(const UnitPtr&); - void generateImpl(const UnitPtr&); - void generateImplTie(const UnitPtr&); - -private: - - std::string _base; - std::vector<std::string> _includePaths; - std::string _package; - std::string _dir; - bool _clone; - - class OpsVisitor : public JavaVisitor - { - public: - - OpsVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - }; - - class TieVisitor : public JavaVisitor - { - public: - - TieVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class TypesVisitor : public JavaVisitor - { - public: - - TypesVisitor(const std::string&, const std::string&, bool); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual bool visitExceptionStart(const ExceptionPtr&); - virtual void visitExceptionEnd(const ExceptionPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitStructEnd(const StructPtr&); - virtual void visitEnum(const EnumPtr&); - virtual void visitDataMember(const DataMemberPtr&); - - private: - - bool _clone; - }; - - class HolderVisitor : public JavaVisitor - { - public: - - HolderVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitSequence(const SequencePtr&); - virtual void visitDictionary(const DictionaryPtr&); - virtual void visitEnum(const EnumPtr&); - - private: - - void writeHolder(const TypePtr&); - }; - - class HelperVisitor : public JavaVisitor - { - public: - - HelperVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitSequence(const SequencePtr&); - virtual void visitDictionary(const DictionaryPtr&); - }; - - class ProxyVisitor : public JavaVisitor - { - public: - - ProxyVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - }; - - class DelegateVisitor : public JavaVisitor - { - public: - - DelegateVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class DelegateMVisitor : public JavaVisitor - { - public: - - DelegateMVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class DelegateDVisitor : public JavaVisitor - { - public: - - DelegateDVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class DispatcherVisitor : public JavaVisitor - { - public: - - DispatcherVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class BaseImplVisitor : public JavaVisitor - { - protected: - - // - // Generate code to return a value - // - void writeReturn(::IceUtil::Output&, const TypePtr&); - - // - // Generate an operation - // - void writeOperation(::IceUtil::Output&, const std::string&, const OperationPtr&, bool); - - public: - - BaseImplVisitor(const std::string&, const std::string&); - }; - - class ImplVisitor : public BaseImplVisitor - { - public: - - ImplVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class ImplTieVisitor : public BaseImplVisitor - { - public: - - ImplTieVisitor(const std::string&, const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GEN_H
+#define GEN_H
+
+#include <Slice/JavaUtil.h>
+
+namespace Slice
+{
+
+class JavaVisitor : public JavaGenerator, public ParserVisitor
+{
+public:
+
+ virtual ~JavaVisitor();
+
+protected:
+
+ JavaVisitor(const std::string&, const std::string&);
+
+ //
+ // Compose the parameter list for an operation
+ //
+ std::string getParams(const OperationPtr&, const std::string&);
+
+ //
+ // Compose the argument list for an operation
+ //
+ std::string getArgs(const OperationPtr&, const std::string&);
+
+ //
+ // Generate a throws clause containing only non-local exceptions
+ //
+ void writeThrowsClause(const std::string&, const ExceptionList&);
+
+ //
+ // Generate a throws clause for delegate operations containing only
+ // non-local exceptions
+ //
+ void writeDelegateThrowsClause(const std::string&, const ExceptionList&);
+
+ //
+ // Generate code to compute a hash code for a type
+ //
+ void writeHashCode(::IceUtil::Output&, const TypePtr&, const std::string&, int&,
+ const std::list<std::string>& = std::list<std::string>());
+
+ //
+ // Generate dispatch methods for a class or interface
+ //
+ void writeDispatch(::IceUtil::Output&, const ClassDefPtr&);
+};
+
+class Gen : public ::IceUtil::noncopyable
+{
+public:
+
+ Gen(const std::string&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&,
+ const std::string&,
+ bool);
+ ~Gen();
+
+ bool operator!() const; // Returns true if there was a constructor error
+
+ void generate(const UnitPtr&);
+ void generateTie(const UnitPtr&);
+ void generateImpl(const UnitPtr&);
+ void generateImplTie(const UnitPtr&);
+
+private:
+
+ std::string _base;
+ std::vector<std::string> _includePaths;
+ std::string _package;
+ std::string _dir;
+ bool _clone;
+
+ class OpsVisitor : public JavaVisitor
+ {
+ public:
+
+ OpsVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ };
+
+ class TieVisitor : public JavaVisitor
+ {
+ public:
+
+ TieVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+
+ class TypesVisitor : public JavaVisitor
+ {
+ public:
+
+ TypesVisitor(const std::string&, const std::string&, bool);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual void visitExceptionEnd(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitStructEnd(const StructPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
+
+ private:
+
+ bool _clone;
+ };
+
+ class HolderVisitor : public JavaVisitor
+ {
+ public:
+
+ HolderVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ virtual void visitEnum(const EnumPtr&);
+
+ private:
+
+ void writeHolder(const TypePtr&);
+ };
+
+ class HelperVisitor : public JavaVisitor
+ {
+ public:
+
+ HelperVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ };
+
+ class ProxyVisitor : public JavaVisitor
+ {
+ public:
+
+ ProxyVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ };
+
+ class DelegateVisitor : public JavaVisitor
+ {
+ public:
+
+ DelegateVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+
+ class DelegateMVisitor : public JavaVisitor
+ {
+ public:
+
+ DelegateMVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+
+ class DelegateDVisitor : public JavaVisitor
+ {
+ public:
+
+ DelegateDVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+
+ class DispatcherVisitor : public JavaVisitor
+ {
+ public:
+
+ DispatcherVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+
+ class BaseImplVisitor : public JavaVisitor
+ {
+ protected:
+
+ //
+ // Generate code to return a value
+ //
+ void writeReturn(::IceUtil::Output&, const TypePtr&);
+
+ //
+ // Generate an operation
+ //
+ void writeOperation(::IceUtil::Output&, const std::string&, const OperationPtr&, bool);
+
+ public:
+
+ BaseImplVisitor(const std::string&, const std::string&);
+ };
+
+ class ImplVisitor : public BaseImplVisitor
+ {
+ public:
+
+ ImplVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+
+ class ImplTieVisitor : public BaseImplVisitor
+ {
+ public:
+
+ ImplTieVisitor(const std::string&, const std::string&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ };
+};
+
+}
+
+#endif
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index 94103c2f0f0..9b180d6caba 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -50,62 +50,62 @@ main(int argc, char* argv[]) bool debug = false; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; string path = argv[idx] + 2; - if (path.length()) + if(path.length()) { includePaths.push_back(path); } - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--output-dir") == 0) + else if(strcmp(argv[idx], "--output-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; @@ -114,15 +114,15 @@ main(int argc, char* argv[]) } output = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--package") == 0) + else if(strcmp(argv[idx], "--package") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; @@ -131,49 +131,49 @@ main(int argc, char* argv[]) } package = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--tie") == 0) + else if(strcmp(argv[idx], "--tie") == 0) { tie = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--impl") == 0) + else if(strcmp(argv[idx], "--impl") == 0) { impl = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--impl-tie") == 0) + else if(strcmp(argv[idx], "--impl-tie") == 0) { implTie = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--clone") == 0) + else if(strcmp(argv[idx], "--clone") == 0) { clone = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; @@ -186,14 +186,14 @@ main(int argc, char* argv[]) } } - if (argc < 2) + if(argc < 2) { cerr << argv[0] << ": no input file" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (impl && implTie) + if(impl && implTie) { cerr << argv[0] << ": cannot specify both --impl and --impl-tie" << endl; usage(argv[0]); @@ -202,17 +202,17 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { string base(argv[idx]); string suffix; string::size_type pos = base.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = base.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; return EXIT_FAILURE; @@ -220,7 +220,7 @@ main(int argc, char* argv[]) base.erase(pos); ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; @@ -234,7 +234,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; @@ -250,28 +250,28 @@ main(int argc, char* argv[]) pclose(cppHandle); #endif - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } else { Gen gen(argv[0], base, includePaths, package, output, clone); - if (!gen) + if(!gen) { unit->destroy(); return EXIT_FAILURE; } gen.generate(unit); - if (tie) + if(tie) { gen.generateTie(unit); } - if (impl) + if(impl) { gen.generateImpl(unit); } - if (implTie) + if(implTie) { gen.generateImplTie(unit); } diff --git a/cpp/src/slice2wsdl/Gen.cpp b/cpp/src/slice2wsdl/Gen.cpp index cbaa6984fd8..503975aaf5a 100644 --- a/cpp/src/slice2wsdl/Gen.cpp +++ b/cpp/src/slice2wsdl/Gen.cpp @@ -30,16 +30,16 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, _dir(dir) { _orgName = "http://www.noorg.org"; // TODO: argument! - for (vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) + for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) { - if (p->length() && (*p)[p->length() - 1] != '/') + if(p->length() && (*p)[p->length() - 1] != '/') { *p += '/'; } } string::size_type pos = _base.rfind('/'); - if (pos != string::npos) + if(pos != string::npos) { _base.erase(0, pos + 1); } @@ -56,13 +56,13 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) //string fileO = _base + ".wsdl"; string fileO = containedToId(p) + p->name() + ".wsdl"; - if (!_dir.empty()) + if(!_dir.empty()) { fileO = _dir + '/' + fileO; } O.open(fileO.c_str()); - if (!O) + if(!O) { cerr << _name << ": can't open `" << fileO << "' for writing: " << strerror(errno) << endl; return false; @@ -91,7 +91,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) OperationList ops = p->allOperations(); - for (OperationList::const_iterator q = ops.begin(); q != ops.end(); ++q) + for(OperationList::const_iterator q = ops.begin(); q != ops.end(); ++q) { emitMessage(O, *q); } @@ -102,7 +102,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) os << "wsdl:portType name=\"" << scopeId << "PortType\""; O << se(os.str()); - for (OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r) + for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r) { emitOperation(O, *r); } @@ -142,7 +142,7 @@ Slice::Gen::emitMessage(XMLOutput& O, const OperationPtr& p) O << se(os.str()); list<string> metaData = p->getMetaData(); - for (list<string>::iterator iter = metaData.begin(); iter != metaData.end(); ++iter) + for(list<string>::iterator iter = metaData.begin(); iter != metaData.end(); ++iter) { O << nl << "<wsdl:part name=\"" << *iter << "\"/>"; } @@ -195,7 +195,7 @@ Slice::Gen::containedToId(const ContainedPtr& contained) assert(contained); string scoped = contained->scope(); - if (scoped[0] == ':') + if(scoped[0] == ':') { scoped.erase(0, 2); } @@ -204,9 +204,9 @@ Slice::Gen::containedToId(const ContainedPtr& contained) id.reserve(scoped.size()); - for (unsigned int i = 0; i < scoped.size(); ++i) + for(unsigned int i = 0; i < scoped.size(); ++i) { - if (scoped[i] == ':') + if(scoped[i] == ':') { id += '.'; ++i; diff --git a/cpp/src/slice2wsdl/Gen.h b/cpp/src/slice2wsdl/Gen.h index e35402764ad..8192dee73a2 100644 --- a/cpp/src/slice2wsdl/Gen.h +++ b/cpp/src/slice2wsdl/Gen.h @@ -1,59 +1,59 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GEN_H -#define GEN_H - -#include <Slice/Parser.h> -#include <stack> - -namespace IceUtil -{ - -class XMLOutput; - -} - -namespace Slice -{ - -class Gen : public ::IceUtil::noncopyable, public ParserVisitor -{ -public: - - Gen(const std::string&, - const std::string&, - const std::string&, - const std::vector<std::string>&, - const std::string&); - virtual ~Gen(); - - virtual bool visitClassDefStart(const ClassDefPtr&); - -private: - - void emitMessage(::IceUtil::XMLOutput&, const OperationPtr&); - void emitOperation(::IceUtil::XMLOutput&, const OperationPtr&); - - void printHeader(::IceUtil::XMLOutput&); - - std::string containedToId(const ContainedPtr&); - - std::string _name; - std::string _base; - std::string _include; - std::string _orgName; - std::vector<std::string> _includePaths; - std::string _dir; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GEN_H
+#define GEN_H
+
+#include <Slice/Parser.h>
+#include <stack>
+
+namespace IceUtil
+{
+
+class XMLOutput;
+
+}
+
+namespace Slice
+{
+
+class Gen : public ::IceUtil::noncopyable, public ParserVisitor
+{
+public:
+
+ Gen(const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&);
+ virtual ~Gen();
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+
+private:
+
+ void emitMessage(::IceUtil::XMLOutput&, const OperationPtr&);
+ void emitOperation(::IceUtil::XMLOutput&, const OperationPtr&);
+
+ void printHeader(::IceUtil::XMLOutput&);
+
+ std::string containedToId(const ContainedPtr&);
+
+ std::string _name;
+ std::string _base;
+ std::string _include;
+ std::string _orgName;
+ std::vector<std::string> _includePaths;
+ std::string _dir;
+};
+
+}
+
+#endif
diff --git a/cpp/src/slice2wsdl/Main.cpp b/cpp/src/slice2wsdl/Main.cpp index a814b6e514d..507329be3d6 100644 --- a/cpp/src/slice2wsdl/Main.cpp +++ b/cpp/src/slice2wsdl/Main.cpp @@ -40,58 +40,58 @@ main(int argc, char* argv[]) vector<string> includePaths; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; string path = argv[idx] + 2; - if (path.length()) + if(path.length()) { includePaths.push_back(path); } - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--include-dir") == 0) + else if(strcmp(argv[idx], "--include-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -99,15 +99,15 @@ main(int argc, char* argv[]) } include = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--output-dir") == 0) + else if(strcmp(argv[idx], "--output-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -115,13 +115,13 @@ main(int argc, char* argv[]) } output = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -133,7 +133,7 @@ main(int argc, char* argv[]) } } - if (argc < 2) + if(argc < 2) { usage(argv[0]); return EXIT_FAILURE; @@ -146,12 +146,12 @@ main(int argc, char* argv[]) string base(sourceFile); string suffix; string::size_type pos = base.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = base.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; unit->destroy(); @@ -160,7 +160,7 @@ main(int argc, char* argv[]) base.erase(pos); ifstream test(sourceFile.c_str()); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << sourceFile << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -173,7 +173,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; unit->destroy(); @@ -189,7 +189,7 @@ main(int argc, char* argv[]) pclose(cppHandle); #endif - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } @@ -197,17 +197,17 @@ main(int argc, char* argv[]) { Gen gen(argv[0], base, include, includePaths, output); - if (argc > 2) + if(argc > 2) { - for (idx = 2 ; idx < argc; ++idx) + for(idx = 2 ; idx < argc; ++idx) { ClassDeclPtr classDecl; TypeList classTypes = unit->lookupType(argv[idx], false); - if (!classTypes.empty()) + if(!classTypes.empty()) { classDecl = ClassDeclPtr::dynamicCast(classTypes.front()); } - if (!classDecl) + if(!classDecl) { cerr << argv[0] << ": invalid type: " << argv[idx] << endl; status = EXIT_FAILURE; diff --git a/cpp/src/slice2xsd/Gen.cpp b/cpp/src/slice2xsd/Gen.cpp index 17c0b284383..d529205b505 100644 --- a/cpp/src/slice2xsd/Gen.cpp +++ b/cpp/src/slice2xsd/Gen.cpp @@ -25,28 +25,28 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, _includePaths(includePaths) { _orgName = "http://www.noorg.org"; // TODO: argument! - for (vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) + for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p) { - if (p->length() && (*p)[p->length() - 1] != '/') + if(p->length() && (*p)[p->length() - 1] != '/') { *p += '/'; } } string::size_type pos = _base.rfind('/'); - if (pos != string::npos) + if(pos != string::npos) { _base.erase(0, pos + 1); } string fileO = _base + ".xsd"; - if (!dir.empty()) + if(!dir.empty()) { fileO = dir + '/' + fileO; } O.open(fileO.c_str()); - if (!O) + if(!O) { cerr << name << ": can't open `" << fileO << "' for writing: " << strerror(errno) << endl; return; @@ -88,7 +88,7 @@ Slice::Gen::generate(const UnitPtr& unit) O << nl << "<xs:import namespace=\"http://www.mutablerealms.com/schemas\" schemaLocation=\"ice.xsd\"/>"; StringList includes = unit->includeFiles(); - for (StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) + for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) { O << sp; O << nl << "<xs:include schemaLocation=\"" << changeInclude(*q, _includePaths) << ".xsd\"/>"; @@ -120,7 +120,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) string extension = "xs:extension base=\""; ClassList bases = p->bases(); - if (bases.empty() || bases.front()->isInterface()) + if(bases.empty() || bases.front()->isInterface()) { extension += "ice:_internal.object"; } @@ -136,7 +136,7 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p) DataMemberList dataMembers = p->dataMembers(); O << se("xs:sequence"); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { emitElement((*q)->name(), (*q)->type()); } @@ -172,7 +172,7 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p) // Emit base Data // ExceptionPtr base = p->base(); - if (base) + if(base) { string baseScopeId = containedToId(base); @@ -189,14 +189,14 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p) O << se("xs:sequence"); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { emitElement((*q)->name(), (*q)->type()); } O << ee; // xs:sequence - if (base) + if(base) { O << ee; // xs:extension O << ee; // xs:complexContent @@ -226,7 +226,7 @@ Slice::Gen::visitStructStart(const StructPtr& p) DataMemberList dataMembers = p->dataMembers(); O << se("xs:sequence"); - for (DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) + for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { emitElement((*q)->name(), (*q)->type()); } @@ -260,7 +260,7 @@ Slice::Gen::visitOperation(const OperationPtr& p) O << se("xs:sequence"); TypeStringList::const_iterator q; - for (q = in.begin(); q != in.end(); ++q) + for(q = in.begin(); q != in.end(); ++q) { emitElement(q->second, q->first); } @@ -280,12 +280,12 @@ Slice::Gen::visitOperation(const OperationPtr& p) annotate("operation"); O << se("xs:sequence"); - if (ret) + if(ret) { emitElement("__return", ret); //O << nl << "<xs:element name=\"__return\" type=\"" << toString(ret) << "\"/>"; } - for (q = out.begin(); q != out.end(); ++q) + for(q = out.begin(); q != out.end(); ++q) { emitElement(q->second, q->first); } @@ -313,7 +313,7 @@ Slice::Gen::visitEnum(const EnumPtr& p) O << se("xs:restriction base=\"xs:string\""); - for (EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q) + for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q) { O << nl << "<xs:enumeration value=\"" << (*q)->name() << "\"/>"; } @@ -348,7 +348,7 @@ Slice::Gen::visitSequence(const SequencePtr& p) << "\" minOccurs=\"0\" maxOccurs=\"unbounded\""; O << se(os.str()); ProxyPtr proxy = ProxyPtr::dynamicCast(p->type()); - if (proxy) + if(proxy) { annotate(proxy->_class()->scoped()); } @@ -387,7 +387,7 @@ Slice::Gen::visitDictionary(const DictionaryPtr& p) os << "xs:element name=\"key\" type=\"" << toString(p->keyType()) << "\""; O << se(os.str()); ProxyPtr proxy = ProxyPtr::dynamicCast(p->keyType()); - if (proxy) + if(proxy) { annotate(proxy->_class()->scoped()); } @@ -396,7 +396,7 @@ Slice::Gen::visitDictionary(const DictionaryPtr& p) os << "xs:element name=\"value\" type=\"" << toString(p->valueType()) << "\""; O << se(os.str()); proxy = ProxyPtr::dynamicCast(p->valueType()); - if (proxy) + if(proxy) { annotate(proxy->_class()->scoped()); } @@ -477,7 +477,7 @@ Slice::Gen::emitElement(const string& name, const TypePtr& type) os << "xs:element name=\"" << name << "\" type=\"" << toString(type) << '"'; O << se(os.str()); ProxyPtr proxy = ProxyPtr::dynamicCast(type); - if (proxy) + if(proxy) { annotate(proxy->_class()->scoped()); } @@ -490,7 +490,7 @@ Slice::Gen::containedToId(const ContainedPtr& contained) assert(contained); string scoped = contained->scope(); - if (scoped[0] == ':') + if(scoped[0] == ':') { scoped.erase(0, 2); } @@ -499,9 +499,9 @@ Slice::Gen::containedToId(const ContainedPtr& contained) id.reserve(scoped.size()); - for (unsigned int i = 0; i < scoped.size(); ++i) + for(unsigned int i = 0; i < scoped.size(); ++i) { - if (scoped[i] == ':') + if(scoped[i] == ':') { id += '.'; ++i; @@ -538,20 +538,20 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p) }; BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); - if (builtin) + if(builtin) { s = builtinTable[builtin->kind()]; //tag = "type"; } ProxyPtr proxy = ProxyPtr::dynamicCast(p); - if (proxy) + if(proxy) { s = "ice:_internal.proxyType"; } ClassDeclPtr cl = ClassDeclPtr::dynamicCast(p); - if (cl) + if(cl) { string scopeId = containedToId(cl); //s = "tns:" + internalId + scopeId + cl->name() + "Type"; @@ -559,42 +559,42 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p) } ExceptionPtr ex = ExceptionPtr::dynamicCast(p); - if (ex) + if(ex) { string scopeId = containedToId(ex); s = "tns:" + internalId + scopeId + ex->name() + "Type"; } StructPtr st = StructPtr::dynamicCast(p); - if (st) + if(st) { string scopeId = containedToId(st); s = "tns:" + internalId + scopeId + st->name() + "Type"; } EnumeratorPtr en = EnumeratorPtr::dynamicCast(p); - if (en) + if(en) { string scopeId = containedToId(en); s = "tns:" + internalId + scopeId + en->name() + "Type"; } SequencePtr sq = SequencePtr::dynamicCast(p); - if (sq) + if(sq) { string scopeId = containedToId(sq); s = "tns:" + internalId + scopeId + sq->name() + "Type"; } DictionaryPtr di = DictionaryPtr::dynamicCast(p); - if (di) + if(di) { string scopeId = containedToId(di); s = "tns:" + internalId + scopeId + di->name() + "Type"; } EnumPtr em = EnumPtr::dynamicCast(p); - if (em) + if(em) { string scopeId = containedToId(em); s = "tns:" + internalId + scopeId + em->name() + "Type"; diff --git a/cpp/src/slice2xsd/Gen.h b/cpp/src/slice2xsd/Gen.h index aedc4c3af95..2bfb2d5c9f2 100644 --- a/cpp/src/slice2xsd/Gen.h +++ b/cpp/src/slice2xsd/Gen.h @@ -1,63 +1,63 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef GEN_H -#define GEN_H - -#include <Slice/Parser.h> -#include <IceUtil/OutputUtil.h> -#include <stack> - -namespace Slice -{ - -class Gen : public ::IceUtil::noncopyable, public ParserVisitor -{ -public: - - Gen(const std::string&, - const std::string&, - const std::string&, - const std::vector<std::string>&, - const std::string&); - virtual ~Gen(); - - bool operator!() const; // Returns true if there was a constructor error - - void generate(const UnitPtr&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitExceptionStart(const ExceptionPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitOperation(const OperationPtr&); - virtual void visitEnum(const EnumPtr&); - virtual void visitSequence(const SequencePtr&); - virtual void visitDictionary(const DictionaryPtr&); - -private: - - void printHeader(); - void annotate(const ::std::string&); - void emitElement(const ::std::string&, const TypePtr&); - - std::string containedToId(const ContainedPtr&); - std::string toString(const SyntaxTreeBasePtr&); - - ::IceUtil::XMLOutput O; - - std::string _base; - std::string _include; - std::string _orgName; - std::vector<std::string> _includePaths; -}; - -} - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef GEN_H
+#define GEN_H
+
+#include <Slice/Parser.h>
+#include <IceUtil/OutputUtil.h>
+#include <stack>
+
+namespace Slice
+{
+
+class Gen : public ::IceUtil::noncopyable, public ParserVisitor
+{
+public:
+
+ Gen(const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&);
+ virtual ~Gen();
+
+ bool operator!() const; // Returns true if there was a constructor error
+
+ void generate(const UnitPtr&);
+
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+
+private:
+
+ void printHeader();
+ void annotate(const ::std::string&);
+ void emitElement(const ::std::string&, const TypePtr&);
+
+ std::string containedToId(const ContainedPtr&);
+ std::string toString(const SyntaxTreeBasePtr&);
+
+ ::IceUtil::XMLOutput O;
+
+ std::string _base;
+ std::string _include;
+ std::string _orgName;
+ std::vector<std::string> _includePaths;
+};
+
+}
+
+#endif
diff --git a/cpp/src/slice2xsd/Main.cpp b/cpp/src/slice2xsd/Main.cpp index ce97a00c8a7..d385e690182 100644 --- a/cpp/src/slice2xsd/Main.cpp +++ b/cpp/src/slice2xsd/Main.cpp @@ -40,58 +40,58 @@ main(int argc, char* argv[]) vector<string> includePaths; int idx = 1; - while (idx < argc) + while(idx < argc) { - if (strncmp(argv[idx], "-I", 2) == 0) + if(strncmp(argv[idx], "-I", 2) == 0) { cpp += ' '; cpp += argv[idx]; string path = argv[idx] + 2; - if (path.length()) + if(path.length()) { includePaths.push_back(path); } - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) + else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { cpp += ' '; cpp += argv[idx]; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) + else if(strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { usage(argv[0]); return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) + else if(strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0) { cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) + else if(strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0) { debug = true; - for (int i = idx ; i + 1 < argc ; ++i) + for(int i = idx ; i + 1 < argc ; ++i) { argv[i] = argv[i + 1]; } --argc; } - else if (strcmp(argv[idx], "--include-dir") == 0) + else if(strcmp(argv[idx], "--include-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -99,15 +99,15 @@ main(int argc, char* argv[]) } include = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (strcmp(argv[idx], "--output-dir") == 0) + else if(strcmp(argv[idx], "--output-dir") == 0) { - if (idx + 1 >= argc) + if(idx + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl; usage(argv[0]); @@ -115,13 +115,13 @@ main(int argc, char* argv[]) } output = argv[idx + 1]; - for (int i = idx ; i + 2 < argc ; ++i) + for(int i = idx ; i + 2 < argc ; ++i) { argv[i] = argv[i + 2]; } argc -= 2; } - else if (argv[idx][0] == '-') + else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; usage(argv[0]); @@ -133,7 +133,7 @@ main(int argc, char* argv[]) } } - if (argc < 2) + if(argc < 2) { cerr << argv[0] << ": no input file" << endl; usage(argv[0]); @@ -142,17 +142,17 @@ main(int argc, char* argv[]) int status = EXIT_SUCCESS; - for (idx = 1 ; idx < argc ; ++idx) + for(idx = 1 ; idx < argc ; ++idx) { string base(argv[idx]); string suffix; string::size_type pos = base.rfind('.'); - if (pos != string::npos) + if(pos != string::npos) { suffix = base.substr(pos); transform(suffix.begin(), suffix.end(), suffix.begin(), tolower); } - if (suffix != ".ice") + if(suffix != ".ice") { cerr << argv[0] << ": input files must end with `.ice'" << endl; unit->destroy(); @@ -161,7 +161,7 @@ main(int argc, char* argv[]) base.erase(pos); ifstream test(argv[idx]); - if (!test) + if(!test) { cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; return EXIT_FAILURE; @@ -174,7 +174,7 @@ main(int argc, char* argv[]) #else FILE* cppHandle = popen(cmd.c_str(), "r"); #endif - if (cppHandle == 0) + if(cppHandle == 0) { cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; unit->destroy(); @@ -190,14 +190,14 @@ main(int argc, char* argv[]) pclose(cppHandle); #endif - if (parseStatus == EXIT_FAILURE) + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; } else { Gen gen(argv[0], base, include, includePaths, output); - if (!gen) + if(!gen) { unit->destroy(); return EXIT_FAILURE; diff --git a/cpp/src/slice2xsd/Validate.cpp b/cpp/src/slice2xsd/Validate.cpp index e0089682b14..abc1c621a96 100644 --- a/cpp/src/slice2xsd/Validate.cpp +++ b/cpp/src/slice2xsd/Validate.cpp @@ -105,7 +105,7 @@ main(int argc, char** argv) return 1; } - if (argc < 2) + if(argc < 2) { usage(argv[0]); return EXIT_FAILURE; @@ -136,7 +136,7 @@ main(int argc, char** argv) { parser->parse(argv[1]); int errorCount = parser->getErrorCount(); - if (errorCount > 0) + if(errorCount > 0) errorsOccured = true; } diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index faafbca2966..9430222fed0 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -33,7 +33,7 @@ validate(const DBPtr& db) cout << "testing database expressions... "; Complex::ComplexDict::const_iterator p; Parser parser; - for (p = m.begin(); p != m.end(); ++p) + for(p = m.begin(); p != m.end(); ++p) { // // Verify the stored record is correct. @@ -68,7 +68,7 @@ populate(const DBPtr& db) cout << "populating the database... "; Parser parser; - for (int i = 0 ; i < nexpressions; ++i) + for(int i = 0 ; i < nexpressions; ++i) { Complex::NodePtr root = parser.parse(expressions[i]); assert(root); @@ -103,11 +103,11 @@ run(int argc, char* argv[], const DBPtr& db) communicator->addObjectFactory(factory, "::Complex::AddNode"); communicator->addObjectFactory(factory, "::Complex::MultiplyNode"); - if (argc > 1 && strcmp(argv[1], "populate") == 0) + if(argc > 1 && strcmp(argv[1], "populate") == 0) { return populate(db); } - if (argc > 1 && strcmp(argv[1], "validate") == 0) + if(argc > 1 && strcmp(argv[1], "validate") == 0) { return validate(db); } @@ -131,11 +131,11 @@ main(int argc, char* argv[]) // Scan for --dbdir command line argument. // int i = 1; - while (i < argc) + while(i < argc) { - if (strcmp(argv[i], "--dbdir") == 0) + if(strcmp(argv[i], "--dbdir") == 0) { - if (i +1 >= argc) + if(i +1 >= argc) { usage(argv[0]); return EXIT_FAILURE; @@ -148,7 +148,7 @@ main(int argc, char* argv[]) // // Consume arguments // - while (i < argc - 2) + while(i < argc - 2) { argv[i] = argv[i+2]; ++i; @@ -172,7 +172,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (db) + if(db) { try { @@ -196,7 +196,7 @@ main(int argc, char* argv[]) db = 0; } - if (dbEnv) + if(dbEnv) { try { diff --git a/cpp/test/Freeze/complex/NodeI.h b/cpp/test/Freeze/complex/NodeI.h index aeb1405d134..e1c091f24f9 100644 --- a/cpp/test/Freeze/complex/NodeI.h +++ b/cpp/test/Freeze/complex/NodeI.h @@ -1,110 +1,110 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef NODE_I_H -#define NODE_I_H - -#include <Complex.h> -#include <Ice/ObjectFactory.h> - -namespace Complex -{ - -class NumberNodeI : public NumberNode -{ -public: - - NumberNodeI() - { - } - - NumberNodeI(int number) - { - _number = number; - } - - virtual int calc(const Ice::Current&) - { - return _number; - } -}; - -class AddNodeI : public AddNode -{ -public: - - AddNodeI() - { - } - - AddNodeI(const NodePtr& left, const NodePtr& right) - { - _left = left; - _right = right; - } - - virtual int calc(const Ice::Current&) - { - return _left->calc() + _right->calc(); - } -}; - -class MultiplyNodeI : public MultiplyNode -{ -public: - - MultiplyNodeI() - { - } - - MultiplyNodeI(const NodePtr& left, const NodePtr& right) - { - _left = left; - _right = right; - } - - virtual int calc(const Ice::Current&) - { - return _left->calc() * _right->calc(); - } -}; - -class ObjectFactoryI : public Ice::ObjectFactory -{ -public: - - virtual Ice::ObjectPtr create(const std::string& type) - { - if (type == "::Complex::MultiplyNode") - { - return new MultiplyNodeI(); - } - if (type == "::Complex::AddNode") - { - return new AddNodeI(); - } - if (type == "::Complex::NumberNode") - { - return new NumberNodeI(); - } - std::cout << "create: " << type << std::endl; - assert(false); - return 0; - } - - virtual void destroy() - { - // Nothing to do - } -}; - -} // End namespace Complex - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef NODE_I_H
+#define NODE_I_H
+
+#include <Complex.h>
+#include <Ice/ObjectFactory.h>
+
+namespace Complex
+{
+
+class NumberNodeI : public NumberNode
+{
+public:
+
+ NumberNodeI()
+ {
+ }
+
+ NumberNodeI(int number)
+ {
+ _number = number;
+ }
+
+ virtual int calc(const Ice::Current&)
+ {
+ return _number;
+ }
+};
+
+class AddNodeI : public AddNode
+{
+public:
+
+ AddNodeI()
+ {
+ }
+
+ AddNodeI(const NodePtr& left, const NodePtr& right)
+ {
+ _left = left;
+ _right = right;
+ }
+
+ virtual int calc(const Ice::Current&)
+ {
+ return _left->calc() + _right->calc();
+ }
+};
+
+class MultiplyNodeI : public MultiplyNode
+{
+public:
+
+ MultiplyNodeI()
+ {
+ }
+
+ MultiplyNodeI(const NodePtr& left, const NodePtr& right)
+ {
+ _left = left;
+ _right = right;
+ }
+
+ virtual int calc(const Ice::Current&)
+ {
+ return _left->calc() * _right->calc();
+ }
+};
+
+class ObjectFactoryI : public Ice::ObjectFactory
+{
+public:
+
+ virtual Ice::ObjectPtr create(const std::string& type)
+ {
+ if(type == "::Complex::MultiplyNode")
+ {
+ return new MultiplyNodeI();
+ }
+ if(type == "::Complex::AddNode")
+ {
+ return new AddNodeI();
+ }
+ if(type == "::Complex::NumberNode")
+ {
+ return new NumberNodeI();
+ }
+ std::cout << "create: " << type << std::endl;
+ assert(false);
+ return 0;
+ }
+
+ virtual void destroy()
+ {
+ // Nothing to do
+ }
+};
+
+} // End namespace Complex
+
+#endif
diff --git a/cpp/test/Freeze/complex/Parser.cpp b/cpp/test/Freeze/complex/Parser.cpp index 39294914c2a..7231c81fad7 100644 --- a/cpp/test/Freeze/complex/Parser.cpp +++ b/cpp/test/Freeze/complex/Parser.cpp @@ -43,7 +43,7 @@ Parser::parse(const string& commands, bool debug) yyparse(); parser = 0; - if (_errors) + if(_errors) { return 0; } @@ -67,7 +67,7 @@ Parser::error(const std::string& s) void Parser::getInput(char* buf, int& result, int maxSize) { - if (!_buf.empty()) + if(!_buf.empty()) { #if defined(_MSC_VER) && !defined(_STLP_MSVC) // COMPILERBUG: Stupid Visual C++ defines min and max as macros diff --git a/cpp/test/Freeze/complex/Parser.h b/cpp/test/Freeze/complex/Parser.h index 53898734009..ba140f668c6 100644 --- a/cpp/test/Freeze/complex/Parser.h +++ b/cpp/test/Freeze/complex/Parser.h @@ -1,79 +1,79 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef PARSER_H -#define PARSER_H - -#include <Complex.h> - -#ifdef _WIN32 -# include <io.h> -# define isatty _isatty -# define fileno _fileno -// '_isatty' : inconsistent dll linkage. dllexport assumed. -# pragma warning( disable : 4273 ) -#endif - -// -// Stuff for flex and bison -// - -#define YYSTYPE Complex::NodePtr -#define YY_DECL int yylex(YYSTYPE* yylvalp) -YY_DECL; -int yyparse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) yyerror(a) - -// -// unput() isn't needed. This prevents the function being defined, and -// the resulting compiler warning. -// -#define YY_NO_UNPUT - -class Parser -{ -public: - - Parser(); - ~Parser(); - - Complex::NodePtr parse(const std::string&, bool = false); - - void error(const char*); - void error(const std::string&); - - void getInput(char*, int&, int); - void setResult(const Complex::NodePtr&); - -private: - - std::string _buf; - Complex::NodePtr _result; - int _errors; -}; - -extern Parser* parser; // Current parser for bison/flex - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <Complex.h>
+
+#ifdef _WIN32
+# include <io.h>
+# define isatty _isatty
+# define fileno _fileno
+// '_isatty' : inconsistent dll linkage. dllexport assumed.
+# pragma warning( disable : 4273 )
+#endif
+
+//
+// Stuff for flex and bison
+//
+
+#define YYSTYPE Complex::NodePtr
+#define YY_DECL int yylex(YYSTYPE* yylvalp)
+YY_DECL;
+int yyparse();
+
+//
+// I must set the initial stack depth to the maximum stack depth to
+// disable bison stack resizing. The bison stack resizing routines use
+// simple malloc/alloc/memcpy calls, which do not work for the
+// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor,
+// assignment operator, etc.
+//
+#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum.
+#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above.
+
+//
+// Newer bison versions allow to disable stack resizing by defining
+// yyoverflow.
+//
+#define yyoverflow(a, b, c, d, e, f) yyerror(a)
+
+//
+// unput() isn't needed. This prevents the function being defined, and
+// the resulting compiler warning.
+//
+#define YY_NO_UNPUT
+
+class Parser
+{
+public:
+
+ Parser();
+ ~Parser();
+
+ Complex::NodePtr parse(const std::string&, bool = false);
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void getInput(char*, int&, int);
+ void setResult(const Complex::NodePtr&);
+
+private:
+
+ std::string _buf;
+ Complex::NodePtr _result;
+ int _errors;
+};
+
+extern Parser* parser; // Current parser for bison/flex
+
+#endif
diff --git a/cpp/test/Freeze/complex/dummyinclude/unistd.h b/cpp/test/Freeze/complex/dummyinclude/unistd.h index 92d53d10b9b..a5868056a35 100644 --- a/cpp/test/Freeze/complex/dummyinclude/unistd.h +++ b/cpp/test/Freeze/complex/dummyinclude/unistd.h @@ -1,4 +1,4 @@ -// -// Files generated by flex need unistd.h, which is not available on -// Windows. Thus this dummy file. -// +//
+// Files generated by flex need unistd.h, which is not available on
+// Windows. Thus this dummy file.
+//
diff --git a/cpp/test/Freeze/cursor/Client.cpp b/cpp/test/Freeze/cursor/Client.cpp index 1bd50da5e54..eee8a7fb45e 100644 --- a/cpp/test/Freeze/cursor/Client.cpp +++ b/cpp/test/Freeze/cursor/Client.cpp @@ -86,7 +86,7 @@ vector<char> alphabet(alphabetChars, alphabetChars + sizeof(alphabetChars)-1); static void populateDB(const DBPtr& db) { - for (vector<char>::const_iterator j = alphabet.begin() ; j != alphabet.end(); ++j) + for(vector<char>::const_iterator j = alphabet.begin() ; j != alphabet.end(); ++j) { addValue(db, *j, j-alphabet.begin()); } @@ -133,7 +133,7 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) test(key == *j && value == j - alphabet.begin()); ++j; } - while (cursor->next()); + while(cursor->next()); } catch(const DBNotFoundException&) { @@ -145,7 +145,7 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) cout << "testing contains... "; try { - for (j = alphabet.begin(); j != alphabet.end(); ++j) + for(j = alphabet.begin(); j != alphabet.end(); ++j) { k = KeyCodec::write(*j, instance); test(db->contains(k)); @@ -172,7 +172,7 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) test(key == *j && value == j - alphabet.begin()); ++j; } - while (cursor->next()); + while(cursor->next()); } catch(const DBNotFoundException&) { @@ -194,10 +194,10 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) test(key == *j && value == j - alphabet.begin()); cursor->del(); ++j; - if (key == 'c') + if(key == 'c') break; } - while (cursor->next()); + while(cursor->next()); } catch(const DBNotFoundException&) { @@ -216,7 +216,7 @@ run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) test(key == *j && value == j - alphabet.begin()); ++j; } - while (cursor->next()); + while(cursor->next()); } catch(const DBNotFoundException&) { @@ -329,7 +329,7 @@ main(int argc, char* argv[]) try { communicator = Ice::initialize(argc, argv); - if (argc != 1) + if(argc != 1) { dbEnvDir = argv[1]; dbEnvDir += "/"; @@ -344,7 +344,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (dbEnv) + if(dbEnv) { try { diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp index 3d3ce800f27..e369d252550 100644 --- a/cpp/test/Freeze/dbmap/Client.cpp +++ b/cpp/test/Freeze/dbmap/Client.cpp @@ -98,7 +98,7 @@ populateDB(CharIntMap& m) { alphabet.assign(alphabetChars, alphabetChars + sizeof(alphabetChars)-1); - for (vector<char>::const_iterator j = alphabet.begin() ; j != alphabet.end(); ++j) + for(vector<char>::const_iterator j = alphabet.begin() ; j != alphabet.end(); ++j) { m.insert(make_pair(*j, j-alphabet.begin())); } @@ -125,7 +125,7 @@ run(int argc, char* argv[], const DBPtr& db) // // First try non-const iterator // - for (j = alphabet.begin() ; j != alphabet.end() ; ++j) + for(j = alphabet.begin() ; j != alphabet.end() ; ++j) { p = m.find(*j); test(p != m.end()); @@ -134,7 +134,7 @@ run(int argc, char* argv[], const DBPtr& db) // // Next try const iterator // - for (j = alphabet.begin() ; j != alphabet.end() ; ++j) + for(j = alphabet.begin() ; j != alphabet.end() ; ++j) { cp = m.find(*j); test(cp != m.end()); @@ -165,7 +165,7 @@ run(int argc, char* argv[], const DBPtr& db) chars.push_back('a'); chars.push_back('b'); chars.push_back('c'); - for (j = chars.begin(); j != chars.end(); ++j) + for(j = chars.begin(); j != chars.end(); ++j) { p = m.find(*j); test(p != m.end()); @@ -177,7 +177,7 @@ run(int argc, char* argv[], const DBPtr& db) alphabet.erase(r); } - for (j = alphabet.begin() ; j != alphabet.end() ; ++j) + for(j = alphabet.begin() ; j != alphabet.end() ; ++j) { cp = m.find(*j); test(cp != m.end()); @@ -325,7 +325,7 @@ run(int argc, char* argv[], const DBPtr& db) test(pairs.size() == m.size()); vector<pair<char, int> >::const_iterator pit; - for (pit = pairs.begin() ; pit != pairs.end() ; ++pit) + for(pit = pairs.begin() ; pit != pairs.end() ; ++pit) { p = m.find(pit->first); test(p != m.end()); @@ -364,7 +364,7 @@ main(int argc, char* argv[]) try { communicator = Ice::initialize(argc, argv); - if (argc != 1) + if(argc != 1) { dbEnvDir = argv[1]; dbEnvDir += "/"; @@ -380,7 +380,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (db) + if(db) { try { @@ -404,7 +404,7 @@ main(int argc, char* argv[]) db = 0; } - if (dbEnv) + if(dbEnv) { try { diff --git a/cpp/test/Glacier/starter/CallbackI.cpp b/cpp/test/Glacier/starter/CallbackI.cpp index ede6e13beb3..ea18ff20d68 100644 --- a/cpp/test/Glacier/starter/CallbackI.cpp +++ b/cpp/test/Glacier/starter/CallbackI.cpp @@ -43,9 +43,9 @@ CallbackReceiverI::callbackOK() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while (!_callback) + while(!_callback) { - if (!timedWait(IceUtil::Time::milliSeconds(5000))) + if(!timedWait(IceUtil::Time::milliSeconds(5000))) { return false; } diff --git a/cpp/test/Glacier/starter/CallbackI.h b/cpp/test/Glacier/starter/CallbackI.h index f8ad0fd68f8..72b67994798 100644 --- a/cpp/test/Glacier/starter/CallbackI.h +++ b/cpp/test/Glacier/starter/CallbackI.h @@ -1,48 +1,48 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef CALLBACK_I_H -#define CALLBACK_I_H - -#include <IceUtil/Mutex.h> -#include <IceUtil/Monitor.h> -#include <Callback.h> - -class CallbackReceiverI : public CallbackReceiver, IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - CallbackReceiverI(); - - virtual void callback(const Ice::Current&); - virtual void callbackEx(const Ice::Current&); - bool callbackOK(); - -private: - - bool _callback; -}; - -class CallbackI : public Callback -{ -public: - - CallbackI(const Ice::CommunicatorPtr&); - - virtual void initiateCallback(const CallbackReceiverPrx&, const Ice::Current&); - virtual void initiateCallbackEx(const CallbackReceiverPrx&, const Ice::Current&); - virtual void shutdown(const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef CALLBACK_I_H
+#define CALLBACK_I_H
+
+#include <IceUtil/Mutex.h>
+#include <IceUtil/Monitor.h>
+#include <Callback.h>
+
+class CallbackReceiverI : public CallbackReceiver, IceUtil::Monitor<IceUtil::Mutex>
+{
+public:
+
+ CallbackReceiverI();
+
+ virtual void callback(const Ice::Current&);
+ virtual void callbackEx(const Ice::Current&);
+ bool callbackOK();
+
+private:
+
+ bool _callback;
+};
+
+class CallbackI : public Callback
+{
+public:
+
+ CallbackI(const Ice::CommunicatorPtr&);
+
+ virtual void initiateCallback(const CallbackReceiverPrx&, const Ice::Current&);
+ virtual void initiateCallbackEx(const CallbackReceiverPrx&, const Ice::Current&);
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+};
+
+#endif
diff --git a/cpp/test/Glacier/starter/Client.cpp b/cpp/test/Glacier/starter/Client.cpp index d0e65d81599..9a29a4e0098 100644 --- a/cpp/test/Glacier/starter/Client.cpp +++ b/cpp/test/Glacier/starter/Client.cpp @@ -90,7 +90,7 @@ CallbackClient::run(int argc, char* argv[]) string clientConfig = properties->getProperty("IceSSL.Client.Config"); string serverConfig = properties->getProperty("IceSSL.Server.Config"); - if (!clientConfig.empty() && !serverConfig.empty()) + if(!clientConfig.empty() && !serverConfig.empty()) { string privateKeyBase64 = IceUtil::Base64::encode(privateKey); string publicKeyBase64 = IceUtil::Base64::encode(publicKey); diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index fc43e5b5a21..7392b96d25b 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -20,19 +20,19 @@ public: virtual void createAndThrow(const string& type) { - if (type == "::A") + if(type == "::A") { throw A(); } - else if (type == "::B") + else if(type == "::B") { throw B(); } - else if (type == "::C") + else if(type == "::C") { throw C(); } - else if (type == "::D") + else if(type == "::D") { throw D(); } @@ -170,7 +170,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "ok" << endl; - if (!collocated) // If the server is collocated, exception factories are not needed. + if(!collocated) // If the server is collocated, exception factories are not needed. { cout << "catching derived types w/o exception factories... " << flush; @@ -277,7 +277,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "ok" << endl; - if (thrower->supportsUndeclaredExceptions()) + if(thrower->supportsUndeclaredExceptions()) { cout << "catching unknown user exception... " << flush; diff --git a/cpp/test/Ice/exceptions/Client.cpp b/cpp/test/Ice/exceptions/Client.cpp index 5853a5703e7..d3e0df1c164 100644 --- a/cpp/test/Ice/exceptions/Client.cpp +++ b/cpp/test/Ice/exceptions/Client.cpp @@ -40,7 +40,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/exceptions/Collocated.cpp b/cpp/test/Ice/exceptions/Collocated.cpp index cb2be202a7d..f8229233fc6 100644 --- a/cpp/test/Ice/exceptions/Collocated.cpp +++ b/cpp/test/Ice/exceptions/Collocated.cpp @@ -44,7 +44,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/exceptions/Server.cpp b/cpp/test/Ice/exceptions/Server.cpp index 2b6d9b35e0b..2ba01f7723e 100644 --- a/cpp/test/Ice/exceptions/Server.cpp +++ b/cpp/test/Ice/exceptions/Server.cpp @@ -44,7 +44,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/exceptions/TestI.cpp b/cpp/test/Ice/exceptions/TestI.cpp index 5e4a01b5b8e..b50f2866c54 100644 --- a/cpp/test/Ice/exceptions/TestI.cpp +++ b/cpp/test/Ice/exceptions/TestI.cpp @@ -33,7 +33,7 @@ ThrowerI::throwAasA(Ice::Int a, const Ice::Current&) void ThrowerI::throwAorDasAorD(Ice::Int a, const Ice::Current&) { - if (a > 0) + if(a > 0) { A ex; ex.a = a; diff --git a/cpp/test/Ice/exceptions/TestI.h b/cpp/test/Ice/exceptions/TestI.h index afd6095ddc7..ec7415ac750 100644 --- a/cpp/test/Ice/exceptions/TestI.h +++ b/cpp/test/Ice/exceptions/TestI.h @@ -1,42 +1,42 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class ThrowerI : public Thrower -{ -public: - - ThrowerI(const Ice::ObjectAdapterPtr&); - - virtual void shutdown(const Ice::Current&); - virtual void throwAasA(Ice::Int, const Ice::Current&); - virtual void throwAorDasAorD(Ice::Int, const Ice::Current&); - virtual void throwBasA(Ice::Int, Ice::Int, const Ice::Current&); - virtual void throwCasA(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); - virtual void throwBasB(Ice::Int, Ice::Int, const Ice::Current&); - virtual void throwCasB(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); - virtual void throwCasC(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); - virtual bool supportsUndeclaredExceptions(const Ice::Current&); - virtual void throwUndeclaredA(Ice::Int, const Ice::Current&); - virtual void throwUndeclaredB(Ice::Int, Ice::Int, const Ice::Current&); - virtual void throwUndeclaredC(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&); - virtual void throwLocalException(const Ice::Current&); - virtual void throwNonIceException(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class ThrowerI : public Thrower
+{
+public:
+
+ ThrowerI(const Ice::ObjectAdapterPtr&);
+
+ virtual void shutdown(const Ice::Current&);
+ virtual void throwAasA(Ice::Int, const Ice::Current&);
+ virtual void throwAorDasAorD(Ice::Int, const Ice::Current&);
+ virtual void throwBasA(Ice::Int, Ice::Int, const Ice::Current&);
+ virtual void throwCasA(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&);
+ virtual void throwBasB(Ice::Int, Ice::Int, const Ice::Current&);
+ virtual void throwCasB(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&);
+ virtual void throwCasC(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&);
+ virtual bool supportsUndeclaredExceptions(const Ice::Current&);
+ virtual void throwUndeclaredA(Ice::Int, const Ice::Current&);
+ virtual void throwUndeclaredB(Ice::Int, Ice::Int, const Ice::Current&);
+ virtual void throwUndeclaredC(Ice::Int, Ice::Int, Ice::Int, const Ice::Current&);
+ virtual void throwLocalException(const Ice::Current&);
+ virtual void throwNonIceException(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+};
+
+#endif
diff --git a/cpp/test/Ice/facets/Client.cpp b/cpp/test/Ice/facets/Client.cpp index 70940eb44d2..fceb68829a6 100644 --- a/cpp/test/Ice/facets/Client.cpp +++ b/cpp/test/Ice/facets/Client.cpp @@ -40,7 +40,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/facets/Collocated.cpp b/cpp/test/Ice/facets/Collocated.cpp index fee3ebe054f..9e60fe033f0 100644 --- a/cpp/test/Ice/facets/Collocated.cpp +++ b/cpp/test/Ice/facets/Collocated.cpp @@ -48,7 +48,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/facets/Server.cpp b/cpp/test/Ice/facets/Server.cpp index d0901d14894..467cb6e139b 100644 --- a/cpp/test/Ice/facets/Server.cpp +++ b/cpp/test/Ice/facets/Server.cpp @@ -48,7 +48,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/facets/TestI.h b/cpp/test/Ice/facets/TestI.h index 4187cd07f96..ba4ba0ee4f4 100644 --- a/cpp/test/Ice/facets/TestI.h +++ b/cpp/test/Ice/facets/TestI.h @@ -1,71 +1,71 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class AI : virtual public A -{ -public: - - virtual std::string callA(const Ice::Current&); -}; - -class BI : virtual public B, virtual public AI -{ -public: - - virtual std::string callB(const Ice::Current&); -}; - -class CI : virtual public C, virtual public AI -{ -public: - - virtual std::string callC(const Ice::Current&); -}; - -class DI : virtual public D, virtual public BI, virtual public CI -{ -public: - - virtual std::string callD(const Ice::Current&); -}; - -class EI : virtual public E -{ -public: - - virtual std::string callE(const Ice::Current&); -}; - -class FI : virtual public F, virtual public EI -{ -public: - - virtual std::string callF(const Ice::Current&); -}; - -class GI : virtual public G -{ -public: - - GI(const Ice::CommunicatorPtr&); - virtual void shutdown(const Ice::Current&); - virtual std::string callG(const Ice::Current&); - -private: - - Ice::CommunicatorPtr _communicator; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class AI : virtual public A
+{
+public:
+
+ virtual std::string callA(const Ice::Current&);
+};
+
+class BI : virtual public B, virtual public AI
+{
+public:
+
+ virtual std::string callB(const Ice::Current&);
+};
+
+class CI : virtual public C, virtual public AI
+{
+public:
+
+ virtual std::string callC(const Ice::Current&);
+};
+
+class DI : virtual public D, virtual public BI, virtual public CI
+{
+public:
+
+ virtual std::string callD(const Ice::Current&);
+};
+
+class EI : virtual public E
+{
+public:
+
+ virtual std::string callE(const Ice::Current&);
+};
+
+class FI : virtual public F, virtual public EI
+{
+public:
+
+ virtual std::string callF(const Ice::Current&);
+};
+
+class GI : virtual public G
+{
+public:
+
+ GI(const Ice::CommunicatorPtr&);
+ virtual void shutdown(const Ice::Current&);
+ virtual std::string callG(const Ice::Current&);
+
+private:
+
+ Ice::CommunicatorPtr _communicator;
+};
+
+#endif
diff --git a/cpp/test/Ice/faultTolerance/AllTests.cpp b/cpp/test/Ice/faultTolerance/AllTests.cpp index a564b87f7da..bdb7d4a765e 100644 --- a/cpp/test/Ice/faultTolerance/AllTests.cpp +++ b/cpp/test/Ice/faultTolerance/AllTests.cpp @@ -20,7 +20,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const vector<int>& ports) cout << "testing stringToProxy... " << flush; ostringstream ref; ref << "test"; - for (vector<int>::const_iterator p = ports.begin(); p != ports.end(); ++p) + for(vector<int>::const_iterator p = ports.begin(); p != ports.end(); ++p) { ref << ":default -t 4000 -p " << *p; } @@ -35,7 +35,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const vector<int>& ports) cout << "ok" << endl; int oldPid = 0; - for (unsigned int i = 1, j = 0; i <= ports.size(); ++i, j = j >= 2 ? 0 : j + 1) + for(unsigned int i = 1, j = 0; i <= ports.size(); ++i, j = j >= 2 ? 0 : j + 1) { cout << "testing server #" << i << "... " << flush; int pid = obj->pid(); @@ -43,7 +43,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const vector<int>& ports) cout << "ok" << endl; oldPid = pid; - if (j == 0) + if(j == 0) { cout << "shutting down server #" << i << "... " << flush; obj->shutdown(); diff --git a/cpp/test/Ice/faultTolerance/Client.cpp b/cpp/test/Ice/faultTolerance/Client.cpp index 15901f25095..fcf02635eef 100644 --- a/cpp/test/Ice/faultTolerance/Client.cpp +++ b/cpp/test/Ice/faultTolerance/Client.cpp @@ -24,9 +24,9 @@ int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { vector<int> ports; - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (argv[i][0] == '-') + if(argv[i][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; usage(argv[0]); @@ -36,7 +36,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) ports.push_back(atoi(argv[i])); } - if (ports.empty()) + if(ports.empty()) { cerr << argv[0] << ": no ports specified" << endl; usage(argv[0]); @@ -65,7 +65,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/faultTolerance/Server.cpp b/cpp/test/Ice/faultTolerance/Server.cpp index f2015550c10..829a9b78536 100644 --- a/cpp/test/Ice/faultTolerance/Server.cpp +++ b/cpp/test/Ice/faultTolerance/Server.cpp @@ -23,16 +23,16 @@ int run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { int port = 0; - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (argv[i][0] == '-') + if(argv[i][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (port > 0) + if(port > 0) { cerr << argv[0] << ": only one port can be specified" << endl; usage(argv[0]); @@ -42,7 +42,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) port = atoi(argv[i]); } - if (port <= 0) + if(port <= 0) { cerr << argv[0] << ": no port specified" << endl; usage(argv[0]); @@ -77,7 +77,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/faultTolerance/TestI.h b/cpp/test/Ice/faultTolerance/TestI.h index 92e6e9fb225..f54518cfd2d 100644 --- a/cpp/test/Ice/faultTolerance/TestI.h +++ b/cpp/test/Ice/faultTolerance/TestI.h @@ -1,32 +1,32 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class TestI : public Test -{ -public: - - TestI(const Ice::ObjectAdapterPtr&); - - virtual void shutdown(const Ice::Current&); - virtual void abort(const Ice::Current&); - virtual void nonmutatingAbort(const Ice::Current&); - virtual Ice::Int pid(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class TestI : public Test
+{
+public:
+
+ TestI(const Ice::ObjectAdapterPtr&);
+
+ virtual void shutdown(const Ice::Current&);
+ virtual void abort(const Ice::Current&);
+ virtual void nonmutatingAbort(const Ice::Current&);
+ virtual Ice::Int pid(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+};
+
+#endif
diff --git a/cpp/test/Ice/inheritance/Client.cpp b/cpp/test/Ice/inheritance/Client.cpp index c61fa56625c..f09b65b3c7a 100644 --- a/cpp/test/Ice/inheritance/Client.cpp +++ b/cpp/test/Ice/inheritance/Client.cpp @@ -40,7 +40,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/inheritance/Collocated.cpp b/cpp/test/Ice/inheritance/Collocated.cpp index 30dfc6b7233..07cb6f19900 100644 --- a/cpp/test/Ice/inheritance/Collocated.cpp +++ b/cpp/test/Ice/inheritance/Collocated.cpp @@ -44,7 +44,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/inheritance/Server.cpp b/cpp/test/Ice/inheritance/Server.cpp index 72c3d71a759..ed871d4260c 100644 --- a/cpp/test/Ice/inheritance/Server.cpp +++ b/cpp/test/Ice/inheritance/Server.cpp @@ -42,7 +42,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/inheritance/TestI.h b/cpp/test/Ice/inheritance/TestI.h index f6c0da1d649..b245993316a 100644 --- a/cpp/test/Ice/inheritance/TestI.h +++ b/cpp/test/Ice/inheritance/TestI.h @@ -1,102 +1,102 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class InitialI : public Initial -{ -public: - - InitialI(const Ice::ObjectAdapterPtr&); - - virtual void shutdown(const Ice::Current&); - - virtual M_A::C_APrx c_a(const Ice::Current&); - virtual M_B::C_BPrx c_b(const Ice::Current&); - virtual M_A::C_CPrx c_c(const Ice::Current&); - virtual M_A::C_DPrx c_d(const Ice::Current&); - virtual M_A::I_APrx i_a(const Ice::Current&); - virtual M_B::I_B1Prx i_b1(const Ice::Current&); - virtual M_B::I_B2Prx i_b2(const Ice::Current&); - virtual M_A::I_CPrx i_c(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; - M_A::C_APrx _ca; - M_B::C_BPrx _cb; - M_A::C_CPrx _cc; - M_A::C_DPrx _cd; - M_A::I_APrx _ia; - M_B::I_B1Prx _ib1; - M_B::I_B2Prx _ib2; - M_A::I_CPrx _ic; -}; - -class C_A_I : virtual public M_A::C_A -{ -public: - - virtual M_A::C_APrx ca(const M_A::C_APrx&, const Ice::Current&); -}; - -class C_B_I : virtual public M_B::C_B, virtual public C_A_I -{ -public: - - virtual M_B::C_BPrx cb(const M_B::C_BPrx&, const Ice::Current&); -}; - -class C_C_I : virtual public M_A::C_C, virtual public C_B_I -{ -public: - - virtual M_A::C_CPrx cc(const M_A::C_CPrx&, const Ice::Current&); -}; - -class I_A_I : virtual public M_A::I_A -{ -public: - - virtual M_A::I_APrx ia(const M_A::I_APrx&, const Ice::Current&); -}; - -class I_B1_I : virtual public M_B::I_B1, virtual public I_A_I -{ -public: - - virtual M_B::I_B1Prx ib1(const M_B::I_B1Prx&, const Ice::Current&); -}; - -class I_B2_I : virtual public M_B::I_B2, virtual public I_A_I -{ -public: - - virtual M_B::I_B2Prx ib2(const M_B::I_B2Prx&, const Ice::Current&); -}; - -class I_C_I : virtual public M_A::I_C, virtual public I_B1_I, virtual public I_B2_I -{ -public: - - virtual M_A::I_CPrx ic(const M_A::I_CPrx&, const Ice::Current&); -}; - -class C_D_I : virtual public M_A::C_D, virtual public C_C_I, virtual public I_B1_I, virtual public I_B2_I -{ -public: - - virtual M_A::C_DPrx cd(const M_A::C_DPrx&, const Ice::Current&); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class InitialI : public Initial
+{
+public:
+
+ InitialI(const Ice::ObjectAdapterPtr&);
+
+ virtual void shutdown(const Ice::Current&);
+
+ virtual M_A::C_APrx c_a(const Ice::Current&);
+ virtual M_B::C_BPrx c_b(const Ice::Current&);
+ virtual M_A::C_CPrx c_c(const Ice::Current&);
+ virtual M_A::C_DPrx c_d(const Ice::Current&);
+ virtual M_A::I_APrx i_a(const Ice::Current&);
+ virtual M_B::I_B1Prx i_b1(const Ice::Current&);
+ virtual M_B::I_B2Prx i_b2(const Ice::Current&);
+ virtual M_A::I_CPrx i_c(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+ M_A::C_APrx _ca;
+ M_B::C_BPrx _cb;
+ M_A::C_CPrx _cc;
+ M_A::C_DPrx _cd;
+ M_A::I_APrx _ia;
+ M_B::I_B1Prx _ib1;
+ M_B::I_B2Prx _ib2;
+ M_A::I_CPrx _ic;
+};
+
+class C_A_I : virtual public M_A::C_A
+{
+public:
+
+ virtual M_A::C_APrx ca(const M_A::C_APrx&, const Ice::Current&);
+};
+
+class C_B_I : virtual public M_B::C_B, virtual public C_A_I
+{
+public:
+
+ virtual M_B::C_BPrx cb(const M_B::C_BPrx&, const Ice::Current&);
+};
+
+class C_C_I : virtual public M_A::C_C, virtual public C_B_I
+{
+public:
+
+ virtual M_A::C_CPrx cc(const M_A::C_CPrx&, const Ice::Current&);
+};
+
+class I_A_I : virtual public M_A::I_A
+{
+public:
+
+ virtual M_A::I_APrx ia(const M_A::I_APrx&, const Ice::Current&);
+};
+
+class I_B1_I : virtual public M_B::I_B1, virtual public I_A_I
+{
+public:
+
+ virtual M_B::I_B1Prx ib1(const M_B::I_B1Prx&, const Ice::Current&);
+};
+
+class I_B2_I : virtual public M_B::I_B2, virtual public I_A_I
+{
+public:
+
+ virtual M_B::I_B2Prx ib2(const M_B::I_B2Prx&, const Ice::Current&);
+};
+
+class I_C_I : virtual public M_A::I_C, virtual public I_B1_I, virtual public I_B2_I
+{
+public:
+
+ virtual M_A::I_CPrx ic(const M_A::I_CPrx&, const Ice::Current&);
+};
+
+class C_D_I : virtual public M_A::C_D, virtual public C_C_I, virtual public I_B1_I, virtual public I_B2_I
+{
+public:
+
+ virtual M_A::C_DPrx cd(const M_A::C_DPrx&, const Ice::Current&);
+};
+
+#endif
diff --git a/cpp/test/Ice/locationForward/Client.cpp b/cpp/test/Ice/locationForward/Client.cpp index 9751c247209..922ea03d5e7 100644 --- a/cpp/test/Ice/locationForward/Client.cpp +++ b/cpp/test/Ice/locationForward/Client.cpp @@ -25,16 +25,16 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { int port = 0; int lastPort = 0; - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (argv[i][0] == '-') + if(argv[i][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (port == 0) + if(port == 0) { port = atoi(argv[i]); } @@ -50,7 +50,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } } - if (port == 0 || lastPort == 0) + if(port == 0 || lastPort == 0) { cerr << argv[0] << ": no ports specified" << endl; usage(argv[0]); @@ -79,7 +79,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/locationForward/Server.cpp b/cpp/test/Ice/locationForward/Server.cpp index 45d88844d84..37d4c3cfbfc 100644 --- a/cpp/test/Ice/locationForward/Server.cpp +++ b/cpp/test/Ice/locationForward/Server.cpp @@ -24,11 +24,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) { int port = 0; Ice::ObjectPrx fwd; - for (int i = 1; i < argc; ++i) + for(int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "--fwd") == 0) + if(strcmp(argv[i], "--fwd") == 0) { - if (i + 1 >= argc) + if(i + 1 >= argc) { cerr << argv[0] << ": argument expected for`" << argv[i] << "'" << endl; usage(argv[0]); @@ -37,14 +37,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) fwd = communicator->stringToProxy(argv[++i]); } - else if (argv[i][0] == '-') + else if(argv[i][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl; usage(argv[0]); return EXIT_FAILURE; } - if (port > 0) + if(port > 0) { cerr << argv[0] << ": only one port can be specified" << endl; usage(argv[0]); @@ -54,7 +54,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) port = atoi(argv[i]); } - if (port <= 0) + if(port <= 0) { cerr << argv[0] << ": no port specified" << endl; usage(argv[0]); @@ -88,7 +88,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/locationForward/TestI.cpp b/cpp/test/Ice/locationForward/TestI.cpp index 42664aeb1aa..c974c9ccc15 100644 --- a/cpp/test/Ice/locationForward/TestI.cpp +++ b/cpp/test/Ice/locationForward/TestI.cpp @@ -21,7 +21,7 @@ void TestI::shutdown(const Ice::Current&) { _adapter->getCommunicator()->shutdown(); - if (_fwd) + if(_fwd) { throw Ice::LocationForward(_fwd); } diff --git a/cpp/test/Ice/locationForward/TestI.h b/cpp/test/Ice/locationForward/TestI.h index 7613c42d1fb..6a6eeff4019 100644 --- a/cpp/test/Ice/locationForward/TestI.h +++ b/cpp/test/Ice/locationForward/TestI.h @@ -1,30 +1,30 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class TestI : public Test -{ -public: - - TestI(const Ice::ObjectAdapterPtr&, const Ice::ObjectPrx); - - virtual void shutdown(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; - Ice::ObjectPrx _fwd; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class TestI : public Test
+{
+public:
+
+ TestI(const Ice::ObjectAdapterPtr&, const Ice::ObjectPrx);
+
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+ Ice::ObjectPrx _fwd;
+};
+
+#endif
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp index d56035fae13..42be8349914 100644 --- a/cpp/test/Ice/objects/AllTests.cpp +++ b/cpp/test/Ice/objects/AllTests.cpp @@ -71,7 +71,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // // Break cyclic dependencies // - if (!collocated) + if(!collocated) { BPtr::dynamicCast(b1->a)->a = 0; BPtr::dynamicCast(b1->a)->b = 0; @@ -128,7 +128,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // // Break cyclic dependencies // - if (!collocated) + if(!collocated) { b1->a = 0; b1->b = 0; @@ -184,7 +184,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // // Break cyclic dependencies // - if (!collocated) + if(!collocated) { BPtr::dynamicCast(fb1->a)->a = 0; BPtr::dynamicCast(fb1->a)->b = 0; @@ -255,7 +255,7 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) // // Break cyclic dependencies // - if (!collocated) + if(!collocated) { fb1->a = 0; fb1->b = 0; diff --git a/cpp/test/Ice/objects/Client.cpp b/cpp/test/Ice/objects/Client.cpp index b6226000e78..b0dc1a572bc 100644 --- a/cpp/test/Ice/objects/Client.cpp +++ b/cpp/test/Ice/objects/Client.cpp @@ -20,15 +20,15 @@ public: virtual Ice::ObjectPtr create(const string& type) { - if (type == "::B") + if(type == "::B") { return new B; } - else if (type == "::C") + else if(type == "::C") { return new C; } - else if (type == "::D") + else if(type == "::D") { return new D; } @@ -73,7 +73,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/objects/Collocated.cpp b/cpp/test/Ice/objects/Collocated.cpp index 797575818b8..9b5a0a14c26 100644 --- a/cpp/test/Ice/objects/Collocated.cpp +++ b/cpp/test/Ice/objects/Collocated.cpp @@ -44,7 +44,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/objects/Server.cpp b/cpp/test/Ice/objects/Server.cpp index 26fc8ddf062..258dd15843a 100644 --- a/cpp/test/Ice/objects/Server.cpp +++ b/cpp/test/Ice/objects/Server.cpp @@ -42,7 +42,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h index f5b8caf77de..549bf17f805 100644 --- a/cpp/test/Ice/objects/TestI.h +++ b/cpp/test/Ice/objects/TestI.h @@ -1,39 +1,39 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class InitialI : public Initial -{ -public: - - InitialI(const Ice::ObjectAdapterPtr&); - - virtual void shutdown(const Ice::Current&); - virtual BPtr getB1(const Ice::Current&); - virtual BPtr getB2(const Ice::Current&); - virtual CPtr getC(const Ice::Current&); - virtual DPtr getD(const Ice::Current&); - virtual void getAll(BPtr&, BPtr&, CPtr&, DPtr&, const Ice::Current&); - virtual void addFacetsToB1(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; - BPtr _b1; - BPtr _b2; - CPtr _c; - DPtr _d; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class InitialI : public Initial
+{
+public:
+
+ InitialI(const Ice::ObjectAdapterPtr&);
+
+ virtual void shutdown(const Ice::Current&);
+ virtual BPtr getB1(const Ice::Current&);
+ virtual BPtr getB2(const Ice::Current&);
+ virtual CPtr getC(const Ice::Current&);
+ virtual DPtr getD(const Ice::Current&);
+ virtual void getAll(BPtr&, BPtr&, CPtr&, DPtr&, const Ice::Current&);
+ virtual void addFacetsToB1(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+ BPtr _b1;
+ BPtr _b2;
+ CPtr _c;
+ DPtr _d;
+};
+
+#endif
diff --git a/cpp/test/Ice/operations/Client.cpp b/cpp/test/Ice/operations/Client.cpp index 8a9624b5ead..aa111be4083 100644 --- a/cpp/test/Ice/operations/Client.cpp +++ b/cpp/test/Ice/operations/Client.cpp @@ -56,7 +56,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/operations/Collocated.cpp b/cpp/test/Ice/operations/Collocated.cpp index 48bf0bd5f22..b1188d1d132 100644 --- a/cpp/test/Ice/operations/Collocated.cpp +++ b/cpp/test/Ice/operations/Collocated.cpp @@ -44,7 +44,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/operations/Server.cpp b/cpp/test/Ice/operations/Server.cpp index 3c4654b7a66..5592e7cb3c3 100644 --- a/cpp/test/Ice/operations/Server.cpp +++ b/cpp/test/Ice/operations/Server.cpp @@ -43,7 +43,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/Ice/operations/TestI.h b/cpp/test/Ice/operations/TestI.h index 33058813a05..4eb2476351a 100644 --- a/cpp/test/Ice/operations/TestI.h +++ b/cpp/test/Ice/operations/TestI.h @@ -1,161 +1,161 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class MyDerivedClassI : public Test::MyDerivedClass -{ -public: - - MyDerivedClassI(const Ice::ObjectAdapterPtr&, const Ice::Identity&); - - virtual void shutdown(const Ice::Current&); - - virtual void opVoid(const Ice::Current&); - - virtual Ice::Byte opByte(Ice::Byte, - Ice::Byte, - Ice::Byte&, - const Ice::Current&); - - virtual bool opBool(bool, - bool, - bool&, - const Ice::Current&); - - virtual Ice::Long opShortIntLong(Ice::Short, - Ice::Int, - Ice::Long, - Ice::Short&, - Ice::Int&, - Ice::Long&, - const Ice::Current&); - - virtual Ice::Double opFloatDouble(Ice::Float, - Ice::Double, - Ice::Float&, - Ice::Double&, - const Ice::Current&); - - virtual std::string opString(const std::string&, - const std::string&, - std::string&, - const Ice::Current&); - - virtual Test::MyEnum opMyEnum(Test::MyEnum, - Test::MyEnum&, - const Ice::Current&); - - virtual Test::MyClassPrx opMyClass(const Test::MyClassPrx&, - Test::MyClassPrx&, Test::MyClassPrx&, - const Ice::Current&); - - virtual Test::Struct opStruct(const Test::Struct&, const Test::Struct&, - Test::Struct&, - const Ice::Current&); - - virtual Test::ByteS opByteS(const Test::ByteS&, - const Test::ByteS&, - Test::ByteS&, - const Ice::Current&); - - virtual Test::BoolS opBoolS(const Test::BoolS&, - const Test::BoolS&, - Test::BoolS&, - const Ice::Current&); - - virtual Test::LongS opShortIntLongS(const Test::ShortS&, - const Test::IntS&, - const Test::LongS&, - Test::ShortS&, - Test::IntS&, - Test::LongS&, - const Ice::Current&); - - virtual Test::DoubleS opFloatDoubleS(const Test::FloatS&, - const Test::DoubleS&, - Test::FloatS&, - Test::DoubleS&, - const Ice::Current&); - - virtual Test::StringS opStringS(const Test::StringS&, - const Test::StringS&, - Test::StringS&, - const Ice::Current&); - - virtual Test::ByteSS opByteSS(const Test::ByteSS&, - const Test::ByteSS&, - Test::ByteSS&, - const Ice::Current&); - - virtual Test::BoolSS opBoolSS(const Test::BoolSS&, - const Test::BoolSS&, - Test::BoolSS&, - const Ice::Current&); - - virtual Test::LongSS opShortIntLongSS(const Test::ShortSS&, - const Test::IntSS&, - const Test::LongSS&, - Test::ShortSS&, - Test::IntSS&, - Test::LongSS&, - const Ice::Current&); - - virtual Test::DoubleSS opFloatDoubleSS(const Test::FloatSS&, - const Test::DoubleSS&, - Test::FloatSS&, - Test::DoubleSS&, - const Ice::Current&); - - virtual Test::StringSS opStringSS(const Test::StringSS&, - const Test::StringSS&, - Test::StringSS&, - const Ice::Current&); - - virtual Test::ByteBoolD opByteBoolD(const Test::ByteBoolD&, const Test::ByteBoolD&, - Test::ByteBoolD&, - const Ice::Current&); - - virtual Test::ShortIntD opShortIntD(const Test::ShortIntD&, const Test::ShortIntD&, - Test::ShortIntD&, - const Ice::Current&); - - virtual Test::LongFloatD opLongFloatD(const Test::LongFloatD&, const Test::LongFloatD&, - Test::LongFloatD&, - const Ice::Current&); - - virtual Test::DoubleStringD opDoubleStringD(const Test::DoubleStringD&, const Test::DoubleStringD&, - Test::DoubleStringD&, - const Ice::Current&); - - virtual Test::StringStringD opStringStringD(const Test::StringStringD&, const Test::StringStringD&, - Test::StringStringD&, - const Ice::Current&); - - virtual Test::StringMyEnumD opStringMyEnumD(const Test::StringMyEnumD&, const Test::StringMyEnumD&, - Test::StringMyEnumD&, - const Ice::Current&); - - virtual Test::MyClassStringD opMyClassStringD(const Test::MyClassStringD&, const Test::MyClassStringD&, - Test::MyClassStringD&, - const Ice::Current&); - - virtual void opDerived(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; - Ice::Identity _identity; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class MyDerivedClassI : public Test::MyDerivedClass
+{
+public:
+
+ MyDerivedClassI(const Ice::ObjectAdapterPtr&, const Ice::Identity&);
+
+ virtual void shutdown(const Ice::Current&);
+
+ virtual void opVoid(const Ice::Current&);
+
+ virtual Ice::Byte opByte(Ice::Byte,
+ Ice::Byte,
+ Ice::Byte&,
+ const Ice::Current&);
+
+ virtual bool opBool(bool,
+ bool,
+ bool&,
+ const Ice::Current&);
+
+ virtual Ice::Long opShortIntLong(Ice::Short,
+ Ice::Int,
+ Ice::Long,
+ Ice::Short&,
+ Ice::Int&,
+ Ice::Long&,
+ const Ice::Current&);
+
+ virtual Ice::Double opFloatDouble(Ice::Float,
+ Ice::Double,
+ Ice::Float&,
+ Ice::Double&,
+ const Ice::Current&);
+
+ virtual std::string opString(const std::string&,
+ const std::string&,
+ std::string&,
+ const Ice::Current&);
+
+ virtual Test::MyEnum opMyEnum(Test::MyEnum,
+ Test::MyEnum&,
+ const Ice::Current&);
+
+ virtual Test::MyClassPrx opMyClass(const Test::MyClassPrx&,
+ Test::MyClassPrx&, Test::MyClassPrx&,
+ const Ice::Current&);
+
+ virtual Test::Struct opStruct(const Test::Struct&, const Test::Struct&,
+ Test::Struct&,
+ const Ice::Current&);
+
+ virtual Test::ByteS opByteS(const Test::ByteS&,
+ const Test::ByteS&,
+ Test::ByteS&,
+ const Ice::Current&);
+
+ virtual Test::BoolS opBoolS(const Test::BoolS&,
+ const Test::BoolS&,
+ Test::BoolS&,
+ const Ice::Current&);
+
+ virtual Test::LongS opShortIntLongS(const Test::ShortS&,
+ const Test::IntS&,
+ const Test::LongS&,
+ Test::ShortS&,
+ Test::IntS&,
+ Test::LongS&,
+ const Ice::Current&);
+
+ virtual Test::DoubleS opFloatDoubleS(const Test::FloatS&,
+ const Test::DoubleS&,
+ Test::FloatS&,
+ Test::DoubleS&,
+ const Ice::Current&);
+
+ virtual Test::StringS opStringS(const Test::StringS&,
+ const Test::StringS&,
+ Test::StringS&,
+ const Ice::Current&);
+
+ virtual Test::ByteSS opByteSS(const Test::ByteSS&,
+ const Test::ByteSS&,
+ Test::ByteSS&,
+ const Ice::Current&);
+
+ virtual Test::BoolSS opBoolSS(const Test::BoolSS&,
+ const Test::BoolSS&,
+ Test::BoolSS&,
+ const Ice::Current&);
+
+ virtual Test::LongSS opShortIntLongSS(const Test::ShortSS&,
+ const Test::IntSS&,
+ const Test::LongSS&,
+ Test::ShortSS&,
+ Test::IntSS&,
+ Test::LongSS&,
+ const Ice::Current&);
+
+ virtual Test::DoubleSS opFloatDoubleSS(const Test::FloatSS&,
+ const Test::DoubleSS&,
+ Test::FloatSS&,
+ Test::DoubleSS&,
+ const Ice::Current&);
+
+ virtual Test::StringSS opStringSS(const Test::StringSS&,
+ const Test::StringSS&,
+ Test::StringSS&,
+ const Ice::Current&);
+
+ virtual Test::ByteBoolD opByteBoolD(const Test::ByteBoolD&, const Test::ByteBoolD&,
+ Test::ByteBoolD&,
+ const Ice::Current&);
+
+ virtual Test::ShortIntD opShortIntD(const Test::ShortIntD&, const Test::ShortIntD&,
+ Test::ShortIntD&,
+ const Ice::Current&);
+
+ virtual Test::LongFloatD opLongFloatD(const Test::LongFloatD&, const Test::LongFloatD&,
+ Test::LongFloatD&,
+ const Ice::Current&);
+
+ virtual Test::DoubleStringD opDoubleStringD(const Test::DoubleStringD&, const Test::DoubleStringD&,
+ Test::DoubleStringD&,
+ const Ice::Current&);
+
+ virtual Test::StringStringD opStringStringD(const Test::StringStringD&, const Test::StringStringD&,
+ Test::StringStringD&,
+ const Ice::Current&);
+
+ virtual Test::StringMyEnumD opStringMyEnumD(const Test::StringMyEnumD&, const Test::StringMyEnumD&,
+ Test::StringMyEnumD&,
+ const Ice::Current&);
+
+ virtual Test::MyClassStringD opMyClassStringD(const Test::MyClassStringD&, const Test::MyClassStringD&,
+ Test::MyClassStringD&,
+ const Ice::Current&);
+
+ virtual void opDerived(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+ Ice::Identity _identity;
+};
+
+#endif
diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index 5d3f9ee2f1e..c3c0f2f4411 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -605,11 +605,11 @@ twoways(const Test::MyClassPrx& p) test(ro[0] == "def"); int i = 0; - for (Test::MyClassStringD::iterator q = ro.begin(); q != ro.end(); ++q, ++i) + for(Test::MyClassStringD::iterator q = ro.begin(); q != ro.end(); ++q, ++i) { test(i < 2); - if (i == 0) + if(i == 0) { test(!q->first); } diff --git a/cpp/test/IcePack/simple/Client.cpp b/cpp/test/IcePack/simple/Client.cpp index 42599491d65..99eefdd2c49 100644 --- a/cpp/test/IcePack/simple/Client.cpp +++ b/cpp/test/IcePack/simple/Client.cpp @@ -44,7 +44,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IcePack/simple/Collocated.cpp b/cpp/test/IcePack/simple/Collocated.cpp index cbddcd886a8..dea6eab61bb 100644 --- a/cpp/test/IcePack/simple/Collocated.cpp +++ b/cpp/test/IcePack/simple/Collocated.cpp @@ -43,7 +43,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IcePack/simple/Server.cpp b/cpp/test/IcePack/simple/Server.cpp index f936bfa400f..0e81cf011d5 100644 --- a/cpp/test/IcePack/simple/Server.cpp +++ b/cpp/test/IcePack/simple/Server.cpp @@ -42,7 +42,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IcePack/simple/TestI.h b/cpp/test/IcePack/simple/TestI.h index 61a45f24e07..026b17a7ffa 100644 --- a/cpp/test/IcePack/simple/TestI.h +++ b/cpp/test/IcePack/simple/TestI.h @@ -1,29 +1,29 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_I_H -#define TEST_I_H - -#include <Test.h> - -class TestI : public Test -{ -public: - - TestI(const Ice::ObjectAdapterPtr&); - - virtual void shutdown(const Ice::Current&); - -private: - - Ice::ObjectAdapterPtr _adapter; -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_I_H
+#define TEST_I_H
+
+#include <Test.h>
+
+class TestI : public Test
+{
+public:
+
+ TestI(const Ice::ObjectAdapterPtr&);
+
+ virtual void shutdown(const Ice::Current&);
+
+private:
+
+ Ice::ObjectAdapterPtr _adapter;
+};
+
+#endif
diff --git a/cpp/test/IceSSL/certificateAndKeyParsing/CertificateAndKeyParsing.cpp b/cpp/test/IceSSL/certificateAndKeyParsing/CertificateAndKeyParsing.cpp index 9adbd595e42..71db33dbfcb 100644 --- a/cpp/test/IceSSL/certificateAndKeyParsing/CertificateAndKeyParsing.cpp +++ b/cpp/test/IceSSL/certificateAndKeyParsing/CertificateAndKeyParsing.cpp @@ -748,7 +748,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceSSL/certificateVerification/Client.cpp b/cpp/test/IceSSL/certificateVerification/Client.cpp index 9b1f6dd4ca2..dfd31ccfea8 100644 --- a/cpp/test/IceSSL/certificateVerification/Client.cpp +++ b/cpp/test/IceSSL/certificateVerification/Client.cpp @@ -46,12 +46,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) properties->setProperty("IceSSL.Server.CertPath", serverCertPath); bool singleCertVerifier = false; - if (properties->getProperty("IceSSL.Client.CertificateVerifier") == "singleCert") + if(properties->getProperty("IceSSL.Client.CertificateVerifier") == "singleCert") { singleCertVerifier = true; } - if (!singleCertVerifier) + if(!singleCertVerifier) { cout << "client and server trusted, client using stock certificate... "; @@ -79,7 +79,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // Neither Client nor Server will trust. sslPlugin->configure(IceSSL::Client); sslPlugin->addTrustedCertificate(IceSSL::Client, serverUntrustedCert); - if (singleCertVerifier) + if(singleCertVerifier) { IceSSL::CertificateVerifierPtr certVerifier = sslPlugin->getSingleCertVerifier(serverUntrustedCert); sslPlugin->setCertificateVerifier(IceSSL::Client, certVerifier); @@ -128,7 +128,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // Client trusts, Server does not. sslPlugin->configure(IceSSL::Client); sslPlugin->addTrustedCertificate(IceSSL::Client, serverTrustedCert); - if (singleCertVerifier) + if(singleCertVerifier) { IceSSL::CertificateVerifierPtr certVerifier = sslPlugin->getSingleCertVerifier(serverTrustedCert); sslPlugin->setCertificateVerifier(IceSSL::Client, certVerifier); @@ -194,7 +194,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceSSL/certificateVerification/Server.cpp b/cpp/test/IceSSL/certificateVerification/Server.cpp index e41cb785c9a..37707715064 100644 --- a/cpp/test/IceSSL/certificateVerification/Server.cpp +++ b/cpp/test/IceSSL/certificateVerification/Server.cpp @@ -153,7 +153,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) sslPlugin->addTrustedCertificate(IceSSL::Server, trustedCertificate); sslPlugin->setRSAKeys(IceSSL::Server, serverKey, serverCertificate); - if (properties->getProperty("IceSSL.Server.CertificateVerifier") == "singleCert") + if(properties->getProperty("IceSSL.Server.CertificateVerifier") == "singleCert") { IceSSL::CertificateVerifierPtr certVerifier = sslPlugin->getSingleCertVerifier(trustedCertificate); sslPlugin->setCertificateVerifier(IceSSL::Server, certVerifier); @@ -189,7 +189,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceSSL/certificateVerifier/CertificateVerifier.cpp b/cpp/test/IceSSL/certificateVerifier/CertificateVerifier.cpp index 96ddb381a54..c52e67d6b67 100644 --- a/cpp/test/IceSSL/certificateVerifier/CertificateVerifier.cpp +++ b/cpp/test/IceSSL/certificateVerifier/CertificateVerifier.cpp @@ -168,7 +168,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceSSL/configuration/Configuration.cpp b/cpp/test/IceSSL/configuration/Configuration.cpp index 03e63b656d2..f75d76a12e3 100644 --- a/cpp/test/IceSSL/configuration/Configuration.cpp +++ b/cpp/test/IceSSL/configuration/Configuration.cpp @@ -45,7 +45,7 @@ testContextWithConfig(const Ice::CommunicatorPtr& communicator, std::string clientPropertyString = "IceSSL.Client.Config"; std::string serverPropertyString = "IceSSL.Server.Config"; - switch (contextType) + switch(contextType) { case IceSSL::Client: { @@ -68,15 +68,15 @@ testContextWithConfig(const Ice::CommunicatorPtr& communicator, std::string configFileDesc = ""; - if (!clientFile.empty() && !serverFile.empty()) + if(!clientFile.empty() && !serverFile.empty()) { configFileDesc = "client and server configuration files"; } - else if (!clientFile.empty()) + else if(!clientFile.empty()) { configFileDesc = "client configuration file"; } - else if (!serverFile.empty()) + else if(!serverFile.empty()) { configFileDesc = "server configuration file"; } @@ -93,7 +93,7 @@ testContextWithConfig(const Ice::CommunicatorPtr& communicator, properties->setProperty(serverPropertyString, serverFile); sslPlugin->configure(contextType); - if (expectFailure) + if(expectFailure) { test(false); } @@ -109,11 +109,11 @@ testContextWithConfig(const Ice::CommunicatorPtr& communicator, // a configuration file, this might be a valid response. // - switch (contextType) + switch(contextType) { case IceSSL::Client: { - if (clientFile.empty()) + if(clientFile.empty()) { std::cout << "ok" << std::endl; } @@ -126,7 +126,7 @@ testContextWithConfig(const Ice::CommunicatorPtr& communicator, case IceSSL::Server: { - if (serverFile.empty()) + if(serverFile.empty()) { std::cout << "ok" << std::endl; } @@ -139,7 +139,7 @@ testContextWithConfig(const Ice::CommunicatorPtr& communicator, case IceSSL::ClientServer: { - if (clientFile.empty() || serverFile.empty()) + if(clientFile.empty() || serverFile.empty()) { std::cout << "ok" << std::endl; } @@ -207,7 +207,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceSSL/loadPEM/LoadPEM.cpp b/cpp/test/IceSSL/loadPEM/LoadPEM.cpp index 933f90a9272..856bd4f17dd 100644 --- a/cpp/test/IceSSL/loadPEM/LoadPEM.cpp +++ b/cpp/test/IceSSL/loadPEM/LoadPEM.cpp @@ -236,7 +236,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceStorm/federation/Publisher.cpp b/cpp/test/IceStorm/federation/Publisher.cpp index 6a67fb40ea5..65e54e1c4ae 100644 --- a/cpp/test/IceStorm/federation/Publisher.cpp +++ b/cpp/test/IceStorm/federation/Publisher.cpp @@ -27,7 +27,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) const char* managerEndpointsProperty = "IceStorm.TopicManager.Endpoints"; string managerEndpoints = properties->getProperty(managerEndpointsProperty); - if (managerEndpoints.empty()) + if(managerEndpoints.empty()) { cerr << argv[0] << ": property `" << managerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -35,7 +35,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) ObjectPrx base = communicator->stringToProxy("TopicManager:" + managerEndpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << argv[0] << ": `" << managerEndpoints << "' is not running" << endl; return EXIT_FAILURE; @@ -92,37 +92,37 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) Ice::Context context; int i; context["cost"] = "0"; - for (i = 0; i < 10; ++i) + for(i = 0; i < 10; ++i) { eventFed1->pub("fed1:0", context); } context["cost"] = "10"; - for (i = 0; i < 10; ++i) + for(i = 0; i < 10; ++i) { eventFed1->pub("fed1:10", context); } context["cost"] = "15"; - for (i = 0; i < 10; ++i) + for(i = 0; i < 10; ++i) { eventFed1->pub("fed1:15", context); } context["cost"] = "0"; - for (i = 0; i < 10; ++i) + for(i = 0; i < 10; ++i) { eventFed2->pub("fed2:0", context); } context["cost"] = "5"; - for (i = 0; i < 10; ++i) + for(i = 0; i < 10; ++i) { eventFed2->pub("fed2:5", context); } context["cost"] = "0"; - for (i = 0; i < 10; ++i) + for(i = 0; i < 10; ++i) { eventFed3->pub("fed3:0", context); } @@ -158,7 +158,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceStorm/federation/Subscriber.cpp b/cpp/test/IceStorm/federation/Subscriber.cpp index 6675459c30f..067532feeaa 100644 --- a/cpp/test/IceStorm/federation/Subscriber.cpp +++ b/cpp/test/IceStorm/federation/Subscriber.cpp @@ -35,7 +35,7 @@ public: virtual void pub(const string& data, const Ice::Current&) { - if (data == "shutdown") + if(data == "shutdown") { _communicator->shutdown(); return; @@ -80,7 +80,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string lockfile = "subscriber.lock"; - if (argc != 1) + if(argc != 1) { lockfile = argv[1]; } @@ -88,7 +88,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) const char* managerEndpointsProperty = "IceStorm.TopicManager.Endpoints"; string managerEndpoints = properties->getProperty(managerEndpointsProperty); - if (managerEndpoints.empty()) + if(managerEndpoints.empty()) { cerr << argv[0] << ": property `" << managerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -96,7 +96,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) ObjectPrx base = communicator->stringToProxy("TopicManager:" + managerEndpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << argv[0] << ": `" << managerEndpoints << "' is not running" << endl; return EXIT_FAILURE; @@ -162,7 +162,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceStorm/single/Publisher.cpp b/cpp/test/IceStorm/single/Publisher.cpp index 57dcf0d986f..719a253fcf9 100644 --- a/cpp/test/IceStorm/single/Publisher.cpp +++ b/cpp/test/IceStorm/single/Publisher.cpp @@ -27,7 +27,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) const char* managerEndpointsProperty = "IceStorm.TopicManager.Endpoints"; string managerEndpoints = properties->getProperty(managerEndpointsProperty); - if (managerEndpoints.empty()) + if(managerEndpoints.empty()) { cerr << argv[0] << ": property `" << managerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -35,7 +35,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) ObjectPrx base = communicator->stringToProxy("TopicManager:" + managerEndpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << argv[0] << ": `" << managerEndpoints << "' is not running" << endl; return EXIT_FAILURE; @@ -62,7 +62,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) obj = obj->ice_oneway(); SinglePrx single = SinglePrx::uncheckedCast(obj); - for (int i = 0; i < 10; ++i) + for(int i = 0; i < 10; ++i) { single->event(); } @@ -87,7 +87,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index 2b3ce84f898..0a7cb0aeaea 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -34,7 +34,7 @@ public: virtual void event(const Current&) { ++_count; - if (_count == 10) + if(_count == 10) { _communicator->shutdown(); } @@ -73,7 +73,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string lockfile = "subscriber.lock"; - if (argc != 1) + if(argc != 1) { lockfile = argv[1]; } @@ -81,7 +81,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) const char* managerEndpointsProperty = "IceStorm.TopicManager.Endpoints"; string managerEndpoints = properties->getProperty(managerEndpointsProperty); - if (managerEndpoints.empty()) + if(managerEndpoints.empty()) { cerr << argv[0] << ": property `" << managerEndpointsProperty << "' is not set" << endl; return EXIT_FAILURE; @@ -89,7 +89,7 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) ObjectPrx base = communicator->stringToProxy("TopicManager:" + managerEndpoints); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); - if (!manager) + if(!manager) { cerr << argv[0] << ": `" << managerEndpoints << "' is not running" << endl; return EXIT_FAILURE; @@ -137,7 +137,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/IceUtil/thread/Client.cpp b/cpp/test/IceUtil/thread/Client.cpp index ac56aac9a00..2c78d2ee7a8 100644 --- a/cpp/test/IceUtil/thread/Client.cpp +++ b/cpp/test/IceUtil/thread/Client.cpp @@ -24,7 +24,7 @@ main(int argc, char** argv) { initializeTestSuite(); - for (list<TestBasePtr>::const_iterator p = allTests.begin(); p != allTests.end(); ++p) + for(list<TestBasePtr>::const_iterator p = allTests.begin(); p != allTests.end(); ++p) { (*p)->start(); } diff --git a/cpp/test/IceUtil/thread/CreateTest.cpp b/cpp/test/IceUtil/thread/CreateTest.cpp index fb91e8e8b89..8c852b21dc4 100644 --- a/cpp/test/IceUtil/thread/CreateTest.cpp +++ b/cpp/test/IceUtil/thread/CreateTest.cpp @@ -47,13 +47,13 @@ CreateTest::CreateTest() : void CreateTest::run() { - for (int i = 0; i < 4096 ; ++i) + for(int i = 0; i < 4096 ; ++i) { CreateTestThreadPtr t = new CreateTestThread(); ThreadControl control = t->start(); control.join(); test(t->threadran); - if ((i % 256) == 0) + if((i % 256) == 0) { char buf[5]; sprintf(buf, "%04d", i); diff --git a/cpp/test/IceUtil/thread/CreateTest.h b/cpp/test/IceUtil/thread/CreateTest.h index 48fb2ff64a0..4418f22dfef 100644 --- a/cpp/test/IceUtil/thread/CreateTest.h +++ b/cpp/test/IceUtil/thread/CreateTest.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef CREATE_TEST_H -#define CREATE_TEST_H - -#include <TestBase.h> - -class CreateTest : public TestBase -{ -public: - - CreateTest(); - -private: - - virtual void run(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef CREATE_TEST_H
+#define CREATE_TEST_H
+
+#include <TestBase.h>
+
+class CreateTest : public TestBase
+{
+public:
+
+ CreateTest();
+
+private:
+
+ virtual void run();
+};
+
+#endif
diff --git a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp index 7f3e59cea70..f148c3939ed 100644 --- a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp @@ -48,7 +48,7 @@ public: waitTrylock() { Mutex::Lock lock(_trylockMutex); - while (!_trylock) + while(!_trylock) { _trylockCond.wait(lock); } diff --git a/cpp/test/IceUtil/thread/MonitorMutexTest.h b/cpp/test/IceUtil/thread/MonitorMutexTest.h index 93e3a828de0..108d72c7d22 100644 --- a/cpp/test/IceUtil/thread/MonitorMutexTest.h +++ b/cpp/test/IceUtil/thread/MonitorMutexTest.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef MONITOR_MUTEX_TEST_H -#define MONITOR_MUTEX_TEST_H - -#include <TestBase.h> - -class MonitorMutexTest : public TestBase -{ -public: - - MonitorMutexTest(); - -private: - - virtual void run(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef MONITOR_MUTEX_TEST_H
+#define MONITOR_MUTEX_TEST_H
+
+#include <TestBase.h>
+
+class MonitorMutexTest : public TestBase
+{
+public:
+
+ MonitorMutexTest();
+
+private:
+
+ virtual void run();
+};
+
+#endif
diff --git a/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp index 320b74a49d7..5cf5cda5534 100644 --- a/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp @@ -48,7 +48,7 @@ public: waitTrylock() { Mutex::Lock lock(_trylockMutex); - while (!_trylock) + while(!_trylock) { _trylockCond.wait(lock); } diff --git a/cpp/test/IceUtil/thread/MonitorRecMutexTest.h b/cpp/test/IceUtil/thread/MonitorRecMutexTest.h index 979267efd0a..9630deed340 100644 --- a/cpp/test/IceUtil/thread/MonitorRecMutexTest.h +++ b/cpp/test/IceUtil/thread/MonitorRecMutexTest.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef MONITOR_REC_MUTEX_TEST_H -#define MONITOR_REC_MUTEX_TEST_H - -#include <TestBase.h> - -class MonitorRecMutexTest : public TestBase -{ -public: - - MonitorRecMutexTest(); - -private: - - virtual void run(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef MONITOR_REC_MUTEX_TEST_H
+#define MONITOR_REC_MUTEX_TEST_H
+
+#include <TestBase.h>
+
+class MonitorRecMutexTest : public TestBase
+{
+public:
+
+ MonitorRecMutexTest();
+
+private:
+
+ virtual void run();
+};
+
+#endif
diff --git a/cpp/test/IceUtil/thread/MutexTest.cpp b/cpp/test/IceUtil/thread/MutexTest.cpp index 33e131c42a1..be271e97ce9 100644 --- a/cpp/test/IceUtil/thread/MutexTest.cpp +++ b/cpp/test/IceUtil/thread/MutexTest.cpp @@ -50,7 +50,7 @@ public: waitTrylock() { Mutex::Lock lock(_trylockMutex); - while (!_trylock) + while(!_trylock) { _trylockCond.wait(lock); } diff --git a/cpp/test/IceUtil/thread/MutexTest.h b/cpp/test/IceUtil/thread/MutexTest.h index cd688a3358a..d21a8a5e27b 100644 --- a/cpp/test/IceUtil/thread/MutexTest.h +++ b/cpp/test/IceUtil/thread/MutexTest.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef MUTEX_TEST_H -#define MUTEX_TEST_H - -#include <TestBase.h> - -class MutexTest : public TestBase -{ -public: - - MutexTest(); - -private: - - virtual void run(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef MUTEX_TEST_H
+#define MUTEX_TEST_H
+
+#include <TestBase.h>
+
+class MutexTest : public TestBase
+{
+public:
+
+ MutexTest();
+
+private:
+
+ virtual void run();
+};
+
+#endif
diff --git a/cpp/test/IceUtil/thread/RWRecMutexTest.cpp b/cpp/test/IceUtil/thread/RWRecMutexTest.cpp index ccd040f3544..85deaa75606 100644 --- a/cpp/test/IceUtil/thread/RWRecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/RWRecMutexTest.cpp @@ -32,7 +32,7 @@ public: waitTrylock() { Mutex::Lock lock(_trylockMutex); - while (!_trylock) + while(!_trylock) { _trylockCond.wait(lock); } @@ -131,7 +131,7 @@ public: waitUnlock() { Mutex::Lock lock(_unlockMutex); - while (!_unlock) + while(!_unlock) { _unlockCond.wait(lock); } @@ -157,7 +157,7 @@ public: waitLock() { Mutex::Lock lock(_lockMutex); - while (!_lock) + while(!_lock) { _lockCond.wait(lock); } @@ -214,7 +214,7 @@ public: waitLock() { Mutex::Lock lock(_lockMutex); - while (!_lock) + while(!_lock) { _lockCond.wait(lock); } diff --git a/cpp/test/IceUtil/thread/RWRecMutexTest.h b/cpp/test/IceUtil/thread/RWRecMutexTest.h index cc929b595c1..3ca84c1631e 100644 --- a/cpp/test/IceUtil/thread/RWRecMutexTest.h +++ b/cpp/test/IceUtil/thread/RWRecMutexTest.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef RW_REC_MUTEX_TEST_H -#define RE_REC_MUTEX_TEST_H - -#include <TestBase.h> - -class RWRecMutexTest : public TestBase -{ -public: - - RWRecMutexTest(); - -private: - - virtual void run(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef RW_REC_MUTEX_TEST_H
+#define RE_REC_MUTEX_TEST_H
+
+#include <TestBase.h>
+
+class RWRecMutexTest : public TestBase
+{
+public:
+
+ RWRecMutexTest();
+
+private:
+
+ virtual void run();
+};
+
+#endif
diff --git a/cpp/test/IceUtil/thread/RecMutexTest.cpp b/cpp/test/IceUtil/thread/RecMutexTest.cpp index 1a95c4e3f44..0c80945668e 100644 --- a/cpp/test/IceUtil/thread/RecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/RecMutexTest.cpp @@ -50,7 +50,7 @@ public: waitTrylock() { Mutex::Lock lock(_trylockMutex); - while (!_trylock) + while(!_trylock) { _trylockCond.wait(lock); } diff --git a/cpp/test/IceUtil/thread/RecMutexTest.h b/cpp/test/IceUtil/thread/RecMutexTest.h index b2d8a215f2a..8b7476ca14b 100644 --- a/cpp/test/IceUtil/thread/RecMutexTest.h +++ b/cpp/test/IceUtil/thread/RecMutexTest.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef REC_MUTEX_TEST_H -#define REC_MUTEX_TEST_H - -#include <TestBase.h> - -class RecMutexTest : public TestBase -{ -public: - - RecMutexTest(); - -private: - - virtual void run(); -}; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef REC_MUTEX_TEST_H
+#define REC_MUTEX_TEST_H
+
+#include <TestBase.h>
+
+class RecMutexTest : public TestBase
+{
+public:
+
+ RecMutexTest();
+
+private:
+
+ virtual void run();
+};
+
+#endif
diff --git a/cpp/test/IceUtil/thread/TestBase.h b/cpp/test/IceUtil/thread/TestBase.h index b1943fdd056..2b381289c43 100644 --- a/cpp/test/IceUtil/thread/TestBase.h +++ b/cpp/test/IceUtil/thread/TestBase.h @@ -1,44 +1,44 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_BASE_H -#define TEST_BASE_H - -#include <IceUtil/Shared.h> -#include <IceUtil/Handle.h> - -class TestFailed -{ -public: - - TestFailed(const std::string&); - - const std::string name; -}; - -class TestBase : public IceUtil::Shared -{ -public: - - TestBase(const std::string&); - - std::string name() const; - void start(); - -protected: - - virtual void run() = 0; - - const std::string _name; -}; - -typedef IceUtil::Handle<TestBase> TestBasePtr; - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_BASE_H
+#define TEST_BASE_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Handle.h>
+
+class TestFailed
+{
+public:
+
+ TestFailed(const std::string&);
+
+ const std::string name;
+};
+
+class TestBase : public IceUtil::Shared
+{
+public:
+
+ TestBase(const std::string&);
+
+ std::string name() const;
+ void start();
+
+protected:
+
+ virtual void run() = 0;
+
+ const std::string _name;
+};
+
+typedef IceUtil::Handle<TestBase> TestBasePtr;
+
+#endif
diff --git a/cpp/test/IceUtil/thread/TestSuite.h b/cpp/test/IceUtil/thread/TestSuite.h index 81ca06d9f8f..db3e08318e7 100644 --- a/cpp/test/IceUtil/thread/TestSuite.h +++ b/cpp/test/IceUtil/thread/TestSuite.h @@ -1,22 +1,22 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_SUITE_H -#define TEST_SUITE_H - -#include <TestBase.h> -#include <list> - -extern std::list<TestBasePtr> allTests; - -void initializeTestSuite(); - -#endif - +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_SUITE_H
+#define TEST_SUITE_H
+
+#include <TestBase.h>
+#include <list>
+
+extern std::list<TestBasePtr> allTests;
+
+void initializeTestSuite();
+
+#endif
+
diff --git a/cpp/test/IceUtil/unicode/Client.cpp b/cpp/test/IceUtil/unicode/Client.cpp index 9b0ab9d7aee..8f198383487 100644 --- a/cpp/test/IceUtil/unicode/Client.cpp +++ b/cpp/test/IceUtil/unicode/Client.cpp @@ -1,103 +1,103 @@ -// **********************************************************************
-//
-// Copyright (c) 2001
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-
-#include <IceUtil/Unicode.h>
-#include <TestCommon.h>
-#include <fstream>
-
-using namespace IceUtil;
-using namespace std;
-
-int
-main(int, char**)
-{
- cout << "testing string/wstring conversion... ";
-
- string arabic = "لماذا لا يتكلمون اللّغة العربية فحسب؟";
-
- wstring warabic = stringToWstring(arabic);
- test(warabic.length() == 37);
-
- string arabic2 = wstringToString(warabic);
- test(arabic2.length() == arabic.length());
- test(arabic2 == arabic);
-
- string japanese = "なぜ、みんな日本語を話してくれないのか?";
-
- wstring wjapanese = stringToWstring(japanese);
- test(wjapanese.length() == 20);
-
- string japanese2 = wstringToString(wjapanese);
- test(japanese2.length() == japanese.length());
- test(japanese2 == japanese);
-
- cout << "ok" << endl;
-
- cout << "ditto, but with random unicode text... ";
-
- ifstream numeric("numeric.txt");
- test(numeric.good());
- wstring wrandom;
- while (numeric)
- {
- int c;
- numeric >> c;
- if (numeric)
- {
- wrandom += static_cast<wchar_t>(c);
- }
- }
- numeric.close();
-
- ifstream utf8("utf8.txt");
- test(utf8.good());
- string random;
- while (utf8)
- {
- char c;
- utf8.get(c);
- if (utf8)
- {
- random += c;
- }
- }
- utf8.close();
-
- string random2 = wstringToString(wrandom);
- wstring wrandom2 = stringToWstring(random);
-
-/*
- unsigned int i;
-
- ofstream numeric2("numeric2.txt");
- for (i = 0; i < wrandom2.length(); ++i)
- {
- numeric2 << static_cast<int>(wrandom2[i]) << '\n';
- }
- numeric2.close();
-
- ofstream utf82("utf82.txt");
- for (i = 0; i < random2.length(); ++i)
- {
- utf82.put(random2[i]);
- }
- utf82.close();
-*/
-
- test (random2.length() == random.length());
- test (wrandom2.length() == wrandom.length());
-
- test (random2 == random);
- test (wrandom2 == wrandom);
-
- cout << "ok" << endl;
-
- return EXIT_SUCCESS;
-}
+// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <IceUtil/Unicode.h> +#include <TestCommon.h> +#include <fstream> + +using namespace IceUtil; +using namespace std; + +int +main(int, char**) +{ + cout << "testing string/wstring conversion... "; + + string arabic = "لماذا لا يتكلمون اللّغة العربية فحسب؟"; + + wstring warabic = stringToWstring(arabic); + test(warabic.length() == 37); + + string arabic2 = wstringToString(warabic); + test(arabic2.length() == arabic.length()); + test(arabic2 == arabic); + + string japanese = "なぜ、みんな日本語を話してくれないのか?"; + + wstring wjapanese = stringToWstring(japanese); + test(wjapanese.length() == 20); + + string japanese2 = wstringToString(wjapanese); + test(japanese2.length() == japanese.length()); + test(japanese2 == japanese); + + cout << "ok" << endl; + + cout << "ditto, but with random unicode text... "; + + ifstream numeric("numeric.txt"); + test(numeric.good()); + wstring wrandom; + while(numeric) + { + int c; + numeric >> c; + if(numeric) + { + wrandom += static_cast<wchar_t>(c); + } + } + numeric.close(); + + ifstream utf8("utf8.txt"); + test(utf8.good()); + string random; + while(utf8) + { + char c; + utf8.get(c); + if(utf8) + { + random += c; + } + } + utf8.close(); + + string random2 = wstringToString(wrandom); + wstring wrandom2 = stringToWstring(random); + +/* + unsigned int i; + + ofstream numeric2("numeric2.txt"); + for(i = 0; i < wrandom2.length(); ++i) + { + numeric2 << static_cast<int>(wrandom2[i]) << '\n'; + } + numeric2.close(); + + ofstream utf82("utf82.txt"); + for(i = 0; i < random2.length(); ++i) + { + utf82.put(random2[i]); + } + utf82.close(); +*/ + + test (random2.length() == random.length()); + test (wrandom2.length() == wrandom.length()); + + test (random2 == random); + test (wrandom2 == wrandom); + + cout << "ok" << endl; + + return EXIT_SUCCESS; +} diff --git a/cpp/test/IceUtil/unicode/Makefile b/cpp/test/IceUtil/unicode/Makefile index eeefa0ca689..7e235893f5f 100644 --- a/cpp/test/IceUtil/unicode/Makefile +++ b/cpp/test/IceUtil/unicode/Makefile @@ -1,30 +1,30 @@ -# **********************************************************************
-#
-# Copyright (c) 2001
-# MutableRealms, Inc.
-# Huntsville, AL, USA
-#
-# All Rights Reserved
-#
-# **********************************************************************
-
-top_srcdir = ../../..
-
-CLIENT = client
-
-TARGETS = $(CLIENT)
-
-OBJS = Client.o
-
-
-SRCS = $(OBJS:.o=.cpp)
-
-include $(top_srcdir)/config/Make.rules
-
-CPPFLAGS := -I. -I../../include $(CPPFLAGS)
-
-$(CLIENT): $(OBJS)
- rm -f $@
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(BASELIBS)
-
-include .depend
+# ********************************************************************** +# +# Copyright (c) 2001 +# MutableRealms, Inc. +# Huntsville, AL, USA +# +# All Rights Reserved +# +# ********************************************************************** + +top_srcdir = ../../.. + +CLIENT = client + +TARGETS = $(CLIENT) + +OBJS = Client.o + + +SRCS = $(OBJS:.o=.cpp) + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I../../include $(CPPFLAGS) + +$(CLIENT): $(OBJS) + rm -f $@ + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(BASELIBS) + +include .depend diff --git a/cpp/test/IceXML/encoding/Client.cpp b/cpp/test/IceXML/encoding/Client.cpp index 86444e72593..9bc31fcca3b 100644 --- a/cpp/test/IceXML/encoding/Client.cpp +++ b/cpp/test/IceXML/encoding/Client.cpp @@ -39,7 +39,7 @@ TestString(const Ice::CommunicatorPtr& communicator) "hello &&''\"\"<<>>world", "" }; - for (int i = 0; !strings[i].empty(); ++i) + for(int i = 0; !strings[i].empty(); ++i) { ostringstream os; os << "<data>"; @@ -165,7 +165,7 @@ TestStruct4Seq(const Ice::CommunicatorPtr& communicator) Test::Struct4Seq seqout; Test::Struct4SeqHelper::ice_unmarshal(element, istream, seqout); test(seqout.size() == seqin.size()); - while (!seqin.empty()) + while(!seqin.empty()) { Test::Struct4 sin = seqin.back(); Test::Struct4 sout = seqout.back(); @@ -203,7 +203,7 @@ TestStringStruct4Dict(const Ice::CommunicatorPtr& communicator) Test::StringStruct4Dict dictout; Test::StringStruct4DictHelper::ice_unmarshal(element, istream, dictout); test(dictout.size() == dictin.size()); - for (Test::StringStruct4Dict::const_iterator p = dictin.begin(); p != dictin.end(); ++p) + for(Test::StringStruct4Dict::const_iterator p = dictin.begin(); p != dictin.end(); ++p) { Test::StringStruct4Dict::const_iterator q = dictout.find(p->first); test(q != dictout.end()); @@ -246,7 +246,7 @@ TestStruct3Struct4Dict(const Ice::CommunicatorPtr& communicator) Test::Struct3Struct4Dict dictout; Test::Struct3Struct4DictHelper::ice_unmarshal(element, istream, dictout); test(dictout.size() == dictin.size()); - for (Test::Struct3Struct4Dict::const_iterator p = dictin.begin(); p != dictin.end(); ++p) + for(Test::Struct3Struct4Dict::const_iterator p = dictin.begin(); p != dictin.end(); ++p) { Test::Struct3Struct4Dict::const_iterator q = dictout.find(p->first); test(q != dictout.end()); @@ -294,7 +294,7 @@ TestColorSeq(const Ice::CommunicatorPtr& communicator) Test::ColorSeq seqout; Test::ColorSeqHelper::ice_unmarshal(element, istream, seqout); test(seqout.size() == seqin.size()); - while (!seqin.empty()) + while(!seqin.empty()) { Test::Color sin = seqin.back(); Test::Color sout = seqout.back(); @@ -502,7 +502,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) // If the test is run out of the CWD then adjust the location of // Test.xsd appropriately. // - if (argc > 1) + if(argc > 1) { string dir(argv[1]); dir += '/'; @@ -580,7 +580,7 @@ main(int argc, char* argv[]) status = EXIT_FAILURE; } - if (communicator) + if(communicator) { try { diff --git a/cpp/test/include/TestCommon.h b/cpp/test/include/TestCommon.h index 745aee68fde..7a6e725559a 100644 --- a/cpp/test/include/TestCommon.h +++ b/cpp/test/include/TestCommon.h @@ -1,27 +1,27 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#ifndef TEST_COMMON_H -#define TEST_COMMON_H - -#include <IceUtil/Config.h> -#include <cstdlib> - -void -inline testFailed(const char* expr, const char* file, unsigned int line) -{ - std::cout << "failed!" << std::endl; - std::cout << file << ':' << line << ": assertion `" << expr << "' failed" << std::endl; - abort(); -} - -#define test(ex) ((ex) ? ((void)0) : testFailed(#ex, __FILE__, __LINE__)) - -#endif +// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef TEST_COMMON_H
+#define TEST_COMMON_H
+
+#include <IceUtil/Config.h>
+#include <cstdlib>
+
+void
+inline testFailed(const char* expr, const char* file, unsigned int line)
+{
+ std::cout << "failed!" << std::endl;
+ std::cout << file << ':' << line << ": assertion `" << expr << "' failed" << std::endl;
+ abort();
+}
+
+#define test(ex) ((ex) ? ((void)0) : testFailed(#ex, __FILE__, __LINE__))
+
+#endif
|