summaryrefslogtreecommitdiff
path: root/ACE/contrib/utility/Example/ExH
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/contrib/utility/Example/ExH')
-rw-r--r--ACE/contrib/utility/Example/ExH/BadCast/Makefile24
-rw-r--r--ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp54
-rw-r--r--ACE/contrib/utility/Example/ExH/Compound/Makefile24
-rw-r--r--ACE/contrib/utility/Example/ExH/Compound/compound.cpp144
-rw-r--r--ACE/contrib/utility/Example/ExH/HelloWorld/Makefile24
-rw-r--r--ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp142
-rw-r--r--ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile24
-rw-r--r--ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp60
-rw-r--r--ACE/contrib/utility/Example/ExH/Makefile16
9 files changed, 0 insertions, 512 deletions
diff --git a/ACE/contrib/utility/Example/ExH/BadCast/Makefile b/ACE/contrib/utility/Example/ExH/BadCast/Makefile
deleted file mode 100644
index 9963d9708a1..00000000000
--- a/ACE/contrib/utility/Example/ExH/BadCast/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# file : Example/ExH/BadCast/Makefile
-# author : Boris Kolpackov <boris@kolpackov.net>
-# copyright : Copyright (c) 2002-2003 Boris Kolpackov
-# license : http://kolpackov.net/license.html
-
-root := ../../..
-
-include $(root)/BuildRules/Bootstrap.rules
-
-$(call include, $(root)/BuildRules/Executable.pre.rules)
-
-
-cxx_translation_units := bad_cast.cpp
-
-module_base := bad_cast
-module_prefix :=
-module_suffix :=
-
-
-CXX_PREPROCESS_FLAGS += -I $(root)
-
-
-$(call include, $(root)/BuildRules/Executable.post.rules)
-# $Id$
diff --git a/ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp b/ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp
deleted file mode 100644
index 699add03047..00000000000
--- a/ACE/contrib/utility/Example/ExH/BadCast/bad_cast.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-// file : Example/ExH/BadCast/bad_cast.cpp
-// author : Boris Kolpackov <boris@kolpackov.net>
-// copyright : Copyright (c) 2002-2003 Boris Kolpackov
-// license : http://kolpackov.net/license.html
-
-/* FUZZ: disable check_for_improper_main_declaration */
-
-#include "Utility/ExH/System/Exception.hpp"
-
-#include <iostream>
-
-using std::cerr;
-using std::endl;
-
-
-struct A
-{
- virtual
- ~A() {}
-};
-
-struct B
-{
- void
- foo () {}
-};
-
-void
-foo ()
-{
- A a;
-
- A& ar (a);
-
- B& br (dynamic_cast<B&> (ar));
-
- br.foo ();
-}
-
-int
-main ()
-{
- try
- {
- foo ();
- }
- catch (Utility::ExH::System::Exception const& ex)
- {
- cerr << "Caught Utility::ExH::System::Exception: "
- << ex.what ()
- << endl;
- }
-}
-//$Id$
diff --git a/ACE/contrib/utility/Example/ExH/Compound/Makefile b/ACE/contrib/utility/Example/ExH/Compound/Makefile
deleted file mode 100644
index 8bd588587d5..00000000000
--- a/ACE/contrib/utility/Example/ExH/Compound/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# file : Example/ExH/Compound/Makefile
-# author : Boris Kolpackov <boris@kolpackov.net>
-# copyright : Copyright (c) 2002-2003 Boris Kolpackov
-# license : http://kolpackov.net/license.html
-
-root := ../../..
-
-include $(root)/BuildRules/Bootstrap.rules
-
-$(call include, $(root)/BuildRules/Executable.pre.rules)
-
-
-cxx_translation_units := compound.cpp
-
-module_base := compound
-module_prefix :=
-module_suffix :=
-
-
-CXX_PREPROCESS_FLAGS += -I $(root)
-
-
-$(call include, $(root)/BuildRules/Executable.post.rules)
-# $Id$
diff --git a/ACE/contrib/utility/Example/ExH/Compound/compound.cpp b/ACE/contrib/utility/Example/ExH/Compound/compound.cpp
deleted file mode 100644
index e9f585ce6d3..00000000000
--- a/ACE/contrib/utility/Example/ExH/Compound/compound.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-// file : Example/ExH/Compound/compound.cpp
-// author : Boris Kolpackov <boris@kolpackov.net>
-// copyright : Copyright (c) 2002-2003 Boris Kolpackov
-// license : http://kolpackov.net/license.html
-
-/* FUZZ: disable check_for_improper_main_declaration */
-
-#include "Utility/ExH/Compound.hpp"
-#include "Utility/ExH/System/Exception.hpp"
-#include "Utility/ExH/Logic/DescriptiveException.hpp"
-
-// Include some helper converters to allow exception initialization
-// with std::ostringstream
-
-#include "Utility/ExH/StringStreamConverter.hpp"
-
-#include <iostream>
-
-using std::cerr;
-using std::endl;
-using std::string;
-using std::ostringstream;
-
-using namespace Utility::ExH;
-
-// Here are our components
-
-class Base
-{
-public:
-
- //
- // Exception definitions.
- //
-
- // Base logic exception class for component.
- class Exception_ {};
- typedef
- Compound <Exception_, Logic::DescriptiveException>
- Exception;
-
- class InvalidArgument_ {};
- typedef
- Compound <InvalidArgument_, Exception>
- InvalidArgument;
-
- class NotInitialized_ {};
- typedef
- Compound <NotInitialized_, Exception>
- NotInitialized;
-
-public:
-
- void
- foo (char const* str)
- {
- // This is just an example.
-
- if (str == 0)
- {
- throw InvalidArgument ("Base::foo: first parameter is zero.");
- }
- else
- {
- ostringstream ostr;
- ostr << "Base::foo [this = " << this << "]: object is not initialized.";
-
- throw NotInitialized (ostr);
- }
- }
-
-
- // We don't know what implementation may decide to throw so
- // we allow to throw System exception and any logic exception
- // derived from Base::Exception
- virtual void
- vfoo () = 0;
-};
-
-class Derived : public Base
-{
-public:
-
- // Define some Derived-specific logic exception.
- class NotImplemented_ {};
- typedef
- Compound <NotImplemented_, Exception>
- NotImplemented;
-
-public:
- virtual void
- vfoo ()
- {
- std::string str ("Derived::vfoo: not implemented yet.");
- throw NotImplemented (str);
- }
-};
-
-int
-main ()
-{
- try
- {
-
- Derived d;
- Base* pb (&d);
-
- // We can use generic handler.
- try
- {
- pb->vfoo ();
- }
- catch (Base::Exception const& ex)
- {
- cerr << "Caught Base::Exception: " << ex.what () << endl;
- }
-
-
- // Or use more precise control.
- try
- {
- pb->foo ("hello");
- }
- catch (Base::NotInitialized const& ex)
- {
- cerr << "Caught Base::NotInitialized: " << ex.what () << endl;
- }
-
- // Or use application-level handler.
- pb->foo (0);
-
- }
- catch (Logic::Exception const& ex)
- {
- cerr << "Caught Logic::Exception: " << ex.what () << endl;
- }
- catch (...)
- {
- cerr << "Caught unknown exception using catch-all handler" << endl;
- return -1;
- }
-
-}
-//$Id$
diff --git a/ACE/contrib/utility/Example/ExH/HelloWorld/Makefile b/ACE/contrib/utility/Example/ExH/HelloWorld/Makefile
deleted file mode 100644
index 93debef0e7c..00000000000
--- a/ACE/contrib/utility/Example/ExH/HelloWorld/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# file : Example/ExH/HelloWorld/Makefile
-# author : Boris Kolpackov <boris@kolpackov.net>
-# copyright : Copyright (c) 2002-2003 Boris Kolpackov
-# license : http://kolpackov.net/license.html
-
-root := ../../..
-
-include $(root)/BuildRules/Bootstrap.rules
-
-$(call include, $(root)/BuildRules/Executable.pre.rules)
-
-
-cxx_translation_units := hello_world.cpp
-
-module_base := hello_world
-module_prefix :=
-module_suffix :=
-
-
-CXX_PREPROCESS_FLAGS += -I $(root)
-
-
-$(call include, $(root)/BuildRules/Executable.post.rules)
-# $Id$
diff --git a/ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp b/ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp
deleted file mode 100644
index 9499bf09fe1..00000000000
--- a/ACE/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// file : Example/ExH/HelloWorld/hello_world.cpp
-// author : Boris Kolpackov <boris@kolpackov.net>
-// copyright : Copyright (c) 2002-2003 Boris Kolpackov
-// license : http://kolpackov.net/license.html
-
-/* FUZZ: disable check_for_improper_main_declaration */
-
-#include <cstdlib> // for std::abort ()
-
-#include <string>
-#include <iostream>
-
-#include "Utility/ExH/System/Exception.hpp"
-#include "Utility/ExH/Logic/Exception.hpp"
-
-using std::cerr;
-using std::cout;
-using std::endl;
-
-using namespace Utility;
-
-class Application
-{
-public:
- class Exception : public ExH::Logic::Exception {};
-
- // Hint: you may want to try again...
- class FeelingDizzy : public Exception {};
-
- class InvalidArg : public Exception {};
-
-public:
- Application ()
- : // The std::string c-tor may throw any kind of exceptions besides
- // quite possible std::bad_alloc.
- greeting_ ("Hello, world!")
- {
- }
-
- Application (char const * greeting)
- : greeting_ (greeting == 0 ? "" : greeting)
- {
- if (greeting == 0) throw InvalidArg ();
- }
-
-public:
-
- void
- run ()
- {
- static unsigned int dizzy_count (0);
-
- if (dizzy_count++ < 5) throw FeelingDizzy ();
-
- // The next line can throw full bucket of exceptions
- // not to mention ios_base::failure.
- cout << greeting_.c_str () << endl;
- }
-
-private:
-
- std::string greeting_;
-};
-
-
-
-int
-main ()
-{
- // This is a catch-all layer that should be in use only
- // if we are really in trouble.
- try
- {
- // This is a catch-system layer. Here we will catch exceptions like
- // bad_alloc, etc. If we get here it means that nobody wanted/managed
- // to recover from this kind of errors.
- try
- {
- // This is a catch-logic layer. If we get here it usually
- // indicates an application logic error.
- try
- {
-
- // Ok, here we go about our application logic.
- try
- {
- for (int i = 0; i < 10; i++)
- {
- try
- {
- Application app ("Hi dude!");
- app.run ();
- break;
- }
- catch (Application::FeelingDizzy const& )
- {
- if (i == 9)
- {
- cerr << "Given up!" << endl;
- return -1;
- }
- else
- {
- cerr << "Application is feeling dizzy. Trying again..."
- << endl;
- }
- }
- }
- }
- catch (Application::InvalidArg const& )
- {
- cerr << "Cought Application::InvalidArg : ...hmm... strange!"
- << endl;
- return -1;
- }
- }
- catch (ExH::Logic::Exception const& e)
- {
- cerr << "Caught Logic::Exception : " << e.what () << endl;
- return -1;
- }
- }
- catch (const ExH::System::Exception& e)
- {
- cerr << "Caught System::Exception : " << e.what () << endl;
- return -1;
- }
- catch (...)
- {
- cerr << "Caught unknown exception using catch-all handler. " << endl;
- return -1;
- }
- }
- catch (...)
- {
- // We get here in cases of some hard failure. For example when handling
- // exception, operator << throws another exception. Usually application
- // cannot handle such failures itself so we just propagate it futher.
- std::abort ();
- }
-}
-//$Id$
diff --git a/ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile b/ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile
deleted file mode 100644
index 789413c0a3c..00000000000
--- a/ACE/contrib/utility/Example/ExH/LogicToSystem/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# file : Example/ExH/LogicToSystem/Makefile
-# author : Boris Kolpackov <boris@kolpackov.net>
-# copyright : Copyright (c) 2002-2003 Boris Kolpackov
-# license : http://kolpackov.net/license.html
-
-root := ../../..
-
-include $(root)/BuildRules/Bootstrap.rules
-
-$(call include, $(root)/BuildRules/Executable.pre.rules)
-
-
-cxx_translation_units := logic_to_system.cpp
-
-module_base := logic_to_system
-module_prefix :=
-module_suffix :=
-
-
-CXX_PREPROCESS_FLAGS += -I $(root)
-
-
-$(call include, $(root)/BuildRules/Executable.post.rules)
-# $Id$
diff --git a/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp b/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
deleted file mode 100644
index 6f718e9c694..00000000000
--- a/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// file : Example/ExH/LogicToSystem/logic_to_system.cpp
-// author : Boris Kolpackov <boris@kolpackov.net>
-// copyright : Copyright (c) 2002-2003 Boris Kolpackov
-// license : http://kolpackov.net/license.html
-
-/* FUZZ: disable check_for_improper_main_declaration */
-
-#include "Utility/ExH/System/Exception.hpp"
-#include "Utility/ExH/Logic/Exception.hpp"
-
-#include <iostream>
-
-using std::cerr;
-using std::endl;
-
-
-struct SubsystemA
-{
- class Exception : public Utility::ExH::Logic::Exception {};
-
- void
- foo ()
- {
- throw Exception ();
- }
-};
-
-
-struct SubsystemB
-{
- void
- foo ()
- {
- SubsystemA a;
- a.foo ();
-
- // Here SubsystemB is using SunsystemA but cannot (forgot, doesnt't
- // want to, doesn't know how to, etc - pick your favorite) handle
- // exception thrown by SubsystemA. As a result exception is
- // 'converted' to System::Exception.
- }
-};
-
-
-int
-main ()
-{
- try
- {
- SubsystemB b;
- b.foo ();
- }
- catch (Utility::ExH::System::Exception const& ex)
- {
- cerr << "Caught Utility::ExH::System::Exception: "
- << ex.what ()
- << endl;
- }
-}
-//$Id$
diff --git a/ACE/contrib/utility/Example/ExH/Makefile b/ACE/contrib/utility/Example/ExH/Makefile
deleted file mode 100644
index 99eb95cf62f..00000000000
--- a/ACE/contrib/utility/Example/ExH/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# file : Example/ExH/Makefile
-# author : Boris Kolpackov <boris@kolpackov.net>
-# copyright : Copyright (c) 2002-2003 Boris Kolpackov
-# license : http://kolpackov.net/license.html
-
-root := ../..
-
-include $(root)/BuildRules/Bootstrap.rules
-
-$(call include, $(root)/BuildRules/Recursion.pre.rules)
-
-target_makefile_list :=
-target_directory_list := BadCast Compound HelloWorld LogicToSystem
-
-$(call include, $(root)/BuildRules/Recursion.post.rules)
-# $Id$