summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorturkaye <turkaye@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-05-24 04:33:13 +0000
committerturkaye <turkaye@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-05-24 04:33:13 +0000
commit711701c42d16c84440b025ef6488785cbbe0036b (patch)
treeec9195a1c672c4fe1c1c4ad9d991fb3428b50907
parentc7ce0f6c2430cb6dcec63c01e4aa68f2516a7ba9 (diff)
downloadATCD-711701c42d16c84440b025ef6488785cbbe0036b.tar.gz
ChangeLogTag: Mon May 23 23:11:14 2005 Emre Turkay <turkaye@dre.vanderbilt.edu>
-rw-r--r--ChangeLog6
-rw-r--r--contrib/utility/BuildRules/Archive.gcc.post.rules47
-rw-r--r--contrib/utility/BuildRules/Archive.gcc.pre.rules28
-rw-r--r--contrib/utility/BuildRules/Archive.post.rules7
-rw-r--r--contrib/utility/BuildRules/Archive.pre.rules7
-rw-r--r--contrib/utility/BuildRules/Bootstrap.rules95
-rw-r--r--contrib/utility/BuildRules/Documentation.post.rules35
-rw-r--r--contrib/utility/BuildRules/Documentation.pre.rules18
-rw-r--r--contrib/utility/BuildRules/Executable.gcc.post.rules46
-rw-r--r--contrib/utility/BuildRules/Executable.gcc.pre.rules26
-rw-r--r--contrib/utility/BuildRules/Executable.generic.post.rules55
-rw-r--r--contrib/utility/BuildRules/Executable.generic.pre.rules26
-rw-r--r--contrib/utility/BuildRules/Executable.post.rules8
-rw-r--r--contrib/utility/BuildRules/Executable.pre.rules8
-rw-r--r--contrib/utility/BuildRules/Object.gcc.post.rules38
-rw-r--r--contrib/utility/BuildRules/Object.gcc.pre.rules22
-rw-r--r--contrib/utility/BuildRules/Object.post.rules7
-rw-r--r--contrib/utility/BuildRules/Object.pre.rules7
-rw-r--r--contrib/utility/BuildRules/Recursion.post.rules37
-rw-r--r--contrib/utility/BuildRules/Recursion.pre.rules13
-rw-r--r--contrib/utility/BuildRules/Shared.gcc.post.rules43
-rw-r--r--contrib/utility/BuildRules/Shared.gcc.pre.rules26
-rw-r--r--contrib/utility/BuildRules/Shared.generic.post.rules51
-rw-r--r--contrib/utility/BuildRules/Shared.generic.pre.rules26
-rw-r--r--contrib/utility/BuildRules/Shared.post.rules7
-rw-r--r--contrib/utility/BuildRules/Shared.pre.rules7
-rw-r--r--contrib/utility/BuildRules/Thoughts55
-rw-r--r--contrib/utility/Documentation/Build.xhtml58
-rw-r--r--contrib/utility/Documentation/CommandLine/News.xhtml31
-rw-r--r--contrib/utility/Documentation/CommandLine/Terminology.xhtml272
-rw-r--r--contrib/utility/Documentation/CommandLine/Thoughts8
-rw-r--r--contrib/utility/Documentation/CommandLine/index.xhtml39
-rw-r--r--contrib/utility/Documentation/ExH/Compound.hpp.html50
-rw-r--r--contrib/utility/Documentation/ExH/Example/Makefile26
-rw-r--r--contrib/utility/Documentation/ExH/Example/bad_cast.cpp.html63
-rw-r--r--contrib/utility/Documentation/ExH/Example/compound.cpp.html153
-rw-r--r--contrib/utility/Documentation/ExH/Example/hello_world.cpp.html152
-rw-r--r--contrib/utility/Documentation/ExH/Example/logic_to_system.cpp.html69
-rw-r--r--contrib/utility/Documentation/ExH/Logic/DescriptiveException.hpp.html61
-rw-r--r--contrib/utility/Documentation/ExH/Logic/Exception.hpp.html43
-rw-r--r--contrib/utility/Documentation/ExH/Logic/Makefile20
-rw-r--r--contrib/utility/Documentation/ExH/Makefile16
-rw-r--r--contrib/utility/Documentation/ExH/Makefile.documentation20
-rw-r--r--contrib/utility/Documentation/ExH/News.xhtml47
-rw-r--r--contrib/utility/Documentation/ExH/System/DescriptiveException.hpp.html64
-rw-r--r--contrib/utility/Documentation/ExH/System/Exception.hpp.html32
-rw-r--r--contrib/utility/Documentation/ExH/System/Makefile20
-rw-r--r--contrib/utility/Documentation/ExH/index.xhtml60
-rw-r--r--contrib/utility/Documentation/Hetero/News.xhtml31
-rw-r--r--contrib/utility/Documentation/Hetero/index.xhtml62
-rw-r--r--contrib/utility/Documentation/Introspection/News.xhtml38
-rw-r--r--contrib/utility/Documentation/Introspection/index.xhtml42
-rw-r--r--contrib/utility/Documentation/Makefile16
-rw-r--r--contrib/utility/Documentation/News.xhtml72
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/DefaultImpl.hpp.html93
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/Interface.hpp.html82
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/Makefile22
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/News.xhtml90
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/SmartPtr.hpp.html103
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/StrictPtr.hpp.html107
-rw-r--r--contrib/utility/Documentation/ReferenceCounting/index.xhtml50
-rw-r--r--contrib/utility/Documentation/ReleaseProcess13
-rw-r--r--contrib/utility/Documentation/Style/CXX.css9
-rw-r--r--contrib/utility/Documentation/Style/CXX_Blue.css25
-rw-r--r--contrib/utility/Documentation/Style/Default.css45
-rw-r--r--contrib/utility/Documentation/Synch/Makefile16
-rw-r--r--contrib/utility/Documentation/Synch/News.xhtml36
-rw-r--r--contrib/utility/Documentation/Synch/Policy/Makefile20
-rw-r--r--contrib/utility/Documentation/Synch/Policy/Null.hpp.html59
-rw-r--r--contrib/utility/Documentation/Synch/index.xhtml48
-rw-r--r--contrib/utility/Documentation/TODO53
-rw-r--r--contrib/utility/Documentation/Template.xhtml33
-rw-r--r--contrib/utility/Documentation/Thoughts/Enum/EnumCount95
-rw-r--r--contrib/utility/Documentation/Thoughts/Enum/EnumCount217
-rw-r--r--contrib/utility/Documentation/Thoughts/Enum/EnumInfo45
-rw-r--r--contrib/utility/Documentation/index.xhtml81
-rw-r--r--contrib/utility/Example/CommandLine/Foo/command.cpp86
-rw-r--r--contrib/utility/Example/CommandLine/Foo/foo.cpp183
-rw-r--r--contrib/utility/Example/ExH/BadCast/Makefile24
-rw-r--r--contrib/utility/Example/ExH/BadCast/bad_cast.cpp52
-rw-r--r--contrib/utility/Example/ExH/Compound/Makefile24
-rw-r--r--contrib/utility/Example/ExH/Compound/compound.cpp142
-rw-r--r--contrib/utility/Example/ExH/HelloWorld/Makefile24
-rw-r--r--contrib/utility/Example/ExH/HelloWorld/hello_world.cpp141
-rw-r--r--contrib/utility/Example/ExH/LogicToSystem/Makefile24
-rw-r--r--contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp58
-rw-r--r--contrib/utility/Example/ExH/Makefile16
-rw-r--r--contrib/utility/Example/Hetero/Container/Makefile24
-rw-r--r--contrib/utility/Example/Hetero/Container/container.cpp110
-rw-r--r--contrib/utility/Example/Hetero/Makefile16
-rw-r--r--contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp104
-rw-r--r--contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp61
-rw-r--r--contrib/utility/Example/Introspection/InheritanceTree/Makefile22
-rw-r--r--contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp64
-rw-r--r--contrib/utility/Example/Introspection/Makefile16
-rw-r--r--contrib/utility/Example/Introspection/Traversal/Makefile22
-rw-r--r--contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp119
-rw-r--r--contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp95
-rw-r--r--contrib/utility/Example/Introspection/Traversal/Traversal.cpp105
-rw-r--r--contrib/utility/Example/Introspection/Traversal/Traversal.hpp157
-rw-r--r--contrib/utility/Example/Introspection/Traversal/driver.cpp91
-rw-r--r--contrib/utility/Example/Makefile16
-rw-r--r--contrib/utility/Makefile18
-rw-r--r--contrib/utility/Test/ExH/Compound/Makefile24
-rw-r--r--contrib/utility/Test/ExH/Compound/compound.cpp115
-rw-r--r--contrib/utility/Test/ExH/Converter/Makefile24
-rw-r--r--contrib/utility/Test/ExH/Converter/converter.cpp48
-rw-r--r--contrib/utility/Test/ExH/Inline/Makefile24
-rw-r--r--contrib/utility/Test/ExH/Inline/inline.cpp18
-rw-r--r--contrib/utility/Test/ExH/Inline/unit.cpp8
-rw-r--r--contrib/utility/Test/ExH/Logic/DescriptiveException/Makefile24
-rw-r--r--contrib/utility/Test/ExH/Logic/DescriptiveException/descriptive_exception.cpp108
-rw-r--r--contrib/utility/Test/ExH/Logic/Makefile16
-rw-r--r--contrib/utility/Test/ExH/Makefile16
-rw-r--r--contrib/utility/Test/ExH/System/DescriptiveException/Makefile24
-rw-r--r--contrib/utility/Test/ExH/System/DescriptiveException/descriptive_exception.cpp107
-rw-r--r--contrib/utility/Test/ExH/System/Makefile16
-rw-r--r--contrib/utility/Test/Introspection/Inline/Makefile24
-rw-r--r--contrib/utility/Test/Introspection/Inline/inline.cpp18
-rw-r--r--contrib/utility/Test/Introspection/Inline/unit.cpp8
-rw-r--r--contrib/utility/Test/Introspection/Makefile16
-rw-r--r--contrib/utility/Test/Makefile18
-rw-r--r--contrib/utility/Test/ReferenceCounting/DefaultImpl/Makefile24
-rw-r--r--contrib/utility/Test/ReferenceCounting/DefaultImpl/default_impl.cpp132
-rw-r--r--contrib/utility/Test/ReferenceCounting/Inline/Makefile24
-rw-r--r--contrib/utility/Test/ReferenceCounting/Inline/inline.cpp16
-rw-r--r--contrib/utility/Test/ReferenceCounting/Inline/unit.cpp8
-rw-r--r--contrib/utility/Test/ReferenceCounting/Interface/Makefile24
-rw-r--r--contrib/utility/Test/ReferenceCounting/Interface/interface.cpp104
-rw-r--r--contrib/utility/Test/ReferenceCounting/Makefile16
-rw-r--r--contrib/utility/Test/ReferenceCounting/SmartPtr/Makefile24
-rw-r--r--contrib/utility/Test/ReferenceCounting/SmartPtr/smart_ptr.cpp220
-rw-r--r--contrib/utility/Test/ReferenceCounting/StrictPtr/Makefile24
-rw-r--r--contrib/utility/Test/ReferenceCounting/StrictPtr/strict_ptr.cpp218
-rw-r--r--contrib/utility/Test/Synch/Inline/Makefile24
-rw-r--r--contrib/utility/Test/Synch/Inline/inline.cpp18
-rw-r--r--contrib/utility/Test/Synch/Inline/unit.cpp8
-rw-r--r--contrib/utility/Test/Synch/Makefile16
-rw-r--r--contrib/utility/Utility/ExH/Compound.hpp47
-rw-r--r--contrib/utility/Utility/ExH/Compound.tpp71
-rw-r--r--contrib/utility/Utility/ExH/Converter.hpp24
-rw-r--r--contrib/utility/Utility/ExH/Converter.tpp19
-rw-r--r--contrib/utility/Utility/ExH/ExH.hpp22
-rw-r--r--contrib/utility/Utility/ExH/Logic/DescriptiveException.hpp63
-rw-r--r--contrib/utility/Utility/ExH/Logic/DescriptiveException.ipp104
-rw-r--r--contrib/utility/Utility/ExH/Logic/DescriptiveException.tpp23
-rw-r--r--contrib/utility/Utility/ExH/Logic/Exception.hpp40
-rw-r--r--contrib/utility/Utility/ExH/Logic/Exception.ipp20
-rw-r--r--contrib/utility/Utility/ExH/StringStreamConverter.hpp26
-rw-r--r--contrib/utility/Utility/ExH/StringStreamConverter.ipp18
-rw-r--r--contrib/utility/Utility/ExH/System/DescriptiveException.hpp63
-rw-r--r--contrib/utility/Utility/ExH/System/DescriptiveException.ipp90
-rw-r--r--contrib/utility/Utility/ExH/System/DescriptiveException.tpp23
-rw-r--r--contrib/utility/Utility/ExH/System/Exception.hpp29
-rw-r--r--contrib/utility/Utility/Hetero/Container.hpp182
-rw-r--r--contrib/utility/Utility/Hetero/Shell.hpp86
-rw-r--r--contrib/utility/Utility/Hetero/TypeList.hpp46
-rw-r--r--contrib/utility/Utility/Hetero/TypedContainer.hpp57
-rw-r--r--contrib/utility/Utility/Hetero/Vector.hpp47
-rw-r--r--contrib/utility/Utility/Introspection/Introspection.hpp14
-rw-r--r--contrib/utility/Utility/Introspection/Makefile19
-rw-r--r--contrib/utility/Utility/Introspection/Object.cpp24
-rw-r--r--contrib/utility/Utility/Introspection/Object.hpp47
-rw-r--r--contrib/utility/Utility/Introspection/Object.ipp48
-rw-r--r--contrib/utility/Utility/Introspection/TypeId.cpp21
-rw-r--r--contrib/utility/Utility/Introspection/TypeId.hpp47
-rw-r--r--contrib/utility/Utility/Introspection/TypeId.ipp37
-rw-r--r--contrib/utility/Utility/Introspection/TypeId.tpp18
-rw-r--r--contrib/utility/Utility/Introspection/TypeInfo.hpp104
-rw-r--r--contrib/utility/Utility/Introspection/TypeInfo.ipp77
-rw-r--r--contrib/utility/Utility/Makefile16
-rw-r--r--contrib/utility/Utility/ReferenceCounting/DefaultImpl.hpp96
-rw-r--r--contrib/utility/Utility/ReferenceCounting/DefaultImpl.ipp105
-rw-r--r--contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.hpp60
-rw-r--r--contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.ipp122
-rw-r--r--contrib/utility/Utility/ReferenceCounting/Interface.hpp84
-rw-r--r--contrib/utility/Utility/ReferenceCounting/Interface.ipp22
-rw-r--r--contrib/utility/Utility/ReferenceCounting/Interface.tpp20
-rw-r--r--contrib/utility/Utility/ReferenceCounting/ReferenceCounting.hpp16
-rw-r--r--contrib/utility/Utility/ReferenceCounting/SmartPtr.hpp103
-rw-r--r--contrib/utility/Utility/ReferenceCounting/SmartPtr.tpp170
-rw-r--r--contrib/utility/Utility/ReferenceCounting/StrictPtr.hpp108
-rw-r--r--contrib/utility/Utility/ReferenceCounting/StrictPtr.tpp167
-rw-r--r--contrib/utility/Utility/Synch/Policy/Null.hpp54
-rw-r--r--contrib/utility/Utility/Synch/Policy/Null.ipp20
-rw-r--r--contrib/utility/Vault/StringConverter.hpp27
-rw-r--r--contrib/utility/Vault/StringConverter.ipp18
-rw-r--r--contrib/utility/Vault/hetero/map13
-rw-r--r--contrib/utility/Vault/hetero/map.hpp249
-rw-r--r--contrib/utility/Vault/hetero/map.tpp12
-rw-r--r--contrib/utility/Version3
-rw-r--r--contrib/utility/license.html79
192 files changed, 9948 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index bfe21d21780..56c85f5a0f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon May 23 23:11:14 2005 Emre Turkay <turkaye@dre.vanderbilt.edu>
+
+ * contrib/utility/*:
+
+ Added the utility library.
+
Mon May 23 16:38:13 2005 Steve Huston <shuston@riverace.com>
* examples/Reactor/Proactor/post_completions.cpp: Made use of the
diff --git a/contrib/utility/BuildRules/Archive.gcc.post.rules b/contrib/utility/BuildRules/Archive.gcc.post.rules
new file mode 100644
index 00000000000..11b052d5200
--- /dev/null
+++ b/contrib/utility/BuildRules/Archive.gcc.post.rules
@@ -0,0 +1,47 @@
+# file : BuildRules/Archive.gcc.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+FULL_MODULE_PREFIX := $(MODULE_PREFIX)$(module_prefix)
+FULL_MODULE_SUFFIX := $(module_suffix)$(MODULE_SUFFIX)
+MODULE := $(FULL_MODULE_PREFIX)$(module_base)$(FULL_MODULE_SUFFIX)
+
+#
+# Pattern rules catalog.
+# {
+
+# Defined pattern rule to build .o from .cpp
+%.o : %.cpp
+ $(CXX) $(CXX_PREPROCESS_FLAGS) $(CXX_COMPILE_FLAGS) -MD -MP -MT $(@:.o=.d) -MF $(@:.o=.d) -c $< -o $@
+
+# }
+
+# Defines the rule to build module from tarnslated c++ translation units.
+$(MODULE) : $(cxx_translation_units:.cpp=.o) $(translated_units)
+ $(AR) $(AR_FLAGS) $@ $^
+
+# Defines a phony target to clean all what's been generated
+.PHONY : clean
+clean :
+ -rm -f $(cxx_translation_units:.cpp=.o)
+ -rm -f $(cxx_translation_units:.cpp=.d)
+ -rm -f $(MODULE)
+
+
+# Include dependencies for c++ translation units.
+# @@ empty-check should be done in all cases.
+##
+ifneq ($(strip $(cxx_translation_units)),)
+-include $(cxx_translation_units:.cpp=.d)
+endif
+
+
+# The following catch-all rule will skip unknown targets
+%:: ;@:
+# $Id$
diff --git a/contrib/utility/BuildRules/Archive.gcc.pre.rules b/contrib/utility/BuildRules/Archive.gcc.pre.rules
new file mode 100644
index 00000000000..fbeb0329055
--- /dev/null
+++ b/contrib/utility/BuildRules/Archive.gcc.pre.rules
@@ -0,0 +1,28 @@
+# file : BuildRules/Archive.gcc.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+CXX ?= g++
+CXX_DEP ?= $(CXX) -M
+
+CXX_PREPROCESS_FLAGS :=
+CXX_COMPILE_FLAGS := -Wall
+CXX_LINK_FLAGS :=
+CXX_LINK_LIBS :=
+
+AR ?= ar
+AR_FLAGS := -rc
+
+MODULE_PREFIX := lib
+MODULE_SUFFIX := .a
+# $Id$
diff --git a/contrib/utility/BuildRules/Archive.post.rules b/contrib/utility/BuildRules/Archive.post.rules
new file mode 100644
index 00000000000..ffd1dc833f0
--- /dev/null
+++ b/contrib/utility/BuildRules/Archive.post.rules
@@ -0,0 +1,7 @@
+# file : BuildRules/Archive.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Archive.gcc.post.rules)
+# $Id$
diff --git a/contrib/utility/BuildRules/Archive.pre.rules b/contrib/utility/BuildRules/Archive.pre.rules
new file mode 100644
index 00000000000..7547d7176f6
--- /dev/null
+++ b/contrib/utility/BuildRules/Archive.pre.rules
@@ -0,0 +1,7 @@
+# file : BuildRules/Archive.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Archive.gcc.pre.rules)
+# $Id$
diff --git a/contrib/utility/BuildRules/Bootstrap.rules b/contrib/utility/BuildRules/Bootstrap.rules
new file mode 100644
index 00000000000..32d28e12038
--- /dev/null
+++ b/contrib/utility/BuildRules/Bootstrap.rules
@@ -0,0 +1,95 @@
+# file : BuildRules/Bootstrap.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# basics
+#
+#
+
+define set
+$(eval $1 := $(strip $2))
+endef
+
+define get
+$(value $(strip $1))
+endef
+
+define sub
+$(shell expr $1 - $2)
+endef
+
+define add
+$(shell expr $1 + $2)
+endef
+
+# stack
+#
+#
+
+define push
+$(eval $1 +=$(strip $2))
+endef
+
+define pop
+$(eval $1 :=$(wordlist 1,$(call sub, $(words $(value $(strip $1))), 1),$(value $(strip $1))))
+endef
+
+define top
+$(word $(words $(value $(strip $1))),$(value $(strip $1)))
+endef
+
+# local
+#
+#
+
+define path_to_id
+$(subst /,_,$(subst .,_,$(strip $1)))
+endef
+
+MAKEFILE := $(word $(call sub,$(words $(MAKEFILE_LIST)),1),$(MAKEFILE_LIST))
+INCLUSION_ID := $(call path_to_id,$(MAKEFILE))
+
+define get_inclusion_id
+$(INCLUSION_ID)
+endef
+
+define local_set
+$(eval $(strip $(call get_inclusion_id))_$1 := $(strip $2))
+endef
+
+define local_get
+$($(strip $(call get_inclusion_id))_$1)
+endef
+
+define local_origin
+$(origin $(strip $(call get_inclusion_id))_$1)
+endef
+
+
+define _get_inclusion_count
+$(if $(call local_get,INCLUSION_COUNT),$(call local_get,INCLUSION_COUNT),0)
+endef
+
+define _set_inclusion_count
+$(call local_set,INCLUSION_COUNT,$1)
+endef
+
+# include
+#
+#
+
+define include
+$(strip
+ $(eval $(call push, include_stack, $(MAKEFILE))) \
+ $(eval MAKEFILE :=$(strip $1)) \
+ $(eval $(call push, inclusion_id_stack, $(INCLUSION_ID))) \
+ $(eval $(call _set_inclusion_count,$(call add,$(call _get_inclusion_count),1))) \
+ $(eval INCLUSION_ID :=$(INCLUSION_ID)_$(call local_get,INCLUSION_COUNT)_$(call path_to_id,$1)) \
+ $(eval include $1) \
+ $(eval INCLUSION_ID :=$(call top, inclusion_id_stack)) \
+ $(eval $(call pop, inclusion_id_stack)) \
+ $(eval MAKEFILE :=$(call top, include_stack)) \
+ $(eval $(call pop, include_stack)))
+endef
+# $Id$
diff --git a/contrib/utility/BuildRules/Documentation.post.rules b/contrib/utility/BuildRules/Documentation.post.rules
new file mode 100644
index 00000000000..33fd0c2942f
--- /dev/null
+++ b/contrib/utility/BuildRules/Documentation.post.rules
@@ -0,0 +1,35 @@
+# file : BuildRules/Documentation.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+#
+# Pattern rules catalog.
+# {
+
+# Defined pattern rule to build .hpp.html from .hpp
+%.html : %
+ $(DOC) $(DOC_FLAGS) -o $@ $<
+
+# }
+
+# The following rule will inhibit treatment of documentation as
+# default target.
+.PHONY : all
+all: ;@:
+
+.PHONY : documentation
+documentation : $(patsubst %,%.html,$(doc_translation_units))
+
+# Defines a phony target to clean all what's been generated
+.PHONY : clean
+clean :
+ -rm -f $(patsubst %,%.html,$(doc_translation_units))
+
+# The following catch-all rule will skip unknown targets
+%:: ;@:
+# $Id$
diff --git a/contrib/utility/BuildRules/Documentation.pre.rules b/contrib/utility/BuildRules/Documentation.pre.rules
new file mode 100644
index 00000000000..33161d03d40
--- /dev/null
+++ b/contrib/utility/BuildRules/Documentation.pre.rules
@@ -0,0 +1,18 @@
+# file : BuildRules/Documentation.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+DOC ?= cpp_to_html
+CXX_FLAGS :=
+
+# $Id$
diff --git a/contrib/utility/BuildRules/Executable.gcc.post.rules b/contrib/utility/BuildRules/Executable.gcc.post.rules
new file mode 100644
index 00000000000..6587cbf0757
--- /dev/null
+++ b/contrib/utility/BuildRules/Executable.gcc.post.rules
@@ -0,0 +1,46 @@
+# file : BuildRules/Executable.gcc.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+FULL_MODULE_PREFIX := $(MODULE_PREFIX)$(module_prefix)
+FULL_MODULE_SUFFIX := $(module_suffix)$(MODULE_SUFFIX)
+MODULE := $(FULL_MODULE_PREFIX)$(module_base)$(FULL_MODULE_SUFFIX)
+
+#
+# Pattern rules catalog.
+# {
+
+# Defined pattern rule to build .o from .cpp
+%.o : %.cpp
+ $(CXX) $(CXX_PREPROCESS_FLAGS) $(CXX_COMPILE_FLAGS) -MD -MP -MT $(@:.o=.d) -MF $(@:.o=.d) -c $< -o $@
+
+# }
+
+# Defines the rule to build module from tarnslated c++ translation units.
+$(MODULE) : $(cxx_translation_units:.cpp=.o) $(translated_units)
+ $(CXX) $(CXX_LINK_FLAGS) -o $@ $^ $(CXX_LINK_LIBS)
+
+# Defines a phony target to clean all what's been generated
+.PHONY : clean
+clean :
+ -rm -f $(cxx_translation_units:.cpp=.o)
+ -rm -f $(cxx_translation_units:.cpp=.d)
+ -rm -f $(MODULE)
+
+
+# Define a phony target to invoke the test driver.
+.PHONY : test
+test : $(MODULE)
+ ./$(MODULE)
+
+# Include dependencies for c++ translation units.
+-include $(cxx_translation_units:.cpp=.d)
+
+# The following catch-all rule will skip unknown targets
+%:: ;@:
+# $Id$
diff --git a/contrib/utility/BuildRules/Executable.gcc.pre.rules b/contrib/utility/BuildRules/Executable.gcc.pre.rules
new file mode 100644
index 00000000000..f7a0798c824
--- /dev/null
+++ b/contrib/utility/BuildRules/Executable.gcc.pre.rules
@@ -0,0 +1,26 @@
+# file : BuildRules/Executable.gcc.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+CXX ?= g++
+
+CXX_PREPROCESS_FLAGS :=
+CXX_COMPILE_FLAGS := -Wall
+CXX_LINK_FLAGS :=
+CXX_LINK_LIBS :=
+
+
+MODULE_PREFIX :=
+MODULE_SUFFIX :=
+
+# $Id$
diff --git a/contrib/utility/BuildRules/Executable.generic.post.rules b/contrib/utility/BuildRules/Executable.generic.post.rules
new file mode 100644
index 00000000000..26fa9b3b515
--- /dev/null
+++ b/contrib/utility/BuildRules/Executable.generic.post.rules
@@ -0,0 +1,55 @@
+# file : BuildRules/Executable.generic.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+FULL_MODULE_PREFIX := $(MODULE_PREFIX)$(module_prefix)
+FULL_MODULE_SUFFIX := $(module_suffix)$(MODULE_SUFFIX)
+MODULE := $(FULL_MODULE_PREFIX)$(module_base)$(FULL_MODULE_SUFFIX)
+
+#
+# Pattern rules catalog.
+# {
+
+# Defines pattern rule to build .d from .cpp
+%.d: %.cpp
+ set -e; $(CXX_DEP) $(CXX_PREPROCESS_FLAGS) $< \
+ | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+
+# Defined pattern rule to build .o from .cpp
+%.o : %.cpp
+ $(CXX) $(CXX_PREPROCESS_FLAGS) $(CXX_COMPILE_FLAGS) -c $< -o $@
+
+# }
+
+# Defines the rule to build module from tarnslated c++ translation units.
+$(MODULE) : $(cxx_translation_units:.cpp=.o)
+ $(CXX) $(CXX_LINK_FLAGS) -o $@ $^ $(CXX_LINK_LIBS)
+
+# Defines a phony target to clean all what's been generated
+.PHONY : clean
+clean :
+ -rm -f $(cxx_translation_units:.cpp=.o)
+ -rm -f $(cxx_translation_units:.cpp=.d)
+ -rm -f $(MODULE)
+
+
+# Define a phony target to invoke the test driver.
+.PHONY : test
+test : $(MODULE)
+ ./$(MODULE)
+
+# Include dependencies for c++ translation units.
+# Optimization: if we are cleaning there is no reason to calculate
+# dependencies because they will be removed a second later.
+ifneq ($(MAKECMDGOALS),clean)
+ include $(cxx_translation_units:.cpp=.d)
+endif
+# $Id$
diff --git a/contrib/utility/BuildRules/Executable.generic.pre.rules b/contrib/utility/BuildRules/Executable.generic.pre.rules
new file mode 100644
index 00000000000..995dabeebda
--- /dev/null
+++ b/contrib/utility/BuildRules/Executable.generic.pre.rules
@@ -0,0 +1,26 @@
+# file : BuildRules/Executable.generic.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+CXX ?= g++
+CXX_DEP ?= $(CXX) -M
+
+CXX_PREPROCESS_FLAGS :=
+CXX_COMPILE_FLAGS := -Wall
+CXX_LINK_FLAGS :=
+CXX_LINK_LIBS :=
+
+
+MODULE_PREFIX :=
+MODULE_SUFFIX :=
+# $Id$
diff --git a/contrib/utility/BuildRules/Executable.post.rules b/contrib/utility/BuildRules/Executable.post.rules
new file mode 100644
index 00000000000..da146baf162
--- /dev/null
+++ b/contrib/utility/BuildRules/Executable.post.rules
@@ -0,0 +1,8 @@
+# file : BuildRules/Executable.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Executable.gcc.post.rules)
+
+# $Id$
diff --git a/contrib/utility/BuildRules/Executable.pre.rules b/contrib/utility/BuildRules/Executable.pre.rules
new file mode 100644
index 00000000000..10a1796450b
--- /dev/null
+++ b/contrib/utility/BuildRules/Executable.pre.rules
@@ -0,0 +1,8 @@
+# file : BuildRules/Executable.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Executable.gcc.pre.rules)
+
+# $Id$
diff --git a/contrib/utility/BuildRules/Object.gcc.post.rules b/contrib/utility/BuildRules/Object.gcc.post.rules
new file mode 100644
index 00000000000..a58c2369435
--- /dev/null
+++ b/contrib/utility/BuildRules/Object.gcc.post.rules
@@ -0,0 +1,38 @@
+# file : BuildRules/Object.gcc.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+#
+# Pattern rules catalog.
+# {
+
+# Defined pattern rule to build .o from .cpp
+%.o : %.cpp
+ $(CXX) $(CXX_PREPROCESS_FLAGS) $(CXX_COMPILE_FLAGS) -MD -MP -MT $(@:.o=.d) -MF $(@:.o=.d) -c $< -o $@
+
+# }
+
+# Defines the rule to build object files from c++ translation units.
+.PHONY : object
+object : $(cxx_translation_units:.cpp=.o)
+
+# Defines a phony target to clean all that's been generated
+.PHONY : clean
+clean :
+ -rm -f $(cxx_translation_units:.cpp=.o)
+ -rm -f $(cxx_translation_units:.cpp=.d)
+
+
+# Include dependencies for c++ translation units.
+-include $(cxx_translation_units:.cpp=.d)
+
+
+# The following catch-all rule will skip unknown targets
+%:: ;@:
+# $Id$
diff --git a/contrib/utility/BuildRules/Object.gcc.pre.rules b/contrib/utility/BuildRules/Object.gcc.pre.rules
new file mode 100644
index 00000000000..8b8d5527abd
--- /dev/null
+++ b/contrib/utility/BuildRules/Object.gcc.pre.rules
@@ -0,0 +1,22 @@
+# file : BuildRules/Object.gcc.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+CXX ?= g++
+CXX_DEP ?= $(CXX) -M
+
+CXX_PREPROCESS_FLAGS :=
+CXX_COMPILE_FLAGS := -Wall
+CXX_LINK_FLAGS :=
+CXX_LINK_LIBS :=
+# $Id$
diff --git a/contrib/utility/BuildRules/Object.post.rules b/contrib/utility/BuildRules/Object.post.rules
new file mode 100644
index 00000000000..383f759a25a
--- /dev/null
+++ b/contrib/utility/BuildRules/Object.post.rules
@@ -0,0 +1,7 @@
+# file : BuildRules/Object.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Object.gcc.post.rules)
+# $Id$
diff --git a/contrib/utility/BuildRules/Object.pre.rules b/contrib/utility/BuildRules/Object.pre.rules
new file mode 100644
index 00000000000..54c75e0643d
--- /dev/null
+++ b/contrib/utility/BuildRules/Object.pre.rules
@@ -0,0 +1,7 @@
+# file : BuildRules/Object.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Object.gcc.pre.rules)
+# $Id$
diff --git a/contrib/utility/BuildRules/Recursion.post.rules b/contrib/utility/BuildRules/Recursion.post.rules
new file mode 100644
index 00000000000..e842f0f4b67
--- /dev/null
+++ b/contrib/utility/BuildRules/Recursion.post.rules
@@ -0,0 +1,37 @@
+# file : BuildRules/Recursion.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+.PHONY: $(target_directory_list) $(target_makefile_list)
+
+_submodules:: $(target_directory_list) $(target_makefile_list)
+
+ifneq ($(strip $(target_directory_list)),)
+$(target_directory_list):
+ $(MAKE) -C $@ -f $(default_makefile_name) $(MAKECMDGOALS)
+endif
+
+ifneq ($(strip $(target_makefile_list)),)
+$(target_makefile_list):
+ $(MAKE) --no-print-directory -f $@ $(MAKECMDGOALS)
+endif
+
+# These rules keep make from trying to use the match-anything rule below to
+# rebuild the makefiles.
+#
+ifneq ($(strip $(default_makefile_name)),)
+$(default_makefile_name) : ;
+endif
+
+%.mk :: ;
+%.rules :: ;
+
+
+# Anything we don't know how to build will use this rule. The command is a
+# do-nothing command, but the prerequisites ensure that the appropriate
+# recursive invocations of make will occur.
+#
+% :: $(target_directory_list) $(target_makefile_list) ;
+
+# $Id$
diff --git a/contrib/utility/BuildRules/Recursion.pre.rules b/contrib/utility/BuildRules/Recursion.pre.rules
new file mode 100644
index 00000000000..1f03311fbc8
--- /dev/null
+++ b/contrib/utility/BuildRules/Recursion.pre.rules
@@ -0,0 +1,13 @@
+# file : BuildRules/Recursion.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+.SUFFIXES:
+
+.PHONY: _submodules
+
+_submodules::
+
+default_makefile_name := Makefile
+# $Id$
diff --git a/contrib/utility/BuildRules/Shared.gcc.post.rules b/contrib/utility/BuildRules/Shared.gcc.post.rules
new file mode 100644
index 00000000000..641f79dfc1d
--- /dev/null
+++ b/contrib/utility/BuildRules/Shared.gcc.post.rules
@@ -0,0 +1,43 @@
+# file : BuildRules/Shared.gcc.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+FULL_MODULE_PREFIX := $(MODULE_PREFIX)$(module_prefix)
+FULL_MODULE_SUFFIX := $(module_suffix)$(MODULE_SUFFIX)
+MODULE := $(FULL_MODULE_PREFIX)$(module_base)$(FULL_MODULE_SUFFIX)
+
+#
+# Pattern rules catalog.
+# {
+
+# Defined pattern rule to build .o from .cpp
+%.o : %.cpp
+ $(CXX) $(CXX_PREPROCESS_FLAGS) $(CXX_COMPILE_FLAGS) -MD -MP -MT $(@:.o=.d) -MF $(@:.o=.d) -c $< -o $@
+
+# }
+
+# Defines the rule to build module from tarnslated c++ translation units.
+$(MODULE) : $(cxx_translation_units:.cpp=.o) $(translated_units)
+ $(CXX) $(CXX_LINK_FLAGS) -o $@ $^ $(CXX_LINK_LIBS)
+
+# Defines a phony target to clean all what's been generated
+.PHONY : clean
+clean :
+ -rm -f $(cxx_translation_units:.cpp=.o)
+ -rm -f $(cxx_translation_units:.cpp=.d)
+ -rm -f $(MODULE)
+
+
+# Include dependencies for c++ translation units.
+-include $(cxx_translation_units:.cpp=.d)
+
+
+# The following catch-all rule will skip unknown targets
+%:: ;@:
+# $Id$
diff --git a/contrib/utility/BuildRules/Shared.gcc.pre.rules b/contrib/utility/BuildRules/Shared.gcc.pre.rules
new file mode 100644
index 00000000000..d32c42f5260
--- /dev/null
+++ b/contrib/utility/BuildRules/Shared.gcc.pre.rules
@@ -0,0 +1,26 @@
+# file : BuildRules/Shared.gcc.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+CXX ?= g++
+CXX_DEP ?= $(CXX) -M
+
+CXX_PREPROCESS_FLAGS :=
+CXX_COMPILE_FLAGS := -fPIC -Wall
+CXX_LINK_FLAGS := -shared
+CXX_LINK_LIBS :=
+
+
+MODULE_PREFIX := lib
+MODULE_SUFFIX := .so
+# $Id$
diff --git a/contrib/utility/BuildRules/Shared.generic.post.rules b/contrib/utility/BuildRules/Shared.generic.post.rules
new file mode 100644
index 00000000000..19315b5d7ec
--- /dev/null
+++ b/contrib/utility/BuildRules/Shared.generic.post.rules
@@ -0,0 +1,51 @@
+# file : BuildRules/Shared.generic.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+
+#
+# Note: normally you wouldn't want to change anything below.
+#
+
+FULL_MODULE_PREFIX := $(MODULE_PREFIX)$(module_prefix)
+FULL_MODULE_SUFFIX := $(module_suffix)$(MODULE_SUFFIX)
+MODULE := $(FULL_MODULE_PREFIX)$(module_base)$(FULL_MODULE_SUFFIX)
+
+#
+# Pattern rules catalog.
+# {
+
+# Defines pattern rule to build .d from .cpp
+%.d: %.cpp
+ set -e; $(CXX_DEP) $(CXX_PREPROCESS_FLAGS) $< \
+ | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+
+# Defined pattern rule to build .o from .cpp
+%.o : %.cpp
+ $(CXX) $(CXX_PREPROCESS_FLAGS) $(CXX_COMPILE_FLAGS) -c $< -o $@
+
+# }
+
+# Defines the rule to build module from tarnslated c++ translation units.
+$(MODULE) : $(cxx_translation_units:.cpp=.o)
+ $(CXX) $(CXX_LINK_FLAGS) -o $@ $^ $(CXX_LINK_LIBS)
+
+# Defines a phony target to clean all what's been generated
+.PHONY : clean
+clean :
+ -rm -f $(cxx_translation_units:.cpp=.o)
+ -rm -f $(cxx_translation_units:.cpp=.d)
+ -rm -f $(MODULE)
+
+
+# Include dependencies for c++ translation units.
+# Optimization: if we are cleaning there is no reason to calculate
+# dependencies because they will be removed a second later.
+ifneq ($(MAKECMDGOALS),clean)
+ include $(cxx_translation_units:.cpp=.d)
+endif
+# $Id$
diff --git a/contrib/utility/BuildRules/Shared.generic.pre.rules b/contrib/utility/BuildRules/Shared.generic.pre.rules
new file mode 100644
index 00000000000..77b2a055956
--- /dev/null
+++ b/contrib/utility/BuildRules/Shared.generic.pre.rules
@@ -0,0 +1,26 @@
+# file : BuildRules/Shared.generic.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+# Forces make to delete targets whos rebuild commands failed but
+# updated the target.
+.DELETE_ON_ERROR:
+
+# Empties the suffix list for which old-fassion implicit rules would
+# be used. The net effect is that all predefined implicit rules are
+# disabled now.
+.SUFFIXES:
+
+CXX ?= g++
+
+CXX_PREPROCESS_FLAGS :=
+CXX_COMPILE_FLAGS := -fPIC -Wall
+CXX_LINK_FLAGS := -shared
+CXX_LINK_LIBS :=
+
+
+MODULE_PREFIX := lib
+MODULE_SUFFIX := .so
+
+# $Id$
diff --git a/contrib/utility/BuildRules/Shared.post.rules b/contrib/utility/BuildRules/Shared.post.rules
new file mode 100644
index 00000000000..1f098c99b7b
--- /dev/null
+++ b/contrib/utility/BuildRules/Shared.post.rules
@@ -0,0 +1,7 @@
+# file : BuildRules/Shared.post.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Shared.gcc.post.rules)
+# $Id$
diff --git a/contrib/utility/BuildRules/Shared.pre.rules b/contrib/utility/BuildRules/Shared.pre.rules
new file mode 100644
index 00000000000..9ebbeb534dd
--- /dev/null
+++ b/contrib/utility/BuildRules/Shared.pre.rules
@@ -0,0 +1,7 @@
+# file : BuildRules/Shared.pre.rules
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2002-2003 Boris Kolpackov
+# license : http://kolpackov.net/license.html
+
+$(call include, $(dir $(MAKEFILE))/Shared.gcc.pre.rules)
+# $Id$
diff --git a/contrib/utility/BuildRules/Thoughts b/contrib/utility/BuildRules/Thoughts
new file mode 100644
index 00000000000..486a44f108b
--- /dev/null
+++ b/contrib/utility/BuildRules/Thoughts
@@ -0,0 +1,55 @@
+
+Makefile variable naming style.
+
+* Each target is usually invoking one or more commands of the following type:
+
+ (1) translator which translates target's prerequsites to target(s)
+
+ (2) arbitrary command which doesn't create target (aka PHONY targets)
+
+Examples of type (1) are:
+
+ - translation of c++ source to object code
+
+ - translation of object code to executable/shared
+
+Examples of type (2) are:
+
+ - test: terget
+
+ - clean: target
+
+
+Some properties of these types of targets:
+
+ (1) - usually implemented as an implicit rule
+
+ - sometimes the same program is used as two separate translators
+ (e.g. CXX is used as a compiler and as a linker)
+
+
+
+ (2) - seldom (never?) implemented as an implicit rule
+
+
+
+Approach #1
+
+For type (1) name is derived from the translator's name e.g.
+
+CXX_COMPILE_FLAGS
+CXX_PREPROCESS_FLAGS
+CXX_LINK_FLAGS
+CXX_LINK_LIBS
+
+CC_
+LD_
+
+
+For type (2) name is derived from the target's name e.g.
+
+TEST_FLAGS
+CLEAN_FLAGS
+INSTALL_FLAGS
+
+$Id$
diff --git a/contrib/utility/Documentation/Build.xhtml b/contrib/utility/Documentation/Build.xhtml
new file mode 100644
index 00000000000..97e759bdeb7
--- /dev/null
+++ b/contrib/utility/Documentation/Build.xhtml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Build.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Building Utility Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="build,utility,library"/>
+ <meta name="description" content="Building Utility Library"/>
+
+ <link rel="stylesheet" type="text/css" href="Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>Utility Library mostly consists of a header-only sub-libraries
+(the only exception is Introspection Library) so you don't need to
+build anything to start using it. However you may want to build
+examples or libraries that require compilation. This section describes
+how to do that.</p>
+
+<h1>Prerequisites</h1>
+
+<p>To build libraries or examples you will need GNU make and a C++
+compiler with good support of ISO C++ standard.</p>
+
+<p>Utility Library building environment requires latest features of
+GNU make so you have the following options (in the order of increasing
+complexity):</p>
+
+<ul>
+<li>Use GNU make 3.81 or later (not available at the time this is written).</li>
+<li>Use GNU make 3.80 with patches for bug
+<a href="http://savannah.gnu.org/bugs/?func=detailbug&amp;bug_id=1516&amp;group_id=71">1516</a>
+and
+<a href="http://savannah.gnu.org/bugs/?func=detailbug&amp;bug_id=1517&amp;group_id=71">1517</a>.
+</li>
+<li>Use GNU make from CVS.</li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/CommandLine/News.xhtml b/contrib/utility/Documentation/CommandLine/News.xhtml
new file mode 100644
index 00000000000..31738f2150d
--- /dev/null
+++ b/contrib/utility/Documentation/CommandLine/News.xhtml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/CommandLine/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Command Line Processing Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="commandline,command,line,option,argument,parameter,operand,argc,argv,news"/>
+ <meta name="description" content="Command Line Processing Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/CommandLine/Terminology.xhtml b/contrib/utility/Documentation/CommandLine/Terminology.xhtml
new file mode 100644
index 00000000000..6c250f1fa70
--- /dev/null
+++ b/contrib/utility/Documentation/CommandLine/Terminology.xhtml
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/CommandLine/Terminology.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Command Line Processing Model and Terminology</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2002-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="command,line,terminology,model,argv,argc,argument,command,option,operand"/>
+ <meta name="description" content="Command Line Processing Model and Terminology"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+ <style type="text/css">
+
+ table.center {
+ border-collapse : collapse;
+ }
+
+ table.center * td {
+ text-align : center;
+ vertical-align : middle;
+ }
+
+ </style>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>
+Command line is probably the most universal way of passing information from
+caller to the program. Concept of a command line is part of most operating
+systems and programming languages including C and C++. However model and
+terminology for command line processing vary greatly among different
+systems.</p>
+
+<p>
+<a href="http://unix.org/online.html">Single UNIX Specification</a> contains
+<a href="http://opengroup.org/onlinepubs/007904975/basedefs/xbd_chap12.html">
+Utility Argument Syntax Conventions and Guidelines</a> which document basic
+terminology for command line processing. Single UNIX Specification model is
+a "common denominator" for different UNIX implementations. It is somewhat
+minimal and targets system utilities rather than a wide spectrum of
+applications. Another de-facto command line processing model is
+<a href="http://gnu.org/prep/standards_18.html"> GNU Standard for Command
+Line Interfaces</a> which generally encourages conformance to the Single UNIX
+Specification but adds few extensions and uses different terminology.</p>
+
+<p>
+The idea behind this document is to establish terminology and complete model
+for command line processing. Terms translation between this document, Single
+UNIX Specification and GNU Standard for Command Line Interfaces is provided
+in Appendix A.</p>
+
+
+<h1>Model and Terminology</h1>
+
+<p>
+<em>Command line</em> is an array of character strings and not just
+a string with spaces between words as some people tend to think.</p>
+
+<p>
+Each string in a command line array is referred to as <em>argument
+</em>. First argument usually contains a string that refers to an executable.
+</p>
+
+<p>
+Interpretation of arguments is completely up to a program logic however
+conventions exist that vary among different systems. Usually groups of
+arguments are translated into a higher-level objects such as commands,
+options, and operands. These objects form a model for command line processing.
+All of them are defined below.</p>
+
+
+<p>
+<em>Command</em> is usually a word, or a single letter that represents
+a command to the program logic. Neither Single UNIX Specification nor GNU
+Standard for Command Line Interfaces has the notion of a command. Other terms
+for command include <em>action</em> and <em>function</em>. Command is usually
+(but not necessarily) the first argument after executable name. Here are few
+examples:</p>
+
+<p><code>tar x</code></p>
+
+<p class="indent">
+Here we have a one letter command <code>'x'</code> (extract). In GNU tar
+manual it is called <em>functional letter</em>.</p>
+
+<p><code>tar xvf</code></p>
+
+<p class="indent">
+Here we have three commands encoded as a single letter each. Actually
+semantically only <code>'x'</code> is a command while <code>'v'</code>
+(verbose) and <code>'f'</code> (read from a file) are options.</p>
+
+<p><code>openssl req</code></p>
+
+<p class="indent">
+Here we have a word command <code>'req'</code> (operations with certificate
+requests).</p>
+
+<p><code>cvs checkout foo</code></p>
+
+<p class="indent">
+Here we have a word command <code>'checkout'</code> and command operand
+<code>foo</code>.</p>
+
+
+<p><code>tar --help</code></p>
+
+<p class="indent">
+Even though <code>'--help'</code> is usually considered to be an option
+semantically it is a command.</p>
+
+
+<p>
+<em>Option</em> consists of <em>option name</em> and optionally
+one or more <em>option values</em>. Options are usually optional.
+Non-optional options are usually better represented by commands or operands.
+</p>
+
+<p>Option name usually takes up one argument. Option names usually start with
+a prefix (e.g. <code>'--compile-only'</code>, <code>'-c'</code> or <code>'/c'
+</code>). This helps distinguish them from commands and operands. Option name
+may have aliases (e.g. for option name <code>'--output-dir'</code> there could
+be an <code>'-o'</code> alias).</p>
+
+<p>
+Option without a value is alway optional and represents an option with implied
+binary value (e.g. {0, 1} or {false, true} etc.). Such option is sometimes
+called <em>flag</em>.</p>
+
+<p>
+Option can be associated with a program or a command. Thus the concept of
+option can be further refined to <em>program option</em> and <em>
+command option</em>. Program option alters behavior of the program as a
+whole while command option is only affecting particular command.</p>
+
+
+<p>Following are some examples:</p>
+
+<p><code>g++ -o hello.o hello.cpp</code></p>
+
+<p class="indent">
+Here we have an option with name <code>'-o'</code> which has a value
+<code>'hello.o'</code>. <code>'hello.cpp'</code> is an operand.</p>
+
+
+<p><code>ls -l</code></p>
+
+<p class="indent">Here we have a flag with name <code>'-l'</code>.</p>
+
+<p>
+<code>foo --bar=a,b,c</code><br/>
+<code>foo -b "a,b,c"</code><br/>
+<code>foo /baz a b c</code>
+</p>
+
+<p class="indent">
+Here we have a more elaborate example of a multi-format option. It has
+a name <code>'--bar'</code> and two aliases: <code>'-b'</code> and
+<code>'/baz'</code>. It also has three values (in our case they are
+<code>'a'</code>, <code>'b'</code>, and <code>'c'</code>).</p>
+
+<p><code>cvs -z 6 checkout -P foo</code></p>
+
+<p class="indent">
+Here we have a program option with name <code>'-z'</code> and value
+<code>'6'</code> (set compression level to be 6). <code>'checkout'</code>
+is a command. <code>-P</code> is a command flag (prune empty directories).
+<code>'foo'</code> is a command operand.</p>
+
+<p>
+<em>operand</em> usually represents an input value or a parameter.
+Operands can be mandatory or optional. Interpretation of operands is usually
+application-specific.</p>
+
+<p>
+Same as with option the concept of operand can be further refined to
+<em>program operand</em> and <em>command operand</em>.</p>
+
+<h1>Appendix A: Terms Translation</h1>
+
+<table summary="Terms Translation"
+ border="1"
+ cellspacing="0"
+ cellpadding="4"
+ class="center">
+
+ <col width="34%" />
+ <col width="33%" />
+ <col width="33%" />
+
+ <tr>
+ <th>Term</th>
+ <th>Single UNIX Specification</th>
+ <th>GNU</th>
+ </tr>
+ <tr>
+ <td>command line</td>
+ <td>command line</td>
+ <td>command line</td>
+ </tr>
+ <tr>
+ <td>argument</td>
+ <td>argument</td>
+ <td>argument</td>
+ </tr>
+ <tr>
+ <td>command</td>
+ <td>--</td>
+ <td>--</td>
+ </tr>
+ <tr>
+ <td>option</td>
+ <td>--</td>
+ <td>option</td>
+ </tr>
+ <tr>
+ <td>option name</td>
+ <td>option</td>
+ <td>name</td>
+ </tr>
+ <tr>
+ <td>option value</td>
+ <td>option-argument</td>
+ <td>--</td>
+ </tr>
+ <tr>
+ <td>program option</td>
+ <td>--</td>
+ <td>--</td>
+ </tr>
+ <tr>
+ <td>command option</td>
+ <td>--</td>
+ <td>--</td>
+ </tr>
+ <tr>
+ <td>operand</td>
+ <td>operand</td>
+ <td>argument</td>
+ </tr>
+ <tr>
+ <td>program operand</td>
+ <td>--</td>
+ <td>--</td>
+ </tr>
+ <tr>
+ <td>command operand</td>
+ <td>--</td>
+ <td>--</td>
+ </tr>
+</table>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/CommandLine/Thoughts b/contrib/utility/Documentation/CommandLine/Thoughts
new file mode 100644
index 00000000000..a10675f5945
--- /dev/null
+++ b/contrib/utility/Documentation/CommandLine/Thoughts
@@ -0,0 +1,8 @@
+
+@@ I should not assume that Utility::CommandLine is the only mechanism
+ used to parse command line. Application developer may be using
+ different components that employ different command line parsers.
+ Thus it seem to me that I should use argv/argc as input/output
+ format.
+
+$Id$
diff --git a/contrib/utility/Documentation/CommandLine/index.xhtml b/contrib/utility/Documentation/CommandLine/index.xhtml
new file mode 100644
index 00000000000..7caf91689aa
--- /dev/null
+++ b/contrib/utility/Documentation/CommandLine/index.xhtml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/CommandLine/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Command Line Processing Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="commandline,command,line,option,argument,parameter,operand,argc,argv"/>
+ <meta name="description" content="Command Line Processing Library"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>
+Command Line Processing library is in early development stage. You may want
+to take a look at <a href="Terminology.xhtml">Command Line Processing Model
+and Terminology</a> page.
+</p>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Compound.hpp.html b/contrib/utility/Documentation/ExH/Compound.hpp.html
new file mode 100644
index 00000000000..b8996f89552
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Compound.hpp.html
@@ -0,0 +1,50 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+Compound.hpp</title>
+<link rel="stylesheet" href="../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ExH/Compound.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ExH
+ </span><span class=special>{
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Type</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>Base</span><span class=special>&gt;
+ </span><span class=keyword>class </span><span class=identifier>Compound </span><span class=special>: </span><span class=keyword>public </span><span class=keyword>virtual </span><span class=identifier>Base
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>explicit
+ </span><span class=identifier>Compound </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>explicit
+ </span><span class=identifier>Compound </span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=keyword>explicit
+ </span><span class=identifier>Compound </span><span class=special>(</span><span class=identifier>T </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>Compound </span><span class=special>(</span><span class=identifier>Compound </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>src</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>Compound </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=identifier>Compound</span><span class=special>&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>Compound </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>src</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=identifier>Compound </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=special>};
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Example/Makefile b/contrib/utility/Documentation/ExH/Example/Makefile
new file mode 100644
index 00000000000..e0188a81fbf
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Example/Makefile
@@ -0,0 +1,26 @@
+# file : Documentation/ExH/Example/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/Documentation.pre.rules)
+
+vpath %.cpp $(root)/Example/ExH/BadCast
+vpath %.cpp $(root)/Example/ExH/Compound
+vpath %.cpp $(root)/Example/ExH/HelloWorld
+vpath %.cpp $(root)/Example/ExH/LogicToSystem
+
+doc_translation_units := bad_cast.cpp \
+ compound.cpp \
+ hello_world.cpp \
+ logic_to_system.cpp
+
+DOC_FLAGS := -css $(root)/Documentation/Style/CXX.css
+
+$(call include, $(root)/BuildRules/Documentation.post.rules)
+
+# $Id$
diff --git a/contrib/utility/Documentation/ExH/Example/bad_cast.cpp.html b/contrib/utility/Documentation/ExH/Example/bad_cast.cpp.html
new file mode 100644
index 00000000000..ba5044e358a
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Example/bad_cast.cpp.html
@@ -0,0 +1,63 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+bad_cast.cpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Example/ExH/BadCast/bad_cast.cpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=preprocessor>#include &quot;Utility/ExH/System/Exception.hpp&quot;
+
+</span><span class=preprocessor>#include &lt;iostream&gt;
+
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cerr</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;
+
+
+</span><span class=keyword>struct </span><span class=identifier>A
+</span><span class=special>{
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>A</span><span class=special>() </span><span class=special>{}
+</span><span class=special>};
+
+</span><span class=keyword>struct </span><span class=identifier>B
+</span><span class=special>{
+ </span><span class=keyword>void
+ </span><span class=identifier>foo </span><span class=special>() </span><span class=special>{}
+</span><span class=special>};
+
+</span><span class=keyword>void
+</span><span class=identifier>foo </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>)
+</span><span class=special>{
+ </span><span class=identifier>A </span><span class=identifier>a</span><span class=special>;
+
+ </span><span class=identifier>A</span><span class=special>&amp; </span><span class=identifier>ar </span><span class=special>(</span><span class=identifier>a</span><span class=special>);
+
+ </span><span class=identifier>B</span><span class=special>&amp; </span><span class=identifier>br </span><span class=special>(</span><span class=keyword>dynamic_cast</span><span class=special>&lt;</span><span class=identifier>B</span><span class=special>&amp;&gt; </span><span class=special>(</span><span class=identifier>ar</span><span class=special>));
+
+ </span><span class=identifier>br</span><span class=special>.</span><span class=identifier>foo </span><span class=special>();
+</span><span class=special>}
+
+</span><span class=keyword>int
+</span><span class=identifier>main </span><span class=special>()
+</span><span class=special>{
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=identifier>foo </span><span class=special>();
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ex</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught Utility::ExH::System::Exception: &quot;
+ </span><span class=special>&lt;&lt; </span><span class=identifier>ex</span><span class=special>.</span><span class=identifier>what </span><span class=special>()
+ </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+</span><span class=special>}
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Example/compound.cpp.html b/contrib/utility/Documentation/ExH/Example/compound.cpp.html
new file mode 100644
index 00000000000..40ecf71eee9
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Example/compound.cpp.html
@@ -0,0 +1,153 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+compound.cpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Example/ExH/Compound/compound.cpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=preprocessor>#include &quot;Utility/ExH/Compound.hpp&quot;
+</span><span class=preprocessor>#include &quot;Utility/ExH/System/Exception.hpp&quot;
+</span><span class=preprocessor>#include &quot;Utility/ExH/Logic/DescriptiveException.hpp&quot;
+
+</span><span class=comment>// Include some helper converters to allow exception initialization
+// with std::ostringstream
+
+</span><span class=preprocessor>#include &quot;Utility/ExH/StringStreamConverter.hpp&quot;
+
+</span><span class=preprocessor>#include &lt;iostream&gt;
+
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cerr</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>ostringstream</span><span class=special>;
+
+</span><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>ExH</span><span class=special>;
+
+</span><span class=comment>// Here are our components
+
+</span><span class=keyword>class </span><span class=identifier>Base
+</span><span class=special>{
+</span><span class=keyword>public</span><span class=special>:
+
+ </span><span class=comment>//
+ // Exception definitions.
+ //
+
+ // Base logic exception class for component.
+ </span><span class=keyword>class </span><span class=identifier>Exception_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>Compound </span><span class=special>&lt;</span><span class=identifier>Exception_</span><span class=special>, </span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>DescriptiveException</span><span class=special>&gt;
+ </span><span class=identifier>Exception</span><span class=special>;
+
+ </span><span class=keyword>class </span><span class=identifier>InvalidArgument_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>Compound </span><span class=special>&lt;</span><span class=identifier>InvalidArgument_</span><span class=special>, </span><span class=identifier>Exception</span><span class=special>&gt;
+ </span><span class=identifier>InvalidArgument</span><span class=special>;
+
+ </span><span class=keyword>class </span><span class=identifier>NotInitialized_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>Compound </span><span class=special>&lt;</span><span class=identifier>NotInitialized_</span><span class=special>, </span><span class=identifier>Exception</span><span class=special>&gt;
+ </span><span class=identifier>NotInitialized</span><span class=special>;
+
+</span><span class=keyword>public</span><span class=special>:
+
+ </span><span class=keyword>void
+ </span><span class=identifier>foo </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>str</span><span class=special>) </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>InvalidArgument</span><span class=special>, </span><span class=identifier>NotInitialized</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=comment>// This is just an example.
+
+ </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>str </span><span class=special>== </span><span class=number>0</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=keyword>throw </span><span class=identifier>InvalidArgument </span><span class=special>(</span><span class=string>&quot;Base::foo: first parameter is zero.&quot;</span><span class=special>);
+ </span><span class=special>}
+ </span><span class=keyword>else
+ </span><span class=special>{
+ </span><span class=identifier>ostringstream </span><span class=identifier>ostr</span><span class=special>;
+ </span><span class=identifier>ostr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Base::foo [this = &quot; </span><span class=special>&lt;&lt; </span><span class=keyword>this </span><span class=special>&lt;&lt; </span><span class=string>&quot;]: object is not initialized.&quot;</span><span class=special>;
+
+ </span><span class=keyword>throw </span><span class=identifier>NotInitialized </span><span class=special>(</span><span class=identifier>ostr</span><span class=special>);
+ </span><span class=special>}
+ </span><span class=special>}
+
+
+ </span><span class=comment>// 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
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>vfoo </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>) </span><span class=special>= </span><span class=number>0</span><span class=special>;
+</span><span class=special>};
+
+</span><span class=keyword>class </span><span class=identifier>Derived </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>Base
+</span><span class=special>{
+</span><span class=keyword>public</span><span class=special>:
+
+ </span><span class=comment>// Define some Derived-specific logic exception.
+ </span><span class=keyword>class </span><span class=identifier>NotImplemented_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>Compound </span><span class=special>&lt;</span><span class=identifier>NotImplemented_</span><span class=special>, </span><span class=identifier>Exception</span><span class=special>&gt;
+ </span><span class=identifier>NotImplemented</span><span class=special>;
+
+</span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>vfoo </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>NotImplemented</span><span class=special>, </span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>str </span><span class=special>(</span><span class=string>&quot;Derived::vfoo: not implemented yet.&quot;</span><span class=special>);
+ </span><span class=keyword>throw </span><span class=identifier>NotImplemented </span><span class=special>(</span><span class=identifier>str</span><span class=special>);
+ </span><span class=special>}
+</span><span class=special>};
+
+</span><span class=keyword>int
+</span><span class=identifier>main </span><span class=special>()
+</span><span class=special>{
+ </span><span class=keyword>try
+ </span><span class=special>{
+
+ </span><span class=identifier>Derived </span><span class=identifier>d</span><span class=special>;
+ </span><span class=identifier>Base</span><span class=special>* </span><span class=identifier>pb </span><span class=special>(&amp;</span><span class=identifier>d</span><span class=special>);
+
+ </span><span class=comment>// We can use generic handler.
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=identifier>pb</span><span class=special>-&gt;</span><span class=identifier>vfoo </span><span class=special>();
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Base</span><span class=special>::</span><span class=identifier>Exception </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ex</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught Base::Exception: &quot; </span><span class=special>&lt;&lt; </span><span class=identifier>ex</span><span class=special>.</span><span class=identifier>what </span><span class=special>() </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+
+
+ </span><span class=comment>// Or use more precise control.
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=identifier>pb</span><span class=special>-&gt;</span><span class=identifier>foo </span><span class=special>(</span><span class=string>&quot;hello&quot;</span><span class=special>);
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Base</span><span class=special>::</span><span class=identifier>NotInitialized </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ex</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught Base::NotInitialized: &quot; </span><span class=special>&lt;&lt; </span><span class=identifier>ex</span><span class=special>.</span><span class=identifier>what </span><span class=special>() </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+
+ </span><span class=comment>// Or use application-level handler.
+ </span><span class=identifier>pb</span><span class=special>-&gt;</span><span class=identifier>foo </span><span class=special>(</span><span class=number>0</span><span class=special>);
+
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>Exception </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ex</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught Logic::Exception: &quot; </span><span class=special>&lt;&lt; </span><span class=identifier>ex</span><span class=special>.</span><span class=identifier>what </span><span class=special>() </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(...)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught unknown exception using catch-all handler&quot; </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=keyword>return </span><span class=special>-</span><span class=number>1</span><span class=special>;
+ </span><span class=special>}
+
+</span><span class=special>}
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Example/hello_world.cpp.html b/contrib/utility/Documentation/ExH/Example/hello_world.cpp.html
new file mode 100644
index 00000000000..3d2497f325e
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Example/hello_world.cpp.html
@@ -0,0 +1,152 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+hello_world.cpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Example/ExH/HelloWorld/hello_world.cpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=preprocessor>#include &lt;cstdlib&gt; // for std::abort ()
+
+</span><span class=preprocessor>#include &lt;string&gt;
+</span><span class=preprocessor>#include &lt;iostream&gt;
+
+</span><span class=preprocessor>#include &quot;Utility/ExH/System/Exception.hpp&quot;
+</span><span class=preprocessor>#include &quot;Utility/ExH/Logic/Exception.hpp&quot;
+
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cerr</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;
+
+</span><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>Utility</span><span class=special>;
+
+</span><span class=keyword>class </span><span class=identifier>Application
+</span><span class=special>{
+</span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>class </span><span class=identifier>Exception </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>Exception </span><span class=special>{};
+
+ </span><span class=comment>// Hint: you may want to try again...
+ </span><span class=keyword>class </span><span class=identifier>FeelingDizzy </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>Exception </span><span class=special>{};
+
+ </span><span class=keyword>class </span><span class=identifier>InvalidArg </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>Exception </span><span class=special>{};
+
+</span><span class=keyword>public</span><span class=special>:
+ </span><span class=identifier>Application </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>)
+ </span><span class=special>: </span><span class=comment>// The std::string c-tor may throw any kind of exceptions besides
+ // quite possible std::bad_alloc.
+ </span><span class=identifier>greeting_ </span><span class=special>(</span><span class=string>&quot;Hello, world!&quot;</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=special>}
+
+ </span><span class=identifier>Application </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const </span><span class=special>* </span><span class=identifier>greeting</span><span class=special>) </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>InvalidArg</span><span class=special>,
+ </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>)
+ </span><span class=special>: </span><span class=identifier>greeting_ </span><span class=special>(</span><span class=identifier>greeting </span><span class=special>== </span><span class=number>0 </span><span class=special>? </span><span class=string>&quot;&quot; </span><span class=special>: </span><span class=identifier>greeting</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>greeting </span><span class=special>== </span><span class=number>0</span><span class=special>) </span><span class=keyword>throw </span><span class=identifier>InvalidArg </span><span class=special>();
+ </span><span class=special>}
+
+</span><span class=keyword>public</span><span class=special>:
+
+ </span><span class=keyword>void
+ </span><span class=identifier>run </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>FeelingDizzy</span><span class=special>, </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=keyword>static </span><span class=keyword>unsigned </span><span class=keyword>int </span><span class=identifier>dizzy_count </span><span class=special>(</span><span class=number>0</span><span class=special>);
+
+ </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>dizzy_count</span><span class=special>++ </span><span class=special>&lt; </span><span class=number>5</span><span class=special>) </span><span class=keyword>throw </span><span class=identifier>FeelingDizzy </span><span class=special>();
+
+ </span><span class=comment>// The next line can throw full bucket of exceptions
+ // not to mention ios_base::failure.
+ </span><span class=identifier>cout </span><span class=special>&lt;&lt; </span><span class=identifier>greeting_</span><span class=special>.</span><span class=identifier>c_str </span><span class=special>() </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+
+</span><span class=keyword>private</span><span class=special>:
+
+ </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>greeting_</span><span class=special>;
+</span><span class=special>};
+
+
+
+</span><span class=keyword>int
+</span><span class=identifier>main </span><span class=special>()
+</span><span class=special>{
+ </span><span class=comment>// This is a catch-all layer that should be in use only
+ // if we are really in trouble.
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=comment>// 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.
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=comment>// This is a catch-logic layer. If we get here it usually
+ // indicates an application logic error.
+ </span><span class=keyword>try
+ </span><span class=special>{
+
+ </span><span class=comment>// Ok, here we go about our application logic.
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=keyword>for </span><span class=special>(</span><span class=keyword>int </span><span class=identifier>i </span><span class=special>= </span><span class=number>0</span><span class=special>; </span><span class=identifier>i </span><span class=special>&lt; </span><span class=number>10</span><span class=special>; </span><span class=identifier>i</span><span class=special>++)
+ </span><span class=special>{
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=identifier>Application </span><span class=identifier>app </span><span class=special>(</span><span class=string>&quot;Hi dude!&quot;</span><span class=special>);
+ </span><span class=identifier>app</span><span class=special>.</span><span class=identifier>run </span><span class=special>();
+ </span><span class=keyword>break</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Application</span><span class=special>::</span><span class=identifier>FeelingDizzy </span><span class=keyword>const</span><span class=special>&amp; </span><span class=special>)
+ </span><span class=special>{
+ </span><span class=keyword>if </span><span class=special>(</span><span class=identifier>i </span><span class=special>== </span><span class=number>9</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Given up!&quot; </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=keyword>return </span><span class=special>-</span><span class=number>1</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=keyword>else
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Application is feeling dizzy. Trying again...&quot;
+ </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=special>}
+ </span><span class=special>}
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Application</span><span class=special>::</span><span class=identifier>InvalidArg </span><span class=keyword>const</span><span class=special>&amp; </span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Cought Application::InvalidArg : ...hmm... strange!&quot;
+ </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=keyword>return </span><span class=special>-</span><span class=number>1</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>Exception </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>e</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught Logic::Exception : &quot; </span><span class=special>&lt;&lt; </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>what </span><span class=special>() </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=keyword>return </span><span class=special>-</span><span class=number>1</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=keyword>const </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>&amp; </span><span class=identifier>e</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught System::Exception : &quot; </span><span class=special>&lt;&lt; </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>what </span><span class=special>() </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=keyword>return </span><span class=special>-</span><span class=number>1</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(...)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught unknown exception using catch-all handler. &quot; </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=keyword>return </span><span class=special>-</span><span class=number>1</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(...)
+ </span><span class=special>{
+ </span><span class=comment>// We get here in cases of some hard failure. For example when handling
+ // exception, operator &lt;&lt; throws another exception. Usually application
+ // cannot handle such failures itself so we just propagate it futher.
+ </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>abort </span><span class=special>();
+ </span><span class=special>}
+</span><span class=special>}
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Example/logic_to_system.cpp.html b/contrib/utility/Documentation/ExH/Example/logic_to_system.cpp.html
new file mode 100644
index 00000000000..d29794d4c2c
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Example/logic_to_system.cpp.html
@@ -0,0 +1,69 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+logic_to_system.cpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Example/ExH/LogicToSystem/logic_to_system.cpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=preprocessor>#include &quot;Utility/ExH/System/Exception.hpp&quot;
+</span><span class=preprocessor>#include &quot;Utility/ExH/Logic/Exception.hpp&quot;
+
+</span><span class=preprocessor>#include &lt;iostream&gt;
+
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cerr</span><span class=special>;
+</span><span class=keyword>using </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>;
+
+
+</span><span class=keyword>struct </span><span class=identifier>SubsystemA
+</span><span class=special>{
+ </span><span class=keyword>class </span><span class=identifier>Exception </span><span class=special>: </span><span class=keyword>public </span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>Exception </span><span class=special>{};
+
+ </span><span class=keyword>void
+ </span><span class=identifier>foo </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=keyword>throw </span><span class=identifier>Exception </span><span class=special>();
+ </span><span class=special>}
+</span><span class=special>};
+
+
+</span><span class=keyword>struct </span><span class=identifier>SubsystemB
+</span><span class=special>{
+ </span><span class=keyword>void
+ </span><span class=identifier>foo </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>SubsystemA </span><span class=identifier>a</span><span class=special>;
+ </span><span class=identifier>a</span><span class=special>.</span><span class=identifier>foo </span><span class=special>();
+
+ </span><span class=comment>// 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.
+ </span><span class=special>}
+</span><span class=special>};
+
+
+</span><span class=keyword>int
+</span><span class=identifier>main </span><span class=special>()
+</span><span class=special>{
+ </span><span class=keyword>try
+ </span><span class=special>{
+ </span><span class=identifier>SubsystemB </span><span class=identifier>b</span><span class=special>;
+ </span><span class=identifier>b</span><span class=special>.</span><span class=identifier>foo </span><span class=special>();
+ </span><span class=special>}
+ </span><span class=keyword>catch </span><span class=special>(</span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ex</span><span class=special>)
+ </span><span class=special>{
+ </span><span class=identifier>cerr </span><span class=special>&lt;&lt; </span><span class=string>&quot;Caught Utility::ExH::System::Exception: &quot;
+ </span><span class=special>&lt;&lt; </span><span class=identifier>ex</span><span class=special>.</span><span class=identifier>what </span><span class=special>()
+ </span><span class=special>&lt;&lt; </span><span class=identifier>endl</span><span class=special>;
+ </span><span class=special>}
+</span><span class=special>}
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Logic/DescriptiveException.hpp.html b/contrib/utility/Documentation/ExH/Logic/DescriptiveException.hpp.html
new file mode 100644
index 00000000000..b54dbd30936
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Logic/DescriptiveException.hpp.html
@@ -0,0 +1,61 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+DescriptiveException.hpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ExH/Logic/DescriptiveException.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ExH
+ </span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>Logic
+ </span><span class=special>{
+ </span><span class=keyword>class </span><span class=identifier>DescriptiveException </span><span class=special>: </span><span class=keyword>public </span><span class=keyword>virtual </span><span class=identifier>Exception
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>explicit
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>explicit
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=keyword>explicit
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=identifier>T </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=identifier>DescriptiveException </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>src</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>DescriptiveException </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>DescriptiveException</span><span class=special>&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>DescriptiveException </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>src</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=identifier>DescriptiveException </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>void
+ </span><span class=identifier>init </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*
+ </span><span class=identifier>what </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>auto_ptr</span><span class=special>&lt;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>&gt; </span><span class=identifier>description_</span><span class=special>;
+ </span><span class=special>};
+ </span><span class=special>}
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Logic/Exception.hpp.html b/contrib/utility/Documentation/ExH/Logic/Exception.hpp.html
new file mode 100644
index 00000000000..5b4b56aa46d
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Logic/Exception.hpp.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+Exception.hpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ExH/Logic/Exception.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ExH
+ </span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>Logic
+ </span><span class=special>{
+
+ </span><span class=comment>// Logic::Exception inherits from System::Exception for the
+ // following reason. Semantically for some part of the
+ // system particular instance of Logic::Exception may seem as
+ // opaque System::Exception and the only way to handle it would
+ // be to propagate it further. In other words Logic::Exception
+ // can be seemlesly &quot;converted&quot; to System::Exception if there is
+ // no part of the system interested in handling it.
+ //
+
+ </span><span class=keyword>class </span><span class=identifier>Exception </span><span class=special>: </span><span class=keyword>public </span><span class=keyword>virtual </span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>Exception </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=special>};
+ </span><span class=special>}
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/Logic/Makefile b/contrib/utility/Documentation/ExH/Logic/Makefile
new file mode 100644
index 00000000000..d2d48d406bf
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Logic/Makefile
@@ -0,0 +1,20 @@
+# file : Documentation/ExH/Logic/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/Documentation.pre.rules)
+
+vpath %.hpp $(root)/Utility/ExH/Logic
+
+doc_translation_units := Exception.hpp DescriptiveException.hpp
+
+DOC_FLAGS := --strip-preprocessor -css $(root)/Documentation/Style/CXX.css
+
+$(call include, $(root)/BuildRules/Documentation.post.rules)
+
+# $Id$
diff --git a/contrib/utility/Documentation/ExH/Makefile b/contrib/utility/Documentation/ExH/Makefile
new file mode 100644
index 00000000000..c4a5bc5f6c0
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Makefile
@@ -0,0 +1,16 @@
+# file : Documentation/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 := Makefile.documentation
+target_directory_list := Logic System Example
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Documentation/ExH/Makefile.documentation b/contrib/utility/Documentation/ExH/Makefile.documentation
new file mode 100644
index 00000000000..3ebf1511555
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/Makefile.documentation
@@ -0,0 +1,20 @@
+# file : Documentation/ExH/Make.doc.mk
+# 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/Documentation.pre.rules)
+
+vpath %.hpp $(root)/Utility/ExH
+
+doc_translation_units := Compound.hpp
+
+DOC_FLAGS := --strip-preprocessor -css $(root)/Documentation/Style/CXX.css
+
+$(call include, $(root)/BuildRules/Documentation.post.rules)
+
+# $Id$
diff --git a/contrib/utility/Documentation/ExH/News.xhtml b/contrib/utility/Documentation/ExH/News.xhtml
new file mode 100644
index 00000000000..b86f821c992
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/News.xhtml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/ExH/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Exception Handling Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="news,C++,exception,handling,model"/>
+ <meta name="description" content="Exception Handling Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>1.2.0</h1>
+
+<ul class="multiline">
+ <li>
+ Fixed incorrect initialization of <code>DescriptiveException</code> with
+ <code>std::ostringstream</code> object. Thanks to Karen Aroutiounov
+ &lt;karen@ipmce.ru&gt; for reporting this.
+ </li>
+</ul>
+
+<h1>1.1.0</h1>
+
+<ul class="multiline">
+ <li>New regression test coverage.</li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/System/DescriptiveException.hpp.html b/contrib/utility/Documentation/ExH/System/DescriptiveException.hpp.html
new file mode 100644
index 00000000000..fb6b35d4143
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/System/DescriptiveException.hpp.html
@@ -0,0 +1,64 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+DescriptiveException.hpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ExH/System/DescriptiveException.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ExH
+ </span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>System
+ </span><span class=special>{
+ </span><span class=keyword>class </span><span class=identifier>DescriptiveException </span><span class=special>: </span><span class=keyword>public </span><span class=keyword>virtual </span><span class=identifier>Exception
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>explicit
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>explicit
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=keyword>explicit
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=identifier>T </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>DescriptiveException </span><span class=special>(</span><span class=identifier>DescriptiveException </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>src</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>DescriptiveException </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>DescriptiveException</span><span class=special>&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>DescriptiveException </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>src</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=identifier>DescriptiveException </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>void
+ </span><span class=identifier>init </span><span class=special>(</span><span class=keyword>char </span><span class=keyword>const</span><span class=special>* </span><span class=identifier>description</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>char </span><span class=keyword>const</span><span class=special>*
+ </span><span class=identifier>what </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>private</span><span class=special>:
+
+ </span><span class=keyword>static </span><span class=keyword>unsigned </span><span class=keyword>long </span><span class=keyword>const </span><span class=identifier>DESCRIPTION_SIZE </span><span class=special>= </span><span class=number>256</span><span class=special>;
+
+ </span><span class=keyword>char </span><span class=identifier>description_ </span><span class=special>[</span><span class=identifier>DESCRIPTION_SIZE</span><span class=special>];
+ </span><span class=special>};
+ </span><span class=special>}
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/System/Exception.hpp.html b/contrib/utility/Documentation/ExH/System/Exception.hpp.html
new file mode 100644
index 00000000000..60d6bd733f5
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/System/Exception.hpp.html
@@ -0,0 +1,32 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+Exception.hpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ExH/System/Exception.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ExH
+ </span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>System
+ </span><span class=special>{
+ </span><span class=comment>// This is the only way to make predefined exceptions like
+ // std::bad_alloc, etc to appear in the right place of the hierarchy.
+ //
+
+ </span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>exception </span><span class=identifier>Exception</span><span class=special>;
+ </span><span class=special>}
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ExH/System/Makefile b/contrib/utility/Documentation/ExH/System/Makefile
new file mode 100644
index 00000000000..7c7bfbc8e8d
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/System/Makefile
@@ -0,0 +1,20 @@
+# file : Documentation/ExH/System/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/Documentation.pre.rules)
+
+vpath %.hpp $(root)/Utility/ExH/System
+
+doc_translation_units := Exception.hpp DescriptiveException.hpp
+
+DOC_FLAGS := --strip-preprocessor -css $(root)/Documentation/Style/CXX.css
+
+$(call include, $(root)/BuildRules/Documentation.post.rules)
+
+# $Id$
diff --git a/contrib/utility/Documentation/ExH/index.xhtml b/contrib/utility/Documentation/ExH/index.xhtml
new file mode 100644
index 00000000000..c2d40d9fbaa
--- /dev/null
+++ b/contrib/utility/Documentation/ExH/index.xhtml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/ExH/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Exception Handling Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="C++,utility,exception,handling,model,ExH"/>
+ <meta name="description" content="Exception Handling Library"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>
+Exception Handling library was designed to promote consistent usage of
+exceptions and exception handling mechanisms throughout the project.
+For a quick overview of the basic idea you may want to look at some
+examples.</p>
+
+<h1>Examples</h1>
+
+<ul class="menu">
+ <li><a href="Example/bad_cast.cpp.html">bad_cast.cpp</a></li>
+ <li><a href="Example/compound.cpp.html">compound.cpp</a></li>
+ <li><a href="Example/hello_world.cpp.html">hello_world.cpp</a></li>
+ <li><a href="Example/logic_to_system.cpp.html">logic_to_system.cpp</a></li>
+</ul>
+
+<h1>Definitions</h1>
+
+<p>Following are the definitions of the main blocks of the model:</p>
+
+<ul class="menu">
+ <li><a href="Compound.hpp.html">ExH::Compound</a></li>
+ <li><a href="System/Exception.hpp.html">ExH::System::Exception</a></li>
+ <li><a href="System/DescriptiveException.hpp.html">ExH::System::DescriptiveException</a></li>
+ <li><a href="Logic/Exception.hpp.html">ExH::Logic::Exception</a></li>
+ <li><a href="Logic/DescriptiveException.hpp.html">ExH::Logic::DescriptiveException</a></li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Hetero/News.xhtml b/contrib/utility/Documentation/Hetero/News.xhtml
new file mode 100644
index 00000000000..b99645d704d
--- /dev/null
+++ b/contrib/utility/Documentation/Hetero/News.xhtml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Hetero/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Heterogeneous Container Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="c++,heterogeneous,container,news"/>
+ <meta name="description" content="Heterogeneous Container Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Hetero/index.xhtml b/contrib/utility/Documentation/Hetero/index.xhtml
new file mode 100644
index 00000000000..d45a7b6e82d
--- /dev/null
+++ b/contrib/utility/Documentation/Hetero/index.xhtml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Hetero/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Heterogeneous Container Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="c++,heterogeneous,container"/>
+ <meta name="description" content="Heterogeneous Container Library"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>Have you ever wanted to write something like this:</p>
+
+<pre>
+vector v;
+
+v.push_back (10);
+v.push_back (true);
+v.push_back ("hello");
+</pre>
+
+<p>Or maybe even something like this:</p>
+
+<pre>
+template &lt;typename T&gt;
+void print (T const&amp; t)
+{
+ cout &lt;&lt; t &lt;&lt; endl;
+}
+
+for (vector::const_iterator i = v.begin (); i != v.end (); i++)
+{
+ print (*i);
+}
+</pre>
+
+<p>If so then you may be interested in Heterogeneous Container Library.
+It is still in active development but you can take a look for some
+examples in Example/Hetero directory.</p>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Introspection/News.xhtml b/contrib/utility/Documentation/Introspection/News.xhtml
new file mode 100644
index 00000000000..257c790766c
--- /dev/null
+++ b/contrib/utility/Documentation/Introspection/News.xhtml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Introspection/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Introspection Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="introspection,library,news"/>
+ <meta name="description" content="Introspection Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>1.2.2</h1>
+<ul class="multiline">
+ <li>
+ Removed no-throw specification from <code>Introspection::Object::~Object()</code>.
+ </li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Introspection/index.xhtml b/contrib/utility/Documentation/Introspection/index.xhtml
new file mode 100644
index 00000000000..462b2c87321
--- /dev/null
+++ b/contrib/utility/Documentation/Introspection/index.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Introspection/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Introspection Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="c++,type,object,class,introspection"/>
+ <meta name="description" content="Introspection Library"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>
+Sometimes there is a need to analyze object's type at runtime. ISO C++
+provides some capabilities for this kind of introspection however they
+are limited to basic type information. Such information as type
+inheritance graph is not accessible in standard C++. Introspection
+Library provides a framework that enables discovery of type structure
+at runtime. The library is still in development stage but a few meaningful
+examples are available in Example/Introspection directory.</p>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Makefile b/contrib/utility/Documentation/Makefile
new file mode 100644
index 00000000000..6a2caae9002
--- /dev/null
+++ b/contrib/utility/Documentation/Makefile
@@ -0,0 +1,16 @@
+# file : Documentation/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 := ExH ReferenceCounting Synch
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Documentation/News.xhtml b/contrib/utility/Documentation/News.xhtml
new file mode 100644
index 00000000000..b3ea1389e53
--- /dev/null
+++ b/contrib/utility/Documentation/News.xhtml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Utility Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="news,C++,utility,exception,handling,model,reference,counting,thread,synchronization"/>
+ <meta name="description" content="Utility Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Sub-Library News</h1>
+
+<ul class="menu">
+ <li><a href="ExH/News.xhtml">Exception Handling</a></li>
+ <li><a href="ReferenceCounting/News.xhtml">Reference Counting</a></li>
+ <li><a href="Synch/News.xhtml">Synchronization</a></li>
+ <li><a href="Introspection/News.xhtml">Introspection</a></li>
+</ul>
+
+<h1>1.2.2</h1>
+<ul class="multiline">
+ <li>Bug fixes in build system.</li>
+</ul>
+
+
+<h1>1.2.1</h1>
+<ul class="multiline">
+ <li>
+ Documentation bug fixes.
+ </li>
+</ul>
+
+
+<h1>1.2.0</h1>
+<ul class="multiline">
+ <li>
+ Added new <a href="Hetero/index.xhtml">Heterogeneous Container Library</a>.
+ </li>
+ <li>
+ Added new <a href="Introspection/index.xhtml">Introspection Library</a>.
+ </li>
+</ul>
+
+
+<h1>1.1.0</h1>
+<ul class="multiline">
+ <li>New directory structure.</li>
+ <li>New dependency generation mechanism.</li>
+ <li>Automatic documentation generation (<code>make documentation</code>).</li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReferenceCounting/DefaultImpl.hpp.html b/contrib/utility/Documentation/ReferenceCounting/DefaultImpl.hpp.html
new file mode 100644
index 00000000000..86edcd70ec2
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/DefaultImpl.hpp.html
@@ -0,0 +1,93 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+DefaultImpl.hpp</title>
+<link rel="stylesheet" href="../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ReferenceCounting/DefaultImpl.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ReferenceCounting
+ </span><span class=special>{
+ </span><span class=comment>// Default reference counter implementation with parameterised
+ // synchronization policy. It is assumed that none of the SynchPolicy
+ // types throw any logic exceptions. If in fact they do then these
+ // exceptions won't be handled and will be automatically converted
+ // to system exceptions.
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>SynchPolicy </span><span class=special>= </span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>Synch</span><span class=special>::</span><span class=identifier>Policy</span><span class=special>::</span><span class=identifier>Null</span><span class=special>&gt;
+ </span><span class=keyword>class </span><span class=identifier>DefaultImpl </span><span class=special>: </span><span class=keyword>public </span><span class=keyword>virtual </span><span class=identifier>Interface
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>class </span><span class=identifier>InconsistentState_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Compound</span><span class=special>&lt;</span><span class=identifier>InconsistentState_</span><span class=special>, </span><span class=identifier>Exception</span><span class=special>&gt;
+ </span><span class=identifier>InconsistentState</span><span class=special>;
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=identifier>DefaultImpl </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>DefaultImpl </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>add_ref </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>remove_ref </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>virtual </span><span class=identifier>count_t
+ </span><span class=identifier>refcount_value </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>add_ref_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>virtual </span><span class=keyword>bool
+ </span><span class=identifier>remove_ref_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>virtual </span><span class=identifier>count_t
+ </span><span class=identifier>refcount_value_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>Mutex</span><span class=special>&amp;
+ </span><span class=identifier>lock_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=keyword>typedef
+ </span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>Mutex
+ </span><span class=identifier>Mutex_</span><span class=special>;
+
+ </span><span class=keyword>typedef
+ </span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>ReadGuard
+ </span><span class=identifier>ReadGuard_</span><span class=special>;
+
+ </span><span class=keyword>typedef
+ </span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>WriteGuard
+ </span><span class=identifier>WriteGuard_</span><span class=special>;
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=keyword>mutable </span><span class=identifier>count_t </span><span class=identifier>ref_count_</span><span class=special>;
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=keyword>mutable </span><span class=identifier>Mutex_ </span><span class=identifier>lock_</span><span class=special>;
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=comment>// Copy semanic is not supported.
+ </span><span class=identifier>DefaultImpl </span><span class=special>(</span><span class=identifier>DefaultImpl </span><span class=keyword>const</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=identifier>DefaultImpl</span><span class=special>&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>DefaultImpl </span><span class=keyword>const</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=special>};
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReferenceCounting/Interface.hpp.html b/contrib/utility/Documentation/ReferenceCounting/Interface.hpp.html
new file mode 100644
index 00000000000..f81c1dc737c
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/Interface.hpp.html
@@ -0,0 +1,82 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+Interface.hpp</title>
+<link rel="stylesheet" href="../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ReferenceCounting/Interface.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ReferenceCounting
+ </span><span class=special>{
+ </span><span class=comment>// Interface to a reference-countable object. Note that _remove_ref ()
+ // member function has a no-throw semantic. Even though it can lead to
+ // a diagnostic loss it was made no-throw because it has a destructor
+ // semantic.
+
+ </span><span class=keyword>class </span><span class=identifier>Interface
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>typedef
+ </span><span class=keyword>unsigned </span><span class=keyword>long
+ </span><span class=identifier>count_t</span><span class=special>;
+
+ </span><span class=keyword>typedef
+ </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>System</span><span class=special>::</span><span class=identifier>Exception
+ </span><span class=identifier>SystemException</span><span class=special>;
+
+ </span><span class=keyword>class </span><span class=identifier>Exception_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Compound</span><span class=special>&lt;</span><span class=identifier>Exception_</span><span class=special>, </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>DescriptiveException</span><span class=special>&gt;
+ </span><span class=identifier>Exception</span><span class=special>;
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>add_ref </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>) </span><span class=special>= </span><span class=number>0</span><span class=special>;
+
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>remove_ref </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>() </span><span class=special>= </span><span class=number>0</span><span class=special>;
+
+ </span><span class=keyword>virtual </span><span class=identifier>count_t
+ </span><span class=identifier>refcount_value </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>) </span><span class=special>= </span><span class=number>0</span><span class=special>;
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=identifier>Interface </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>virtual
+ </span><span class=special>~</span><span class=identifier>Interface </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>protected</span><span class=special>:
+ </span><span class=keyword>virtual </span><span class=keyword>void
+ </span><span class=identifier>add_ref_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>) </span><span class=special>= </span><span class=number>0</span><span class=special>;
+
+ </span><span class=keyword>virtual </span><span class=keyword>bool
+ </span><span class=identifier>remove_ref_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>) </span><span class=special>= </span><span class=number>0</span><span class=special>;
+
+ </span><span class=keyword>virtual </span><span class=identifier>count_t
+ </span><span class=identifier>refcount_value_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>) </span><span class=special>= </span><span class=number>0</span><span class=special>;
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=comment>// Copy semanic is not supported.
+ </span><span class=identifier>Interface </span><span class=special>(</span><span class=identifier>Interface </span><span class=keyword>const</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=identifier>Interface</span><span class=special>&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>Interface </span><span class=keyword>const</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=special>};
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Type</span><span class=special>&gt;
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=identifier>add_ref </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReferenceCounting/Makefile b/contrib/utility/Documentation/ReferenceCounting/Makefile
new file mode 100644
index 00000000000..3202f185418
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/Makefile
@@ -0,0 +1,22 @@
+# file : Documentation/ReferenceCounting/Make.doc.mk
+# 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/Documentation.pre.rules)
+
+vpath %.hpp $(root)/Utility/ReferenceCounting
+
+doc_translation_units := DefaultImpl.hpp \
+ Interface.hpp \
+ SmartPtr.hpp \
+ StrictPtr.hpp
+
+DOC_FLAGS := --strip-preprocessor -css $(root)/Documentation/Style/CXX.css
+
+$(call include, $(root)/BuildRules/Documentation.post.rules)
+# $Id$
diff --git a/contrib/utility/Documentation/ReferenceCounting/News.xhtml b/contrib/utility/Documentation/ReferenceCounting/News.xhtml
new file mode 100644
index 00000000000..472a97e9e66
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/News.xhtml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/ReferenceCounting/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Reference Counting Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="news,C++,reference,counting,smart,pointer"/>
+ <meta name="description" content="Reference Counting Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>1.1.0</h1>
+<ul class="multiline">
+<li>New regression test coverage.</li>
+
+<li>
+<code>
+<a href="SmartPtr.hpp.html">Utility::ReferenceCounting::SmartPtr</a>
+</code>
+: added
+<pre class="cpp-code">
+template&lt;typename Other&gt;
+SmartPtr (SmartPtr&lt;Other&gt; const&amp;)
+</pre>
+and
+<pre class="cpp-code">
+template&lt;typename Other&gt;
+operator= (SmartPtr&lt;Other&gt; const&amp;)
+</pre>
+</li>
+
+<li>
+<code>
+<a href="SmartPtr.hpp.html">Utility::ReferenceCounting::SmartPtr</a>
+</code>
+: added
+<pre class="cpp-code">typedef T Type;</pre>
+in order to provide access to underlying type.
+</li>
+
+<li>
+<code><a href="index.xhtml">Utility::ReferenceCounting</a></code>
+: added
+<pre class="cpp-code">
+template &lt;typename D, typename S&gt;
+D*
+smart_cast (SmartPtr&lt;S&gt; const&amp;)
+</pre>
+to provide more convenient <code>dynamic_cast</code> functionality.
+</li>
+
+<li>
+<code><a href="index.xhtml">Utility::ReferenceCounting</a></code>
+: added
+<pre class="cpp-code">
+template &lt;typename T&gt;
+SmartPtr&lt;T&gt; acquire (T*)
+</pre>
+</li>
+
+<li>
+New
+<code>
+<a href="StrictPtr.hpp.html">Utility::ReferenceCounting::StrictPtr</a>
+</code>
+automatic pointer.
+</li>
+
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReferenceCounting/SmartPtr.hpp.html b/contrib/utility/Documentation/ReferenceCounting/SmartPtr.hpp.html
new file mode 100644
index 00000000000..a2ef9342441
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/SmartPtr.hpp.html
@@ -0,0 +1,103 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+SmartPtr.hpp</title>
+<link rel="stylesheet" href="../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ReferenceCounting/SmartPtr.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ReferenceCounting
+ </span><span class=special>{
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=keyword>class </span><span class=identifier>SmartPtr
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>typedef
+ </span><span class=identifier>T
+ </span><span class=identifier>Type</span><span class=special>;
+
+ </span><span class=keyword>class </span><span class=identifier>NotInitialized_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Compound</span><span class=special>&lt;</span><span class=identifier>NotInitialized_</span><span class=special>, </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>DescriptiveException</span><span class=special>&gt;
+ </span><span class=identifier>NotInitialized</span><span class=special>;
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=comment>// c-tor's
+
+ </span><span class=identifier>SmartPtr </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=identifier>SmartPtr </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=identifier>SmartPtr </span><span class=special>(</span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Other</span><span class=special>&gt;
+ </span><span class=identifier>SmartPtr </span><span class=special>(</span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Other</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=comment>// d-tor
+
+ </span><span class=special>~</span><span class=identifier>SmartPtr </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=comment>// assignment &amp; copy-assignment operators
+
+ </span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt;&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt;&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Other</span><span class=special>&gt;
+ </span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt;&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>Other</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=comment>//conversions
+
+ </span><span class=keyword>operator </span><span class=identifier>Type</span><span class=special>* </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=comment>// accessors
+
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=keyword>operator</span><span class=special>-&gt; </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>NotInitialized</span><span class=special>);
+
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=identifier>in </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=identifier>retn</span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr_</span><span class=special>;
+ </span><span class=special>};
+
+ </span><span class=comment>// Specialization of add_ref function for SmartPtr&lt;T&gt;
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=identifier>T</span><span class=special>*
+ </span><span class=identifier>add_ref </span><span class=special>(</span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+
+ </span><span class=comment>// Dynamic type conversion function for SmartPtr's
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>D</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>S</span><span class=special>&gt;
+ </span><span class=identifier>D</span><span class=special>*
+ </span><span class=identifier>smart_cast </span><span class=special>(</span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>S</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=comment>// Acquisition function
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=identifier>SmartPtr</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=identifier>acquire </span><span class=special>(</span><span class=identifier>T</span><span class=special>* </span><span class=identifier>ptr</span><span class=special>) </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReferenceCounting/StrictPtr.hpp.html b/contrib/utility/Documentation/ReferenceCounting/StrictPtr.hpp.html
new file mode 100644
index 00000000000..13211b6e3c7
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/StrictPtr.hpp.html
@@ -0,0 +1,107 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+StrictPtr.hpp</title>
+<link rel="stylesheet" href="../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/ReferenceCounting/StrictPtr.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>ReferenceCounting
+ </span><span class=special>{
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=keyword>class </span><span class=identifier>StrictPtr
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>typedef
+ </span><span class=identifier>T
+ </span><span class=identifier>Type</span><span class=special>;
+
+ </span><span class=keyword>class </span><span class=identifier>NotInitialized_ </span><span class=special>{};
+ </span><span class=keyword>typedef
+ </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Compound</span><span class=special>&lt;</span><span class=identifier>NotInitialized_</span><span class=special>, </span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Logic</span><span class=special>::</span><span class=identifier>DescriptiveException</span><span class=special>&gt;
+ </span><span class=identifier>NotInitialized</span><span class=special>;
+
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=comment>// c-tor's
+
+ </span><span class=identifier>StrictPtr </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>explicit
+ </span><span class=identifier>StrictPtr </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>StrictPtr </span><span class=special>(</span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Other</span><span class=special>&gt;
+ </span><span class=identifier>StrictPtr </span><span class=special>(</span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Other</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+ </span><span class=comment>// d-tor
+
+ </span><span class=special>~</span><span class=identifier>StrictPtr </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=comment>// assignment &amp; copy-assignment operators
+
+ </span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt;&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr</span><span class=special>) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt;&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>Other</span><span class=special>&gt;
+ </span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Type</span><span class=special>&gt;&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>Other</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s_ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=comment>// conversions
+
+ // Note: implicit conversion (operator Type* ()) is not supported.
+
+ // comparison
+
+ </span><span class=keyword>bool
+ </span><span class=keyword>operator</span><span class=special>== </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>other</span><span class=special>) </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>bool
+ </span><span class=keyword>operator</span><span class=special>!= </span><span class=special>(</span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>other</span><span class=special>) </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=comment>// accessors
+
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=keyword>operator</span><span class=special>-&gt; </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>NotInitialized</span><span class=special>);
+
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=identifier>in </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>Type</span><span class=special>*
+ </span><span class=identifier>retn</span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=identifier>Type</span><span class=special>* </span><span class=identifier>ptr_</span><span class=special>;
+ </span><span class=special>};
+
+ </span><span class=comment>// Specialization of add_ref function for StrictPtr&lt;T&gt;
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>T</span><span class=special>&gt;
+ </span><span class=identifier>T</span><span class=special>*
+ </span><span class=identifier>add_ref </span><span class=special>(</span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>ptr</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+
+ </span><span class=comment>// Dynamic type conversion function for StrictPtr's
+ </span><span class=keyword>template </span><span class=special>&lt;</span><span class=keyword>typename </span><span class=identifier>D</span><span class=special>, </span><span class=keyword>typename </span><span class=identifier>S</span><span class=special>&gt;
+ </span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>D</span><span class=special>&gt;
+ </span><span class=identifier>strict_cast </span><span class=special>(</span><span class=identifier>StrictPtr</span><span class=special>&lt;</span><span class=identifier>S</span><span class=special>&gt; </span><span class=keyword>const</span><span class=special>&amp; </span><span class=identifier>s</span><span class=special>)
+ </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>Interface</span><span class=special>::</span><span class=identifier>SystemException</span><span class=special>);
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReferenceCounting/index.xhtml b/contrib/utility/Documentation/ReferenceCounting/index.xhtml
new file mode 100644
index 00000000000..43ead969460
--- /dev/null
+++ b/contrib/utility/Documentation/ReferenceCounting/index.xhtml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/ReferenceCounting/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Reference Counting Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="C++,utility,reference,counting"/>
+ <meta name="description" content="Reference Counting Library"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>Reference Counting Library provides basic building blocks for
+reference-countable objects. Implementation is modeled after CORBA
+IDL-to-C++ mapping's reference-countable objects and significantly
+extended.</p>
+
+
+<h1>Definitions</h1>
+
+<p>Below are the definitions of the key classes:</p>
+
+<ul class="menu">
+ <li><a href="Interface.hpp.html">ReferenceCounting::Interface</a></li>
+ <li><a href="DefaultImpl.hpp.html">ReferenceCounting::DefaultImpl</a></li>
+ <li><a href="SmartPtr.hpp.html">ReferenceCounting::SmartPtr</a></li>
+ <li><a href="StrictPtr.hpp.html">ReferenceCounting::StrictPtr</a></li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/ReleaseProcess b/contrib/utility/Documentation/ReleaseProcess
new file mode 100644
index 00000000000..9b42a762902
--- /dev/null
+++ b/contrib/utility/Documentation/ReleaseProcess
@@ -0,0 +1,13 @@
+1) go thru '@@' in source code
+
+2) build & test with g++ and cxx
+
+3) update news pages
+
+4) spellcheck/tidy/validate all xhtml files
+
+5) copy Utility to Utility-x.y.z; make documentation
+
+6) go manually thru all documentation pages with lynx & gui ua
+
+$Id$
diff --git a/contrib/utility/Documentation/Style/CXX.css b/contrib/utility/Documentation/Style/CXX.css
new file mode 100644
index 00000000000..49bf0f34e51
--- /dev/null
+++ b/contrib/utility/Documentation/Style/CXX.css
@@ -0,0 +1,9 @@
+pre { BORDER-RIGHT: gray 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: gray 1pt solid; DISPLAY: block; PADDING-LEFT: 2pt; PADDING-BOTTOM: 2pt; MARGIN-LEFT: 32pt; BORDER-LEFT: gray 1pt solid; MARGIN-RIGHT: 32pt; PADDING-TOP: 2pt; BORDER-BOTTOM: gray 1pt solid; FONT-FAMILY: "Courier New", Courier, mono; background-color: #EEEEEE; font-size: small}
+.keyword { color: #000099}
+.identifier { }
+.comment { color: #990000}
+.special { color: #800040}
+.preprocessor { color: #006600}
+.string { color: #666666}
+.number { color: #666666}
+/* $Id$ */
diff --git a/contrib/utility/Documentation/Style/CXX_Blue.css b/contrib/utility/Documentation/Style/CXX_Blue.css
new file mode 100644
index 00000000000..52b58d54119
--- /dev/null
+++ b/contrib/utility/Documentation/Style/CXX_Blue.css
@@ -0,0 +1,25 @@
+pre {
+ BORDER-RIGHT: gray 1pt solid;
+ PADDING-RIGHT: 2pt;
+ BORDER-TOP: gray 1pt solid;
+ DISPLAY: block;
+ PADDING-LEFT: 2pt;
+ PADDING-BOTTOM: 2pt;
+ MARGIN-LEFT: 32pt;
+ BORDER-LEFT: gray 1pt solid;
+ MARGIN-RIGHT: 32pt;
+ PADDING-TOP: 2pt;
+ BORDER-BOTTOM: gray 1pt solid;
+ FONT-FAMILY: "Courier New", Courier, mono; background-color: #191970;
+ font-size: small
+}
+
+.keyword { font-weight: bold; color: #afeeee}
+.identifier { color: #98fb98 }
+.comment { color: #add8e6}
+.special { color: #bebebe}
+.preprocessor { color: #7fffd4}
+.string { color: #87cefa}
+.number { color: #bebebe}
+.literal { color: #FF0000}
+/* $Id$ */
diff --git a/contrib/utility/Documentation/Style/Default.css b/contrib/utility/Documentation/Style/Default.css
new file mode 100644
index 00000000000..2c90197f340
--- /dev/null
+++ b/contrib/utility/Documentation/Style/Default.css
@@ -0,0 +1,45 @@
+body {
+ font-family : sans-serif;
+
+ color : black;
+ background : white;
+
+ max-width : 40em;
+ padding : 2em 2em 2em 3em;
+ margin : 0;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-family : sans-serif;
+ font-weight : 500;
+}
+
+h1 { font-size : 170%; }
+h2 { font-size : 145%; }
+h3 { font-size : 125%; }
+h4 { font-size : 110%; }
+h5 { font-size : 106%; }
+h6 { font-size : 100%; }
+
+p.indent {
+ margin-left : 1.5em;
+}
+
+/* list of links */
+
+ul.menu {
+ list-style-type : none;
+}
+
+ul.menu li {
+ padding-top : 0.3em;
+ padding-bottom : 0.3em;
+}
+
+/* */
+
+ul.multiline li {
+ padding-top : 0.4em;
+ padding-bottom : 0.4em;
+}
+/* $Id$ */
diff --git a/contrib/utility/Documentation/Synch/Makefile b/contrib/utility/Documentation/Synch/Makefile
new file mode 100644
index 00000000000..a35e28b530d
--- /dev/null
+++ b/contrib/utility/Documentation/Synch/Makefile
@@ -0,0 +1,16 @@
+# file : Documentation/Synch/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 := Policy
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Documentation/Synch/News.xhtml b/contrib/utility/Documentation/Synch/News.xhtml
new file mode 100644
index 00000000000..f7bf4f01285
--- /dev/null
+++ b/contrib/utility/Documentation/Synch/News.xhtml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Synch/News.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Synchronization Library News</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="news,C++,synchronization,policy,thread"/>
+ <meta name="description" content="Synchronization Library News"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>1.1.0</h1>
+<ul class="multiline">
+ <li>New regression test coverage.</li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Synch/Policy/Makefile b/contrib/utility/Documentation/Synch/Policy/Makefile
new file mode 100644
index 00000000000..175d207b06e
--- /dev/null
+++ b/contrib/utility/Documentation/Synch/Policy/Makefile
@@ -0,0 +1,20 @@
+# file : Documentation/Synch/Policy/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/Documentation.pre.rules)
+
+vpath %.hpp $(root)/Utility/Synch/Policy
+
+doc_translation_units := Null.hpp
+
+DOC_FLAGS := --strip-preprocessor -css $(root)/Documentation/Style/CXX.css
+
+$(call include, $(root)/BuildRules/Documentation.post.rules)
+
+# $Id$
diff --git a/contrib/utility/Documentation/Synch/Policy/Null.hpp.html b/contrib/utility/Documentation/Synch/Policy/Null.hpp.html
new file mode 100644
index 00000000000..21173a5951b
--- /dev/null
+++ b/contrib/utility/Documentation/Synch/Policy/Null.hpp.html
@@ -0,0 +1,59 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
+<title>
+Null.hpp</title>
+<link rel="stylesheet" href="../../../Documentation/Style/CXX.css" type="text/css"></head>
+<body>
+<pre>
+<span class=comment>// file : Utility/Synch/Policy/Null.hpp
+// author : Boris Kolpackov &lt;boris@kolpackov.net&gt;
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+</span><span class=keyword>namespace </span><span class=identifier>Utility
+</span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>Synch
+ </span><span class=special>{
+ </span><span class=keyword>namespace </span><span class=identifier>Policy
+ </span><span class=special>{
+
+ </span><span class=keyword>class </span><span class=identifier>NullMutex
+ </span><span class=special>{
+ </span><span class=special>};
+
+ </span><span class=keyword>class </span><span class=identifier>NullGuard
+ </span><span class=special>{
+ </span><span class=keyword>public</span><span class=special>:
+ </span><span class=keyword>explicit
+ </span><span class=identifier>NullGuard </span><span class=special>(</span><span class=identifier>NullMutex</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=keyword>private</span><span class=special>:
+ </span><span class=identifier>NullGuard </span><span class=special>(</span><span class=identifier>NullGuard </span><span class=keyword>const</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+
+ </span><span class=identifier>NullGuard</span><span class=special>&amp;
+ </span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>NullGuard </span><span class=keyword>const</span><span class=special>&amp;) </span><span class=keyword>throw </span><span class=special>();
+ </span><span class=special>};
+
+ </span><span class=keyword>struct </span><span class=identifier>Null
+ </span><span class=special>{
+ </span><span class=keyword>typedef
+ </span><span class=identifier>NullMutex
+ </span><span class=identifier>Mutex</span><span class=special>;
+
+ </span><span class=keyword>typedef
+ </span><span class=identifier>NullGuard
+ </span><span class=identifier>ReadGuard</span><span class=special>;
+
+ </span><span class=keyword>typedef
+ </span><span class=identifier>NullGuard
+ </span><span class=identifier>WriteGuard</span><span class=special>;
+ </span><span class=special>};
+ </span><span class=special>}
+ </span><span class=special>}
+</span><span class=special>}
+
+</span></pre>
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Synch/index.xhtml b/contrib/utility/Documentation/Synch/index.xhtml
new file mode 100644
index 00000000000..dd4a685ccc0
--- /dev/null
+++ b/contrib/utility/Documentation/Synch/index.xhtml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/Synch/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Synchronization Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="C++,utility,thread,synchronization,policy"/>
+ <meta name="description" content="Synchronization Library"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+
+<p>
+Synchronization library provides a compile-time policy-based configurable
+facility of selecting synchronization mechanisms. For now there is only
+no-op synchronization policy provided which is suitable only for
+single-threaded applications. However it shouldn't be difficult to provide
+a wrapper policy for synchronization mechanisms used in a particular project.
+</p>
+
+<h1>Definitions</h1>
+<p>Below are the definitions of the key classes:</p>
+
+<ul class="menu">
+ <li><a href="Policy/Null.hpp.html">Synch::Policy::Null</a></li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/TODO b/contrib/utility/Documentation/TODO
new file mode 100644
index 00000000000..984a0cddb56
--- /dev/null
+++ b/contrib/utility/Documentation/TODO
@@ -0,0 +1,53 @@
+
+New features/changes
+---------------------------------------------------------------------------
+
+@@ DefaultImpl<> looks ugly. Is there a way to just write DefaultImpl
+ (or, perhaps some other name)? Maybe also rename Interface to Object
+ (will be consistent with Introspection::Object).
+
+@@ Abort facility
+
+@@ Maybe rename converter to convert
+
+@@ Maybe make reference counting object implement Introspection. However it
+ will introduce inter-library dependency. Nop, this is a bad idea.
+
+@@ Maybe move <library>.hpp one level up to Utility/.
+
+@@ Go thru C++Templates chapter on RefCounting and SmartPointers and see if
+ anything can be applied?
+
+@@ Examples for many features are missing
+
+@@ Introspection::TypeInfo should use set instead of vector for bases.
+
+
+Documentation
+---------------------------------------------------------------------------
+
+@@ code in <pre> does not look nice in lynx (see Hetero/index.html for example)
+
+
+Building environment
+---------------------------------------------------------------------------
+
+@@ Should probably make lib rules to build library when target is test (try to
+ run 'make clean && make test' from Utility root).
+
+@@ Makefile variable names inconsistency (e.g. cxx_translation_units and CXX_PREPROCESS_FLAGS)
+
+%% Rename Config to Build or rather BuildRules?
+
+@@ Compiler-specific stuff is left after make clean. Potentially dangerous
+ idea would be to remove everything except known files
+
+@@ Multi-compiler configuration
+
+@@ Building library with sources in sub-directories.
+
+
+Pre-release fixes
+---------------------------------------------------------------------------
+
+$Id$
diff --git a/contrib/utility/Documentation/Template.xhtml b/contrib/utility/Documentation/Template.xhtml
new file mode 100644
index 00000000000..41c9857dabf
--- /dev/null
+++ b/contrib/utility/Documentation/Template.xhtml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>@@</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="@@"/>
+ <meta name="description" content="@@"/>
+
+ <link rel="stylesheet" type="text/css" href="../Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>@@</h1>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Documentation/Thoughts/Enum/EnumCount b/contrib/utility/Documentation/Thoughts/Enum/EnumCount
new file mode 100644
index 00000000000..be8b252d4de
--- /dev/null
+++ b/contrib/utility/Documentation/Thoughts/Enum/EnumCount
@@ -0,0 +1,95 @@
+From: Gianni Mariani <gi2nospam@mariani.ws>
+Date: 26 Jul 2003 04:52:43 GMT
+Newsgroups: comp.lang.c++
+Subject: Re: enum count
+
+Clive wrote:
+> If you have an enum, is there any way during execution to find the number of
+> values in the enum?
+> Say I have,
+>
+> enum great { five, ten, fifteen };
+>
+> How could I get the number 3 from that?
+>
+>
+
+replace the enums with objects that report themselves to a registry.
+
+
+I have done it in the past using a template ...
+
+templace <typename base>
+class ExposedEnum : public base
+{
+ public:
+ int enum_val;
+ ExposedEnum( int number )
+ : enum_val( number )
+ {
+ ExposedEnumRegister<base>::Register( *this );
+ }
+
+ ExposedEnum( int number )
+ : enum_val( ExposedEnumRegister<base>::GetNextNumber() )
+ {
+ ExposedEnumRegister<base>::Register( *this );
+ }
+
+
+
+// some more stuff ...
+
+ operator int () const
+ {
+ return enum_val;
+ }
+
+ explicit ExposedEnum( const ExposedEnum & foo );
+};
+
+
+template <typename base>
+class ExposedEnumRegister
+{
+
+ static int GetNextNumber ....
+
+ static void Register ....
+
+ static int Count ....
+
+}
+
+
+Now you can forward declare them...
+
+extern ExposedEnum< great > five;
+
+extern ExposedEnum< great > ten;
+
+extern ExposedEnum< great > fifteen;
+
+
+
+
+In a cpp file you can instantiate them.
+
+ExposedEnum< great > five( 5 );
+
+ExposedEnum< great > ten( 10 );
+
+ExposedEnum< great > fifteen;
+
+
+Now, if you want to know how many you have :
+
+ExposedEnumRegister< great >::Count();
+
+
+
+Disclaimer - it's an outline only, yes it's incomplete.
+
+G
+
+$Id$
diff --git a/contrib/utility/Documentation/Thoughts/Enum/EnumCount2 b/contrib/utility/Documentation/Thoughts/Enum/EnumCount2
new file mode 100644
index 00000000000..d23e790b6d4
--- /dev/null
+++ b/contrib/utility/Documentation/Thoughts/Enum/EnumCount2
@@ -0,0 +1,17 @@
+From: Alexander Terekhov <terekhov@web.de>
+Date: Sat, 26 Jul 2003 19:17:52 +0200
+Newsgroups: comp.lang.c++
+Subject: Re: enum count
+
+
+Steve Pinard wrote:
+>
+> Wouldn't that be nice? And wouldn't it be nice to be able to get the
+> strings "five", "ten", and "fifteen" too?
+
+http://lcgapp.cern.ch/project/architecture/XTI_accu.pdf
+
+regards,
+alexander.
+
+$Id$
diff --git a/contrib/utility/Documentation/Thoughts/Enum/EnumInfo b/contrib/utility/Documentation/Thoughts/Enum/EnumInfo
new file mode 100644
index 00000000000..e59a27c0820
--- /dev/null
+++ b/contrib/utility/Documentation/Thoughts/Enum/EnumInfo
@@ -0,0 +1,45 @@
+From: "Klaus Eichner" <klaus_gb@yahoo.com>
+Date: Sat, 26 Jul 2003 14:53:23 +0100
+Newsgroups: comp.lang.c++
+Subject: Re: enum count
+
+"Clive" <clive@clive.clive> wrote in message
+news:3f21e5cc$0$23611$5a62ac22@freenews.iinet.net.au...
+> If you have an enum, is there any way during execution to find the number
+of
+> values in the enum?
+> Say I have,
+>
+> enum great { five, ten, fifteen };
+>
+> How could I get the number 3 from that?
+
+You could get the number 3 from 'great' with your own, user-defined
+'Enum_Info' template:
+
+cout << "The number of values in enum great is "
+ << Enum_Info<great>::number_of_elements
+ << endl;
+
+The 'Enum_Info' template is defined as follows.
+Suppose you have the following enums:
+
+enum great { five, ten, fifteen };
+enum greater { none, one, fourtytwo, fourtythree, fourtyfour };
+enum even_greater { minusone, minustwo, minusthree, minusfour, minusfive,
+minussix, minusseven };
+
+You could build a template class 'Enum_Info' which uses specialisation to
+register the number of elements in each enum
+
+template <class T> class Enum_Info { };
+template <> class Enum_Info<great> { static const int number_of_elements =
+3; };
+template <> class Enum_Info<greater> { static const int number_of_elements =
+5; };
+template <> class Enum_Info<even_greater> { static const int
+number_of_elements = 7; };
+
+
+
+$Id$
diff --git a/contrib/utility/Documentation/index.xhtml b/contrib/utility/Documentation/index.xhtml
new file mode 100644
index 00000000000..87e82d228dc
--- /dev/null
+++ b/contrib/utility/Documentation/index.xhtml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<!--
+
+file : Documentation/index.xhtml
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2002-2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<head>
+
+ <title>Utility Library</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="C++,utility,exception,handling,model,reference,counting,thread,synchronization"/>
+ <meta name="description" content="Utility Library"/>
+
+ <link rel="stylesheet" type="text/css" href="Style/Default.css"/>
+
+</head>
+
+<body>
+
+<h1>Introduction</h1>
+<p>
+Utility library is a place for generic C++ facilities that I found useful
+in more than one project.
+
+Here you can download the
+<a href="http://kolpackov.net/projects/Utility/Download.xhtml">
+latest version</a>.
+
+Utility library is a
+<a href="http://gnu.org/philosophy/categories.html#Non-CopyleftedFreeSoftware">
+non-copylefted free software</a> with zlib-like
+<a href="http://kolpackov.net/license.html">license</a>.
+
+For changes and new features check out <a href="News.xhtml">News section</a>.
+</p>
+
+<h1>Supported Platforms</h1>
+
+<p>
+For the time being I test Utility library with at least GNU G++ on Linux and
+Compaq (Digital) C++ (-std strict_ansi) on Tru64 UNIX. It also should compile
+and work fine with any decent C++ compiler. Also note that I don't have any
+plans to bloat source code in attempt to support broken compilers.</p>
+
+<h1>Building</h1>
+
+<p>
+Utility library mostly consists of header-only sub-libraries so you don't
+actually need to build anything to start using it. See <a href="Build.xhtml">
+Building Utility Library</a> section for more information.</p>
+
+<h1>Content</h1>
+
+<p>Utility Library consists of the following sub-libraries:</p>
+
+<ul class="menu">
+ <li><a href="CommandLine/index.xhtml">Command Line Processing</a></li>
+
+ <li><a href="ExH/index.xhtml">Exception Handling</a></li>
+
+ <li><a href="Hetero/index.xhtml">Heterogeneous Container</a></li>
+
+ <li><a href="Introspection/index.xhtml">Introspection</a></li>
+
+ <li><a href="ReferenceCounting/index.xhtml">Reference Counting</a></li>
+
+ <li><a href="Synch/index.xhtml">Synchronization</a></li>
+</ul>
+
+</body>
+</html>
+<!-- $Id$ -->
diff --git a/contrib/utility/Example/CommandLine/Foo/command.cpp b/contrib/utility/Example/CommandLine/Foo/command.cpp
new file mode 100644
index 00000000000..50b78a15350
--- /dev/null
+++ b/contrib/utility/Example/CommandLine/Foo/command.cpp
@@ -0,0 +1,86 @@
+#include <string>
+#include <iostream>
+
+using std::cerr;
+using std::endl;
+
+class Command
+{
+public:
+ enum Value
+ {
+ HELP = 0,
+ VERSION,
+ DEFAULT
+ };
+
+ Command (Value v = Command::DEFAULT)
+ : v_ (v)
+ {
+ }
+
+ operator Value () const
+ {
+ return v_;
+ }
+
+ friend std::ostream&
+ operator<< (std::ostream& os, Command c);
+
+ friend std::istream&
+ operator>> (std::istream& is, Command& c);
+
+private:
+ Value v_;
+ static char* labels_[];
+};
+
+char* Command::labels_[] = {"help", "version", "default"};
+
+
+std::ostream&
+operator<< (std::ostream& os, Command c)
+{
+ return os << Command::labels_[c.v_];
+}
+
+std::istream&
+operator>> (std::istream& is, Command& c)
+{
+ std::string s;
+ is >> s;
+ if (is)
+ {
+ if (s == Command::labels_[Command::HELP]) c.v_ = Command::HELP;
+ else if (s == Command::labels_[Command::VERSION]) c.v_ = Command::VERSION;
+ else is.setstate (std::ios::failbit);
+ }
+ return is;
+}
+
+int
+main ()
+{
+ Command c = Command::HELP;
+
+ c = Command::DEFAULT;
+
+ Command c1 (Command::HELP);
+
+ c = c1;
+
+ cerr << c << endl;
+
+ switch (c)
+ {
+ case Command::HELP:
+ {
+ cerr << "iiihuuu!!!" << endl;
+ }
+ }
+
+ std::cin >> c1;
+ if (std::cin) cerr << c1 << endl;
+ else cerr << "*failed" << endl;
+}
+//$Id$
diff --git a/contrib/utility/Example/CommandLine/Foo/foo.cpp b/contrib/utility/Example/CommandLine/Foo/foo.cpp
new file mode 100644
index 00000000000..a389f8d822a
--- /dev/null
+++ b/contrib/utility/Example/CommandLine/Foo/foo.cpp
@@ -0,0 +1,183 @@
+#include <typeinfo>
+#include <string>
+#include <iostream>
+
+
+namespace CommandLine
+{
+ struct Parser
+ {
+ };
+}
+
+using std::string;
+using std::cerr;
+using std::endl;
+
+using namespace CommandLine;
+
+class Command
+{
+public:
+ enum Value
+ {
+ HELP,
+ VERSION,
+ DEFAULT
+ };
+
+ Command (Value v = Command::DEFAULT)
+ : v_ (v)
+ {
+ }
+
+ operator Value () const
+ {
+ return v_;
+ }
+
+private:
+ Value v_;
+};
+
+
+int
+version ();
+
+int
+help (int argc, char* argv[]);
+
+int
+main (int argc, char* argv[])
+{
+
+ // Step 1: determine command
+ //
+ // * there is usually one command
+ // * command can be optional
+ // * command usually takes up one argument
+ //
+
+ CommandParser<Command> cp;
+
+ switch (cp.parse (argc, argv))
+ {
+ case Command::VERSION:
+ {
+ return version ();
+ }
+ case Command::HELP:
+ {
+ return help (argc, argv);
+ }
+ }
+
+ // Step 2: parse options
+ //
+ // * options are usually optional
+ // * options are usually position-independant
+ // * options usually do not repeat
+ // * options can take up more than one argument
+ //
+
+ OptionMap om;
+
+ CompositeParser op;
+
+ op.add (OptionParser<string> ("string", "--string", "-s"));
+ op.add (OptionParser<unsigned long> ("number", "--number", "-n"));
+
+ while (argc != 1 && !op.empty ())
+ {
+ om.insert (op.parse (argc, argv));
+ }
+
+ // Step 3: parse operands
+ //
+ // * operands usually position-dependant
+ // * operand usually take up one argument
+ //
+
+ OperandParser<string> odp;
+
+ string str = odp.parse (argc, argv);
+
+ unsigned long num = 0;
+
+ if (argc != 1)
+ {
+ OperandParser<unsigned long> op;
+ num = op.parse (argc, argv);
+ }
+
+ string s = om.count ("string") ? om["string"] : "default";
+ unsigned long l = om["number"];
+
+ // om.at ()
+ // om.get ()
+ // om.resolve ()
+ // om.option ()
+ // om.value ()
+
+ cerr << "opreation settings are:" << endl << endl
+ << "option string : " << om.get<string> ("string", "default") << endl
+ << "option number : " << om.get ("number", 10UL) << endl
+ << "operand string : " << str << endl
+ << "operand number : " << num << endl;
+}
+
+
+//
+//
+//
+int
+version ()
+{
+ cerr << "foo 1.0" << endl;
+ return 0;
+}
+
+
+//
+//
+//
+int
+help (int argc, char* argv[])
+{
+ Command subject;
+
+ if (argc != 1)
+ {
+ OperandParser<Command> op;
+ subject = op.parse (argc, argv);
+ }
+
+ switch (subject)
+ {
+ case Command::HELP:
+ {
+ cerr << "foo help [<command>]" << endl << endl
+ << "\t If <command> is specified then print extended help" << endl
+ << "\t information for specified command. Otherwise print" << endl
+ << "\t general usage information." << endl;
+ break;
+ }
+ case Command::VERSION:
+ {
+ cerr << "foo version" << endl << endl
+ << "\t Print version information." << endl;
+ break;
+ }
+ default:
+ {
+ cerr << "foo version" << endl
+ << "foo help [<command>]" << endl
+ << "foo [-s|--string <str>] [-n|--number <num>] <str> [<num>]"
+ << endl;
+ break;
+ }
+ }
+
+ return 0;
+}
+//$Id$
diff --git a/contrib/utility/Example/ExH/BadCast/Makefile b/contrib/utility/Example/ExH/BadCast/Makefile
new file mode 100644
index 00000000000..9963d9708a1
--- /dev/null
+++ b/contrib/utility/Example/ExH/BadCast/Makefile
@@ -0,0 +1,24 @@
+# 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/contrib/utility/Example/ExH/BadCast/bad_cast.cpp b/contrib/utility/Example/ExH/BadCast/bad_cast.cpp
new file mode 100644
index 00000000000..cb4a59e26a9
--- /dev/null
+++ b/contrib/utility/Example/ExH/BadCast/bad_cast.cpp
@@ -0,0 +1,52 @@
+// 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
+
+#include "Utility/ExH/System/Exception.hpp"
+
+#include <iostream>
+
+using std::cerr;
+using std::endl;
+
+
+struct A
+{
+ virtual
+ ~A() {}
+};
+
+struct B
+{
+ void
+ foo () {}
+};
+
+void
+foo () throw (Utility::ExH::System::Exception)
+{
+ 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/contrib/utility/Example/ExH/Compound/Makefile b/contrib/utility/Example/ExH/Compound/Makefile
new file mode 100644
index 00000000000..8bd588587d5
--- /dev/null
+++ b/contrib/utility/Example/ExH/Compound/Makefile
@@ -0,0 +1,24 @@
+# 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/contrib/utility/Example/ExH/Compound/compound.cpp b/contrib/utility/Example/ExH/Compound/compound.cpp
new file mode 100644
index 00000000000..9e042ca9c1e
--- /dev/null
+++ b/contrib/utility/Example/ExH/Compound/compound.cpp
@@ -0,0 +1,142 @@
+// 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
+
+#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) throw (InvalidArgument, NotInitialized)
+ {
+ // 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 () throw (Exception, System::Exception) = 0;
+};
+
+class Derived : public Base
+{
+public:
+
+ // Define some Derived-specific logic exception.
+ class NotImplemented_ {};
+ typedef
+ Compound <NotImplemented_, Exception>
+ NotImplemented;
+
+public:
+ virtual void
+ vfoo () throw (NotImplemented, System::Exception)
+ {
+ 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/contrib/utility/Example/ExH/HelloWorld/Makefile b/contrib/utility/Example/ExH/HelloWorld/Makefile
new file mode 100644
index 00000000000..93debef0e7c
--- /dev/null
+++ b/contrib/utility/Example/ExH/HelloWorld/Makefile
@@ -0,0 +1,24 @@
+# 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/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp b/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp
new file mode 100644
index 00000000000..ee678ffa66f
--- /dev/null
+++ b/contrib/utility/Example/ExH/HelloWorld/hello_world.cpp
@@ -0,0 +1,141 @@
+// 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
+
+#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 () throw (ExH::System::Exception)
+ : // The std::string c-tor may throw any kind of exceptions besides
+ // quite possible std::bad_alloc.
+ greeting_ ("Hello, world!")
+ {
+ }
+
+ Application (char const * greeting) throw (InvalidArg,
+ ExH::System::Exception)
+ : greeting_ (greeting == 0 ? "" : greeting)
+ {
+ if (greeting == 0) throw InvalidArg ();
+ }
+
+public:
+
+ void
+ run () throw (FeelingDizzy, ExH::System::Exception)
+ {
+ 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/contrib/utility/Example/ExH/LogicToSystem/Makefile b/contrib/utility/Example/ExH/LogicToSystem/Makefile
new file mode 100644
index 00000000000..789413c0a3c
--- /dev/null
+++ b/contrib/utility/Example/ExH/LogicToSystem/Makefile
@@ -0,0 +1,24 @@
+# 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/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp b/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
new file mode 100644
index 00000000000..ba5944404f0
--- /dev/null
+++ b/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
@@ -0,0 +1,58 @@
+// 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
+
+#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)
+ {
+ throw Exception ();
+ }
+};
+
+
+struct SubsystemB
+{
+ void
+ foo () throw (Utility::ExH::System::Exception)
+ {
+ 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/contrib/utility/Example/ExH/Makefile b/contrib/utility/Example/ExH/Makefile
new file mode 100644
index 00000000000..99eb95cf62f
--- /dev/null
+++ b/contrib/utility/Example/ExH/Makefile
@@ -0,0 +1,16 @@
+# 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$
diff --git a/contrib/utility/Example/Hetero/Container/Makefile b/contrib/utility/Example/Hetero/Container/Makefile
new file mode 100644
index 00000000000..29135f54046
--- /dev/null
+++ b/contrib/utility/Example/Hetero/Container/Makefile
@@ -0,0 +1,24 @@
+# file : Example/Hetero/Container/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 := container.cpp
+
+module_base := container
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Example/Hetero/Container/container.cpp b/contrib/utility/Example/Hetero/Container/container.cpp
new file mode 100644
index 00000000000..f6ba5560dda
--- /dev/null
+++ b/contrib/utility/Example/Hetero/Container/container.cpp
@@ -0,0 +1,110 @@
+// file : Example/Hetero/Container/container.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/Hetero/Container.hpp"
+#include "Utility/Hetero/TypedContainer.hpp"
+#include "Utility/Hetero/Vector.hpp"
+#include "Utility/Hetero/Shell.hpp"
+
+#include <string>
+#include <iostream>
+#include <algorithm>
+
+using std::string;
+
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace Hetero = Utility::Hetero;
+
+using Hetero::Container;
+using Hetero::TypedContainer;
+using Hetero::TypeList;
+using Hetero::Shell;
+
+
+struct PrintCore
+{
+ typedef void RetType;
+
+ template <typename T>
+ void
+ operator() (T const& t)
+ {
+ cout << t << endl;
+ }
+};
+
+typedef Shell<PrintCore> Print;
+
+void
+print (bool b)
+{
+ cout << (b ? "T" : "NIL") << endl;
+}
+
+int
+main ()
+{
+ try
+ {
+ Container a (10L);
+ Container b (true);
+ Container c (string ("hello"));
+
+ string s = c + string (" world");
+
+ long l = a + 20L;
+
+ cout << s << "; " << l << endl;
+
+ print (b);
+
+ //
+ //
+ //
+
+ typedef
+ TypedContainer <TypeList<long, bool, string> >
+ MyContainer;
+
+ MyContainer x (true);
+ MyContainer y (10L);
+ MyContainer z (string ("hey dude"));
+
+ Print print;
+
+ print (x);
+ print (y);
+ print (z);
+
+ //
+ //
+ //
+
+ typedef
+ Hetero::Vector<long, bool, string>
+ vector;
+
+ vector v;
+ v.push_back (10L);
+ v.push_back (true);
+ v.push_back (false);
+ v.push_back (string ("hey"));
+
+ for (vector::iterator i = v.begin (); i != v.end (); i++)
+ {
+ print (*i);
+ }
+
+ std::for_each (v.begin (), v.end (), print);
+ }
+ catch (Hetero::Typing const&)
+ {
+ cerr << "typing error" << endl;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Example/Hetero/Makefile b/contrib/utility/Example/Hetero/Makefile
new file mode 100644
index 00000000000..a55938e9502
--- /dev/null
+++ b/contrib/utility/Example/Hetero/Makefile
@@ -0,0 +1,16 @@
+# file : Example/Hetero/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 := Container
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp b/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp
new file mode 100644
index 00000000000..0dbc616483e
--- /dev/null
+++ b/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.cpp
@@ -0,0 +1,104 @@
+// file : Hierarchy.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Hierarchy.hpp"
+
+// A
+//
+//
+
+using Introspection::Object;
+using Introspection::Access;
+
+namespace
+{
+ TypeInfo
+ a_init_ ()
+ {
+ TypeInfo ti (typeid (A));
+ ti.add_base (Access::PUBLIC, true, Object::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo a_ (a_init_ ());
+}
+
+TypeInfo const& A::
+static_type_info ()
+{
+ return a_;
+}
+
+// B
+//
+//
+
+namespace
+{
+ TypeInfo
+ b_init_ ()
+ {
+ TypeInfo ti (typeid (B));
+ ti.add_base (Access::PUBLIC, false, A::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo b_ (b_init_ ());
+}
+
+TypeInfo const& B::
+static_type_info ()
+{
+ return b_;
+}
+
+// C
+//
+//
+
+namespace
+{
+ TypeInfo
+ c_init_ ()
+ {
+ TypeInfo ti (typeid (C));
+ ti.add_base (Access::PUBLIC, true, A::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo c_ (c_init_ ());
+}
+
+TypeInfo const& C::
+static_type_info ()
+{
+ return c_;
+}
+
+
+// D
+//
+//
+
+namespace
+{
+ TypeInfo
+ d_init_ ()
+ {
+ TypeInfo ti (typeid (D));
+ ti.add_base (Access::PUBLIC, true, B::static_type_info ());
+ ti.add_base (Access::PUBLIC, false, C::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo d_ (d_init_ ());
+}
+
+TypeInfo const& D::
+static_type_info ()
+{
+ return d_;
+}
+//$Id$
diff --git a/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp b/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp
new file mode 100644
index 00000000000..213e0593f6b
--- /dev/null
+++ b/contrib/utility/Example/Introspection/InheritanceTree/Hierarchy.hpp
@@ -0,0 +1,61 @@
+// file : Example/Introspection/InheritanceTree/Hierarchy.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef HIERARCHY_HPP
+#define HIERARCHY_HPP
+
+#include "Utility/Introspection/Introspection.hpp"
+
+namespace Introspection = Utility::Introspection;
+
+using Introspection::TypeInfo;
+using Introspection::TypeId;
+
+struct A : virtual Introspection::Object
+{
+ A ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static TypeInfo const&
+ static_type_info ();
+};
+
+struct B : virtual A
+{
+ B ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static TypeInfo const&
+ static_type_info ();
+};
+
+struct C : virtual A
+{
+ C ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static TypeInfo const&
+ static_type_info ();
+};
+
+struct D : virtual B, C
+{
+ D ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static TypeInfo const&
+ static_type_info ();
+};
+
+#endif // HIERARCHY_HPP
+//$Id$
diff --git a/contrib/utility/Example/Introspection/InheritanceTree/Makefile b/contrib/utility/Example/Introspection/InheritanceTree/Makefile
new file mode 100644
index 00000000000..9b839c2111f
--- /dev/null
+++ b/contrib/utility/Example/Introspection/InheritanceTree/Makefile
@@ -0,0 +1,22 @@
+# file : Example/Introspection/InheritanceTree/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 := Hierarchy.cpp inheritance_tree.cpp
+
+module_base := inheritance_tree
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+CXX_LINK_LIBS += -L$(root)/Utility/Introspection -lIntrospection
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp b/contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp
new file mode 100644
index 00000000000..97c4c68dda6
--- /dev/null
+++ b/contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp
@@ -0,0 +1,64 @@
+// file : Example/Introspection/InheritanceTree/inheritance_tree.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+// Note: This example is by no means complete. In fact properly printing
+// arbitrary C++ inheritance tree is a non-trivial task. If you would like
+// to improve this example please feel free to send your results back ;-).
+//
+
+#include "Hierarchy.hpp"
+
+#include <set>
+#include <iostream>
+
+using std::endl;
+
+typedef
+std::set<TypeId>
+TypeIdSet;
+
+void
+print_inheritance_tree_core (std::ostream& os,
+ TypeInfo const& ti,
+ TypeIdSet& set)
+{
+ bool nl = false;
+
+ for (TypeInfo::BaseIterator i = ti.begin_base ();
+ i != ti.end_base ();
+ i++)
+ {
+ TypeId tid (i->type_info ().type_id ());
+
+ if (set.find (tid) != set.end ()) continue;
+
+ nl = true;
+ set.insert (tid);
+ print_inheritance_tree_core (os, i->type_info (), set);
+ }
+
+ if (nl) os << endl;
+
+ os << ti.type_id () << " ";
+}
+
+void
+print_inheritance_tree (std::ostream& os, TypeInfo const& ti)
+{
+ TypeIdSet set;
+ print_inheritance_tree_core (os, ti, set);
+ os << endl;
+}
+
+int
+main ()
+{
+ B* b = new D;
+
+ print_inheritance_tree (std::cout, b->type_info ());
+
+ delete b;
+}
+//$Id$
diff --git a/contrib/utility/Example/Introspection/Makefile b/contrib/utility/Example/Introspection/Makefile
new file mode 100644
index 00000000000..2dc0a1f809e
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Makefile
@@ -0,0 +1,16 @@
+# file : Example/Introspection/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 := InheritanceTree Traversal
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Example/Introspection/Traversal/Makefile b/contrib/utility/Example/Introspection/Traversal/Makefile
new file mode 100644
index 00000000000..c9b1a8da46a
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Traversal/Makefile
@@ -0,0 +1,22 @@
+# file : Example/Introspection/Traversal/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 := SyntaxTree.cpp Traversal.cpp driver.cpp
+
+module_base := driver
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+CXX_LINK_LIBS += -L$(root)/Utility/Introspection -lIntrospection
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp b/contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp
new file mode 100644
index 00000000000..71115ff2b24
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Traversal/SyntaxTree.cpp
@@ -0,0 +1,119 @@
+// file : Example/Introspection/Traversal/SyntaxTree.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "SyntaxTree.hpp"
+
+using namespace Utility::Introspection;
+
+namespace SyntaxTree
+{
+
+ // Node
+ //
+ //
+
+ namespace
+ {
+ TypeInfo
+ node_init_ ()
+ {
+ TypeInfo ti (typeid (Node));
+ ti.add_base (Access::PUBLIC, true, Object::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo node_ (node_init_ ());
+ }
+
+ TypeInfo const& Node::
+ static_type_info () { return node_; }
+
+
+ // Declaration
+ //
+ //
+
+ namespace
+ {
+ TypeInfo
+ declaration_init_ ()
+ {
+ TypeInfo ti (typeid (Declaration));
+ ti.add_base (Access::PUBLIC, true, Node::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo declaration_ (declaration_init_ ());
+ }
+
+ TypeInfo const& Declaration::
+ static_type_info () { return declaration_; }
+
+
+ // Scope
+ //
+ //
+
+ namespace
+ {
+ TypeInfo
+ scope_init_ ()
+ {
+ TypeInfo ti (typeid (Scope));
+ ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo scope_ (scope_init_ ());
+ }
+
+ TypeInfo const& Scope::
+ static_type_info () { return scope_; }
+
+
+ // InterfaceDecl
+ //
+ //
+
+ namespace
+ {
+ TypeInfo
+ interface_decl_init_ ()
+ {
+ TypeInfo ti (typeid (InterfaceDecl));
+ ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo interface_decl_ (interface_decl_init_ ());
+ }
+
+ TypeInfo const& InterfaceDecl::
+ static_type_info () { return interface_decl_; }
+
+
+ // InterfaceDef
+ //
+ //
+
+ namespace
+ {
+ TypeInfo
+ interface_def_init_ ()
+ {
+ TypeInfo ti (typeid (InterfaceDef));
+ ti.add_base (Access::PUBLIC, true, InterfaceDecl::static_type_info ());
+ ti.add_base (Access::PUBLIC, true, Scope::static_type_info ());
+ return ti;
+ }
+
+ TypeInfo interface_def_ (interface_def_init_ ());
+ }
+
+ TypeInfo const& InterfaceDef::
+ static_type_info () { return interface_def_; }
+
+}
+//$Id$
diff --git a/contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp b/contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp
new file mode 100644
index 00000000000..7bd824ce683
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Traversal/SyntaxTree.hpp
@@ -0,0 +1,95 @@
+// file : Example/Introspection/Traversal/SyntaxTree.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef SYNTAX_TREE_HPP
+#define SYNTAX_TREE_HPP
+
+#include <vector>
+
+#include "Utility/Introspection/Introspection.hpp"
+
+namespace SyntaxTree
+{
+ //
+ //
+ //
+
+ struct Node : virtual Utility::Introspection::Object
+ {
+ Node ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static Utility::Introspection::TypeInfo const&
+ static_type_info ();
+ };
+
+ //
+ //
+ //
+
+ struct Declaration : virtual Node
+ {
+ Declaration ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static Utility::Introspection::TypeInfo const&
+ static_type_info ();
+ };
+
+ typedef
+ std::vector<Declaration*>
+ DeclarationList;
+
+ //
+ //
+ //
+ struct Scope : virtual Declaration
+ {
+ Scope ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static Utility::Introspection::TypeInfo const&
+ static_type_info ();
+
+ DeclarationList content_;
+ };
+
+ //
+ //
+ //
+ struct InterfaceDecl : virtual Declaration
+ {
+ InterfaceDecl ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static Utility::Introspection::TypeInfo const&
+ static_type_info ();
+ };
+
+ //
+ //
+ //
+ struct InterfaceDef : virtual InterfaceDecl, virtual Scope
+ {
+ InterfaceDef ()
+ {
+ type_info (static_type_info ());
+ }
+
+ static Utility::Introspection::TypeInfo const&
+ static_type_info ();
+ };
+}
+
+#endif // SYNTAX_TREE_HPP
+//$Id$
diff --git a/contrib/utility/Example/Introspection/Traversal/Traversal.cpp b/contrib/utility/Example/Introspection/Traversal/Traversal.cpp
new file mode 100644
index 00000000000..9fa94327c2c
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Traversal/Traversal.cpp
@@ -0,0 +1,105 @@
+// file : Example/Introspection/Traversal/Traversal.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Traversal.hpp"
+
+#include <set>
+#include <map>
+
+using namespace Utility::Introspection;
+
+namespace Traversal
+{
+ // Dispatcher
+ //
+ //
+
+ struct TypeInfoComparator
+ {
+ bool
+ operator () (TypeInfo const& x, TypeInfo const& y) const
+ {
+ return x.type_id () < y.type_id ();
+ }
+ };
+
+ typedef
+ std::map<TypeInfo, unsigned long, TypeInfoComparator>
+ LevelMap;
+
+ typedef
+ std::set<TypeInfo, TypeInfoComparator>
+ TypeInfoSet;
+
+ unsigned long
+ compute_levels (TypeInfo const& ti, unsigned long cur, LevelMap& map)
+ {
+ unsigned long ret = cur;
+
+ if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur;
+
+ for (TypeInfo::BaseIterator i = ti.begin_base ();
+ i != ti.end_base ();
+ i++)
+ {
+ unsigned long t = compute_levels (i->type_info (), cur + 1, map);
+ if (t > ret) ret = t;
+ }
+
+ return ret;
+ }
+
+ void
+ flatten_tree (TypeInfo const& ti, TypeInfoSet& set)
+ {
+ set.insert (ti);
+
+ for (TypeInfo::BaseIterator i = ti.begin_base ();
+ i != ti.end_base ();
+ i++)
+ {
+ flatten_tree (i->type_info (), set);
+ }
+ }
+
+ void Dispatcher::
+ dispatch (SyntaxTree::Node* n)
+ {
+ LevelMap levels;
+
+ unsigned long max = compute_levels (n->type_info (), 0, levels);
+
+ for (unsigned long l = 0; l < max + 1; l++)
+ {
+ TypeInfoSet dispatched;
+
+ for (LevelMap::const_iterator i = levels.begin ();
+ i != levels.end ();
+ i++)
+ {
+ if (i->second == l)
+ {
+ TraversalMap::const_iterator v =
+ traversal_map_.find (i->first.type_id ());
+
+ if (v != traversal_map_.end ())
+ {
+ v->second->traverse (n);
+ flatten_tree (i->first, dispatched);
+ }
+ }
+ }
+
+ // Remove traversed types from level map.
+ for (TypeInfoSet::const_iterator i = dispatched.begin ();
+ i != dispatched.end ();
+ i++)
+ {
+ levels.erase (*i);
+ }
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Example/Introspection/Traversal/Traversal.hpp b/contrib/utility/Example/Introspection/Traversal/Traversal.hpp
new file mode 100644
index 00000000000..7ee84523fc0
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Traversal/Traversal.hpp
@@ -0,0 +1,157 @@
+// file : Example/Introspection/Traversal/Traversal.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef TRAVERSAL_HPP
+#define TRAVERSAL_HPP
+
+#include <map>
+#include <iostream>
+
+#include "Utility/Introspection/Introspection.hpp"
+
+#include "SyntaxTree.hpp"
+
+namespace Traversal
+{
+ class Traverser;
+
+ //
+ //
+ //
+ class Dispatcher
+ {
+ public:
+ virtual
+ ~Dispatcher ()
+ {
+ }
+
+ virtual void
+ dispatch (SyntaxTree::Node* n);
+
+ protected:
+ void
+ map (Utility::Introspection::TypeId id, Traverser* t)
+ {
+ traversal_map_[id] = t;
+ }
+
+ private:
+ typedef
+ std::map<Utility::Introspection::TypeId, Traverser*>
+ TraversalMap;
+
+ TraversalMap traversal_map_;
+ };
+
+
+ //
+ //
+ //
+ class Traverser : public virtual Dispatcher
+ {
+ public:
+ virtual void
+ traverse (SyntaxTree::Node* n) = 0;
+ };
+
+ //
+ //
+ //
+ struct Node : Traverser
+ {
+ Node ()
+ {
+ map (typeid (SyntaxTree::Node), this);
+ }
+
+ virtual void
+ traverse (SyntaxTree::Node*)
+ {
+ std::cerr << "node" << std::endl;
+ }
+ };
+
+
+ //
+ //
+ //
+ struct Declaration : Traverser
+ {
+ Declaration ()
+ {
+ map (typeid (SyntaxTree::Declaration), this);
+ }
+
+ virtual void
+ traverse (SyntaxTree::Node*)
+ {
+ std::cerr << "declaration" << std::endl;
+ }
+ };
+
+ //
+ //
+ //
+ struct Scope : Traverser
+ {
+ Scope ()
+ {
+ map (typeid (SyntaxTree::Scope), this);
+ }
+
+ virtual void
+ traverse (SyntaxTree::Node* n)
+ {
+ std::cerr << "scope" << std::endl;
+
+ SyntaxTree::Scope* s = dynamic_cast<SyntaxTree::Scope*> (n);
+
+ for (SyntaxTree::DeclarationList::iterator i = s->content_.begin ();
+ i != s->content_.end ();
+ i++)
+ {
+ dispatch (*i);
+ }
+ }
+ };
+
+ //
+ //
+ //
+ struct InterfaceDecl : Traverser
+ {
+ InterfaceDecl ()
+ {
+ map (typeid (SyntaxTree::InterfaceDecl), this);
+ }
+
+ virtual void
+ traverse (SyntaxTree::Node*)
+ {
+ std::cerr << "interface declaration" << std::endl;
+ }
+ };
+
+ //
+ //
+ //
+ struct InterfaceDef : Traverser
+ {
+ InterfaceDef ()
+ {
+ map (typeid (SyntaxTree::InterfaceDef), this);
+ }
+
+ virtual void
+ traverse (SyntaxTree::Node*)
+ {
+ std::cerr << "interface definition" << std::endl;
+ }
+ };
+}
+
+#endif // TRAVERSAL_HPP
+//$Id$
diff --git a/contrib/utility/Example/Introspection/Traversal/driver.cpp b/contrib/utility/Example/Introspection/Traversal/driver.cpp
new file mode 100644
index 00000000000..35891ef58cc
--- /dev/null
+++ b/contrib/utility/Example/Introspection/Traversal/driver.cpp
@@ -0,0 +1,91 @@
+// file : Example/Introspection/Traversal/driver.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include <iostream>
+
+#include "SyntaxTree.hpp"
+#include "Traversal.hpp"
+
+int
+main ()
+{
+ using namespace SyntaxTree;
+
+ /*
+ Create a syntax tree that looks something like this:
+
+ scope
+ {
+ interface declaration;
+
+ scope
+ {
+ interface definition
+ {
+ decalartion;
+ };
+ };
+ };
+
+ */
+
+ Scope s1;
+
+ InterfaceDecl i1;
+ s1.content_.push_back (&i1);
+
+ Scope s2;
+ s1.content_.push_back (&s2);
+
+ InterfaceDef i2;
+ s2.content_.push_back (&i2);
+
+ Declaration d1;
+ i2.content_.push_back (&d1);
+
+ SyntaxTree::Node* root = &s1;
+
+ // Now different ways of traversing this tree:
+
+ {
+ std::cout << "test #1" << std::endl;
+
+ struct Generator : Traversal::Declaration, Traversal::Scope
+ {
+ };
+
+ Generator g;
+ g.dispatch (root);
+
+ std::cout << std::endl;
+ }
+
+ {
+ std::cout << "test #2" << std::endl;
+
+ struct Generator : Traversal::Scope, Traversal::InterfaceDecl
+ {
+ };
+
+ Generator g;
+ g.dispatch (root);
+
+ std::cout << std::endl;
+ }
+
+ {
+ std::cout << "test #3" << std::endl;
+
+ struct Generator : Traversal::Scope, Traversal::InterfaceDef
+ {
+ };
+
+ Generator g;
+ g.dispatch (root);
+
+ std::cout << std::endl;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Example/Makefile b/contrib/utility/Example/Makefile
new file mode 100644
index 00000000000..1caefc91a39
--- /dev/null
+++ b/contrib/utility/Example/Makefile
@@ -0,0 +1,16 @@
+# file : Example/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 := ExH Hetero Introspection
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Makefile b/contrib/utility/Makefile
new file mode 100644
index 00000000000..d23e380254b
--- /dev/null
+++ b/contrib/utility/Makefile
@@ -0,0 +1,18 @@
+# file : 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 := Utility Test Example Documentation
+
+Test Example Documentation : Utility
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/Compound/Makefile b/contrib/utility/Test/ExH/Compound/Makefile
new file mode 100644
index 00000000000..b596cd2fbce
--- /dev/null
+++ b/contrib/utility/Test/ExH/Compound/Makefile
@@ -0,0 +1,24 @@
+# file : Test/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/contrib/utility/Test/ExH/Compound/compound.cpp b/contrib/utility/Test/ExH/Compound/compound.cpp
new file mode 100644
index 00000000000..d3319f5d7dc
--- /dev/null
+++ b/contrib/utility/Test/ExH/Compound/compound.cpp
@@ -0,0 +1,115 @@
+// file : Test/ExH/Compound/compound.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/Compound.hpp"
+
+#include <string>
+
+using namespace Utility::ExH;
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+class Base
+{
+protected:
+ Base () throw ()
+ {
+ }
+
+ void
+ init (char const* description) throw ()
+ {
+ str_ = description;
+ }
+
+ char const*
+ what () const throw ()
+ {
+ return str_.c_str ();
+ }
+
+public:
+ std::string str_;
+};
+
+class A_ {};
+typedef
+Compound<A_, Base>
+A;
+
+struct StringHolder
+{
+ StringHolder (char const* s)
+ : str_ (s)
+ {
+ }
+
+ operator std::string () const
+ {
+ return str_;
+ }
+
+ std::string str_;
+};
+
+
+int main ()
+{
+ try
+ {
+ // Compound (char const*)
+ //
+ {
+ A a ("hello");
+
+ postcondition (a.str_ == "hello");
+ }
+
+ // Compound (T const&)
+ //
+ {
+ StringHolder a ("hello");
+ A b (a);
+
+ postcondition (b.str_ == "hello");
+ }
+
+ // Compound (Compound const&)
+ //
+ {
+ A a ("hello");
+ A b (a);
+
+ postcondition (b.str_ == "hello");
+ }
+
+ // ~Compound ()
+ //
+
+ // operator= (Compound const&)
+ //
+ {
+ A a ("hello");
+ A b ("foo");
+ b = a;
+
+ postcondition (b.str_ == "hello");
+ }
+
+ // Compound ()
+ //
+
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ExH/Converter/Makefile b/contrib/utility/Test/ExH/Converter/Makefile
new file mode 100644
index 00000000000..3f37652482d
--- /dev/null
+++ b/contrib/utility/Test/ExH/Converter/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ExH/Converter/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 := converter.cpp
+
+module_base := converter
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/Converter/converter.cpp b/contrib/utility/Test/ExH/Converter/converter.cpp
new file mode 100644
index 00000000000..396b616e6a6
--- /dev/null
+++ b/contrib/utility/Test/ExH/Converter/converter.cpp
@@ -0,0 +1,48 @@
+// file : Test/ExH/Converter/converter.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/Converter.hpp"
+#include "Utility/ExH/StringStreamConverter.hpp"
+
+#include <string>
+#include <sstream>
+
+using std::string;
+using namespace Utility::ExH;
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+int
+main ()
+{
+ try
+ {
+ // template<T>
+ // converter (T const&)
+ //
+ {
+ postcondition (converter ("hello") == string("hello"));
+ }
+
+ // template<>
+ // converter (std::ostringstream const&)
+ //
+ {
+ std::ostringstream ostr;
+ ostr << "hello";
+ postcondition (converter (ostr) == string("hello"));
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ExH/Inline/Makefile b/contrib/utility/Test/ExH/Inline/Makefile
new file mode 100644
index 00000000000..26606c35669
--- /dev/null
+++ b/contrib/utility/Test/ExH/Inline/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ExH/Inline/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 := inline.cpp unit.cpp
+
+module_base := inline
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/Inline/inline.cpp b/contrib/utility/Test/ExH/Inline/inline.cpp
new file mode 100644
index 00000000000..7700728932f
--- /dev/null
+++ b/contrib/utility/Test/ExH/Inline/inline.cpp
@@ -0,0 +1,18 @@
+// file : Test/ExH/Inline/inline.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+//
+// This is a link-time test to detect any problems with inline functions
+// (notably missing inline specifier).
+//
+
+#include "Utility/ExH/ExH.hpp"
+
+int
+main ()
+{
+}
+
+//$Id$
diff --git a/contrib/utility/Test/ExH/Inline/unit.cpp b/contrib/utility/Test/ExH/Inline/unit.cpp
new file mode 100644
index 00000000000..8a57af7d759
--- /dev/null
+++ b/contrib/utility/Test/ExH/Inline/unit.cpp
@@ -0,0 +1,8 @@
+// file : Test/ExH/Inline/unit.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/ExH.hpp"
+
+//$Id$
diff --git a/contrib/utility/Test/ExH/Logic/DescriptiveException/Makefile b/contrib/utility/Test/ExH/Logic/DescriptiveException/Makefile
new file mode 100644
index 00000000000..6ca8e6029ee
--- /dev/null
+++ b/contrib/utility/Test/ExH/Logic/DescriptiveException/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ExH/Logic/DescriptiveException/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 := descriptive_exception.cpp
+
+module_base := descriptive_exception
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/Logic/DescriptiveException/descriptive_exception.cpp b/contrib/utility/Test/ExH/Logic/DescriptiveException/descriptive_exception.cpp
new file mode 100644
index 00000000000..7c3246df491
--- /dev/null
+++ b/contrib/utility/Test/ExH/Logic/DescriptiveException/descriptive_exception.cpp
@@ -0,0 +1,108 @@
+// file : Test/ExH/Logic/DescriptiveException/descriptive_exception.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/Logic/DescriptiveException.hpp"
+
+#include <string>
+
+using std::string;
+using namespace Utility::ExH::Logic;
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+struct StringHolder
+{
+ StringHolder (char const* s)
+ : str_ (s)
+ {
+ }
+
+ operator std::string () const
+ {
+ return str_;
+ }
+
+ string str_;
+};
+
+int
+main ()
+{
+ try
+ {
+ // DescriptiveException (char const*)
+ //
+ {
+ DescriptiveException a ("hello");
+
+ postcondition (a.what () == string ("hello"));
+ }
+
+ // DescriptiveException (std::string const&)
+ //
+ {
+ DescriptiveException a (string ("hello"));
+
+ postcondition (a.what () == string ("hello"));
+ }
+
+
+ // DescriptiveException (T const&)
+ //
+ {
+ StringHolder a ("hello");
+
+ DescriptiveException b (a);
+
+ postcondition (b.what () == string ("hello"));
+ }
+
+ // DescriptiveException (DescriptiveException const&)
+ //
+ {
+ DescriptiveException a ("hello");
+ DescriptiveException b (a);
+
+ postcondition (b.what () == string ("hello"));
+ }
+
+ // ~DescriptiveException
+ //
+
+ // operator= (DescriptiveException const&)
+ //
+ {
+ DescriptiveException a ("hello");
+ DescriptiveException b ("foo");
+ b = a;
+
+ postcondition (b.what () == string ("hello"));
+ }
+
+ // DescriptiveException ()
+ //
+
+ // init (char const*)
+ //
+
+ // what ()
+ //
+ {
+ DescriptiveException a ("hello");
+
+ postcondition (a.what () == string ("hello"));
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ExH/Logic/Makefile b/contrib/utility/Test/ExH/Logic/Makefile
new file mode 100644
index 00000000000..042b3a172a4
--- /dev/null
+++ b/contrib/utility/Test/ExH/Logic/Makefile
@@ -0,0 +1,16 @@
+# file : Test/ExH/Logic/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 := DescriptiveException
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/Makefile b/contrib/utility/Test/ExH/Makefile
new file mode 100644
index 00000000000..161884a439c
--- /dev/null
+++ b/contrib/utility/Test/ExH/Makefile
@@ -0,0 +1,16 @@
+# file : Test/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 := Compound Converter Inline Logic System
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/System/DescriptiveException/Makefile b/contrib/utility/Test/ExH/System/DescriptiveException/Makefile
new file mode 100644
index 00000000000..9fd89d86ade
--- /dev/null
+++ b/contrib/utility/Test/ExH/System/DescriptiveException/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ExH/System/DescriptiveException/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 := descriptive_exception.cpp
+
+module_base := descriptive_exception
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ExH/System/DescriptiveException/descriptive_exception.cpp b/contrib/utility/Test/ExH/System/DescriptiveException/descriptive_exception.cpp
new file mode 100644
index 00000000000..4cd14da8627
--- /dev/null
+++ b/contrib/utility/Test/ExH/System/DescriptiveException/descriptive_exception.cpp
@@ -0,0 +1,107 @@
+// file : Test/ExH/System/DescriptiveException/descriptive_exception.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/System/DescriptiveException.hpp"
+
+#include <string>
+
+using std::string;
+using namespace Utility::ExH::System;
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+struct StringHolder
+{
+ StringHolder (char const* s)
+ : str_ (s)
+ {
+ }
+
+ operator std::string () const
+ {
+ return str_;
+ }
+
+ string str_;
+};
+
+int
+main ()
+{
+ try
+ {
+ // DescriptiveException (char const*)
+ //
+ {
+ DescriptiveException a ("hello");
+
+ postcondition (a.what () == string ("hello"));
+ }
+
+ // DescriptiveException (std::string const&)
+ //
+ {
+ DescriptiveException a (string ("hello"));
+
+ postcondition (a.what () == string ("hello"));
+ }
+
+ // DescriptiveException (T const&)
+ //
+ {
+ StringHolder a ("hello");
+
+ DescriptiveException b (a);
+
+ postcondition (b.what () == string ("hello"));
+ }
+
+ // DescriptiveException (DescriptiveException const&)
+ //
+ {
+ DescriptiveException a ("hello");
+ DescriptiveException b (a);
+
+ postcondition (b.what () == string ("hello"));
+ }
+
+ // ~DescriptiveException
+ //
+
+ // operator= (DescriptiveException const&)
+ //
+ {
+ DescriptiveException a ("hello");
+ DescriptiveException b ("foo");
+ b = a;
+
+ postcondition (b.what () == string ("hello"));
+ }
+
+ // DescriptiveException ()
+ //
+
+ // init (char const*)
+ //
+
+ // what ()
+ //
+ {
+ DescriptiveException a ("hello");
+
+ postcondition (a.what () == string ("hello"));
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ExH/System/Makefile b/contrib/utility/Test/ExH/System/Makefile
new file mode 100644
index 00000000000..2ffea12a6ed
--- /dev/null
+++ b/contrib/utility/Test/ExH/System/Makefile
@@ -0,0 +1,16 @@
+# file : Test/ExH/System/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 := DescriptiveException
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/Introspection/Inline/Makefile b/contrib/utility/Test/Introspection/Inline/Makefile
new file mode 100644
index 00000000000..fb7a72c1e2f
--- /dev/null
+++ b/contrib/utility/Test/Introspection/Inline/Makefile
@@ -0,0 +1,24 @@
+# file : Test/Introspection/Inline/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 := inline.cpp unit.cpp
+
+module_base := inline
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/Introspection/Inline/inline.cpp b/contrib/utility/Test/Introspection/Inline/inline.cpp
new file mode 100644
index 00000000000..99ff8ff590f
--- /dev/null
+++ b/contrib/utility/Test/Introspection/Inline/inline.cpp
@@ -0,0 +1,18 @@
+// file : Test/Introspection/Inline/inline.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+//
+// This is a link-time test to detect any problems with inline functions
+// (notably missing inline specifier).
+//
+
+#include "Utility/Introspection/Introspection.hpp"
+
+int
+main ()
+{
+}
+
+//$Id$
diff --git a/contrib/utility/Test/Introspection/Inline/unit.cpp b/contrib/utility/Test/Introspection/Inline/unit.cpp
new file mode 100644
index 00000000000..a5fe6f95b65
--- /dev/null
+++ b/contrib/utility/Test/Introspection/Inline/unit.cpp
@@ -0,0 +1,8 @@
+// file : Test/Introspection/Inline/unit.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/Introspection/Introspection.hpp"
+
+//$Id$
diff --git a/contrib/utility/Test/Introspection/Makefile b/contrib/utility/Test/Introspection/Makefile
new file mode 100644
index 00000000000..8ed18da5c41
--- /dev/null
+++ b/contrib/utility/Test/Introspection/Makefile
@@ -0,0 +1,16 @@
+# file : Test/Introspection/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 := Inline
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/Makefile b/contrib/utility/Test/Makefile
new file mode 100644
index 00000000000..4ac5c3530b8
--- /dev/null
+++ b/contrib/utility/Test/Makefile
@@ -0,0 +1,18 @@
+# file : Test/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 := ExH Introspection ReferenceCounting Synch
+
+ReferenceCounting : ExH Synch
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/DefaultImpl/Makefile b/contrib/utility/Test/ReferenceCounting/DefaultImpl/Makefile
new file mode 100644
index 00000000000..c3f89dc7a9c
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/DefaultImpl/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ReferenceCounting/DefaultImpl/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 := default_impl.cpp
+
+module_base := default_impl
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/DefaultImpl/default_impl.cpp b/contrib/utility/Test/ReferenceCounting/DefaultImpl/default_impl.cpp
new file mode 100644
index 00000000000..971751b6677
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/DefaultImpl/default_impl.cpp
@@ -0,0 +1,132 @@
+// file : Test/ReferenceCounting/DefaultImpl/default_impl.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ReferenceCounting/DefaultImpl.hpp"
+
+using namespace Utility::ReferenceCounting;
+
+struct Base : public virtual Interface
+{
+ virtual
+ ~Base () throw ()
+ {
+ }
+};
+
+
+class Impl : public virtual Base,
+ public virtual DefaultImpl <>
+{
+public:
+ Impl (bool& destroyed)
+ : dummy_ (false),
+ destroyed_ (destroyed)
+ {
+ }
+
+ Impl ()
+ : dummy_ (false),
+ destroyed_ (dummy_)
+ {
+ }
+
+ virtual
+ ~Impl () throw ()
+ {
+ destroyed_ = true;
+ }
+
+public:
+ void
+ lock ()
+ {
+ lock_i ();
+ }
+
+private:
+ bool dummy_;
+ bool& destroyed_;
+};
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+int main ()
+{
+ try
+ {
+ // DefaultImpl
+ //
+ {
+ Impl* a (new Impl);
+
+ postcondition (a->refcount_value () == 1);
+
+ a->remove_ref ();
+ }
+
+ // ~DefaultImpl
+ //
+ {
+ Impl* a (new Impl);
+ a->remove_ref ();
+ }
+
+ // add_ref
+ //
+ {
+ Impl* a (new Impl);
+
+ a->add_ref ();
+
+ postcondition (a->refcount_value () == 2);
+
+ a->remove_ref ();
+ a->remove_ref ();
+ }
+
+
+ // remove_ref
+ //
+ {
+ bool destroyed (false);
+ Impl* a (new Impl (destroyed));
+
+ a->add_ref ();
+ a->remove_ref ();
+
+ postcondition (destroyed == false && a->refcount_value () == 1);
+
+ a->remove_ref ();
+
+ postcondition (destroyed == true);
+ }
+
+
+ // refcount_value
+ //
+ {
+ Impl* a (new Impl);
+
+ postcondition (a->refcount_value () == 1);
+ }
+
+ // lock_i
+ //
+ {
+ Impl* a (new Impl);
+ a->lock ();
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ReferenceCounting/Inline/Makefile b/contrib/utility/Test/ReferenceCounting/Inline/Makefile
new file mode 100644
index 00000000000..5ae9a840c8d
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/Inline/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ReferenceCounting/Inline/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 := inline.cpp unit.cpp
+
+module_base := inline
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/Inline/inline.cpp b/contrib/utility/Test/ReferenceCounting/Inline/inline.cpp
new file mode 100644
index 00000000000..0ff2dfa9986
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/Inline/inline.cpp
@@ -0,0 +1,16 @@
+// file : Test/ReferenceCounting/Inline/inline.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+//
+// This is a link-time test to detect any problems with inline functions
+// (notably missing inline specifier).
+//
+
+#include "Utility/ReferenceCounting/ReferenceCounting.hpp"
+
+int main ()
+{
+}
+//$Id$
diff --git a/contrib/utility/Test/ReferenceCounting/Inline/unit.cpp b/contrib/utility/Test/ReferenceCounting/Inline/unit.cpp
new file mode 100644
index 00000000000..31dbfdb8708
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/Inline/unit.cpp
@@ -0,0 +1,8 @@
+// file : Test/ReferenceCounting/Inline/unit.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ReferenceCounting/ReferenceCounting.hpp"
+
+//$Id$
diff --git a/contrib/utility/Test/ReferenceCounting/Interface/Makefile b/contrib/utility/Test/ReferenceCounting/Interface/Makefile
new file mode 100644
index 00000000000..4327774eb54
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/Interface/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ReferenceCounting/Interface/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 := interface.cpp
+
+module_base := interface
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/Interface/interface.cpp b/contrib/utility/Test/ReferenceCounting/Interface/interface.cpp
new file mode 100644
index 00000000000..a9cb4d55824
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/Interface/interface.cpp
@@ -0,0 +1,104 @@
+// file : Test/ReferenceCounting/Interface/interface.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ReferenceCounting/Interface.hpp"
+
+using namespace Utility::ReferenceCounting;
+
+struct Obj : public virtual Interface
+{
+ Obj ()
+ : ref_count_ (1)
+ {
+ }
+
+ virtual
+ ~Obj () throw ()
+ {
+ }
+
+public:
+ virtual void
+ add_ref () const throw ()
+ {
+ add_ref_i ();
+ }
+
+
+ virtual void
+ remove_ref () const throw ()
+ {
+ if (remove_ref_i ()) delete this;
+ }
+
+ virtual count_t
+ refcount_value () const throw ()
+ {
+ return refcount_value_i ();
+ }
+
+protected:
+ virtual void
+ add_ref_i () const throw ()
+ {
+ ++ref_count_;
+ }
+
+
+ virtual bool
+ remove_ref_i () const throw ()
+ {
+ return --ref_count_ == 0;
+ }
+
+ virtual count_t
+ refcount_value_i () const throw ()
+ {
+ return ref_count_;
+ }
+
+private:
+ mutable count_t ref_count_;
+};
+
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+int main ()
+{
+ try
+ {
+ // add_ref
+ //
+ {
+ Obj* a (new Obj);
+
+ Obj* b (add_ref (a));
+
+ postcondition (a == b && a->refcount_value () == 2);
+
+ a->remove_ref ();
+ b->remove_ref ();
+ }
+
+ {
+ Obj* a (0);
+
+ Obj* b (add_ref (a));
+
+ postcondition (b == 0);
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ReferenceCounting/Makefile b/contrib/utility/Test/ReferenceCounting/Makefile
new file mode 100644
index 00000000000..1f7d981c87f
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/Makefile
@@ -0,0 +1,16 @@
+# file : Test/ReferenceCounting/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 := Interface DefaultImpl Inline SmartPtr StrictPtr
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/SmartPtr/Makefile b/contrib/utility/Test/ReferenceCounting/SmartPtr/Makefile
new file mode 100644
index 00000000000..7bbc0456949
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/SmartPtr/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ReferenceCounting/SmartPtr/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 := smart_ptr.cpp
+
+module_base := smart_ptr
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/SmartPtr/smart_ptr.cpp b/contrib/utility/Test/ReferenceCounting/SmartPtr/smart_ptr.cpp
new file mode 100644
index 00000000000..67f4442a359
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/SmartPtr/smart_ptr.cpp
@@ -0,0 +1,220 @@
+// file : Test/ReferenceCounting/SmartPtr/smart_ptr.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ReferenceCounting/SmartPtr.hpp"
+#include "Utility/ReferenceCounting/DefaultImpl.hpp"
+
+using namespace Utility::ReferenceCounting;
+
+struct Base : public virtual Interface
+{
+ virtual
+ ~Base () throw ()
+ {
+ }
+};
+
+typedef
+SmartPtr<Base>
+BasePtr;
+
+class Impl : public virtual Base,
+ public virtual DefaultImpl <>
+{
+public:
+ Impl (bool& destroyed)
+ : dummy_ (false),
+ destroyed_ (destroyed)
+ {
+ }
+
+ Impl ()
+ : dummy_ (false),
+ destroyed_ (dummy_)
+ {
+ }
+
+ virtual
+ ~Impl () throw ()
+ {
+ destroyed_ = true;
+ }
+
+private:
+ bool dummy_;
+ bool& destroyed_;
+};
+
+typedef
+SmartPtr<Impl>
+ImplPtr;
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+int main ()
+{
+ try
+ {
+ // SmartPtr ()
+ //
+ {
+ BasePtr a;
+
+ postcondition (a.in () == 0);
+ }
+
+ // SmartPtr (Type*)
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+
+ postcondition (b.in () == a && a->refcount_value () == 1);
+ }
+
+ // SmartPtr (SmartPtr<Type> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ ImplPtr b (a);
+
+ postcondition (a.in () == b.in () && a->refcount_value () == 2);
+ }
+
+ // SmartPtr (SmartPtr<Other> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ BasePtr b (a);
+
+ postcondition (b.in () == static_cast<Base*>(a.in ()) &&
+ b->refcount_value () == 2);
+ }
+
+ // ~SmartPtr
+ //
+ {
+ bool destroyed (false);
+ {
+ ImplPtr a (new Impl (destroyed));
+ }
+
+ postcondition (destroyed == true);
+ }
+
+ // operator= (Type* ptr)
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b;
+ b = a;
+
+ postcondition (b.in () == a && a->refcount_value () == 1);
+ }
+
+ // operator= (SmartPtr<Type> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ ImplPtr b;
+ b = a;
+
+ postcondition (b.in () == a.in () && a->refcount_value () == 2);
+ }
+
+ // operator= (SmartPtr<Other> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ BasePtr b;
+ b = a;
+
+ postcondition (b.in () == static_cast<Base*>(a.in ()) &&
+ b->refcount_value () == 2);
+ }
+
+ // operator Type*
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b);
+
+ postcondition (a == c);
+ }
+
+ // operator->
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b.operator-> ());
+
+ postcondition (a == c);
+ }
+
+ // in
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b.in ());
+
+ postcondition (a == c);
+ }
+
+ // retn
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b.retn ());
+
+ postcondition (a == c);
+
+ b = a; // give ownership back
+ }
+
+ // add_ref
+ //
+ {
+ ImplPtr a (new Impl);
+ ImplPtr b (add_ref (a));
+
+ postcondition (a.in () == b.in () && b->refcount_value () == 2);
+ }
+
+ // smart_cast
+ //
+ {
+ BasePtr a (new Impl);
+ ImplPtr b (smart_cast<Impl>(a));
+
+ postcondition (b != 0 && b->refcount_value () == 2);
+ }
+
+ // acquire
+ //
+ {
+ bool destroyed (false);
+ Base::count_t c (0);
+ {
+ c = acquire (new Impl (destroyed))->refcount_value ();
+ }
+
+ postcondition (c == 1 && destroyed == true);
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/ReferenceCounting/StrictPtr/Makefile b/contrib/utility/Test/ReferenceCounting/StrictPtr/Makefile
new file mode 100644
index 00000000000..e078ef688fe
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/StrictPtr/Makefile
@@ -0,0 +1,24 @@
+# file : Test/ReferenceCounting/StrictPtr/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 := strict_ptr.cpp
+
+module_base := strict_ptr
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/ReferenceCounting/StrictPtr/strict_ptr.cpp b/contrib/utility/Test/ReferenceCounting/StrictPtr/strict_ptr.cpp
new file mode 100644
index 00000000000..1fcee9448ea
--- /dev/null
+++ b/contrib/utility/Test/ReferenceCounting/StrictPtr/strict_ptr.cpp
@@ -0,0 +1,218 @@
+// file : Test/ReferenceCounting/StrictPtr/strict_ptr.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ReferenceCounting/StrictPtr.hpp"
+#include "Utility/ReferenceCounting/DefaultImpl.hpp"
+
+using namespace Utility::ReferenceCounting;
+
+struct Base : public virtual Interface
+{
+ virtual
+ ~Base () throw ()
+ {
+ }
+};
+
+typedef
+StrictPtr<Base>
+BasePtr;
+
+class Impl : public virtual Base,
+ public virtual DefaultImpl <>
+{
+public:
+ Impl (bool& destroyed)
+ : dummy_ (false),
+ destroyed_ (destroyed)
+ {
+ }
+
+ Impl ()
+ : dummy_ (false),
+ destroyed_ (dummy_)
+ {
+ }
+
+ virtual
+ ~Impl () throw ()
+ {
+ destroyed_ = true;
+ }
+
+private:
+ bool dummy_;
+ bool& destroyed_;
+};
+
+typedef
+StrictPtr<Impl>
+ImplPtr;
+
+struct E {};
+
+void postcondition (bool p) throw (E)
+{
+ if (!p) throw E ();
+}
+
+int main ()
+{
+ try
+ {
+ // StrictPtr ()
+ //
+ {
+ BasePtr a;
+
+ postcondition (a.in () == 0);
+ }
+
+ // StrictPtr (Type*)
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+
+ postcondition (b.in () == a && a->refcount_value () == 1);
+ }
+
+ // StrictPtr (StrictPtr<Type> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ ImplPtr b (a);
+
+ postcondition (a.in () == b.in () && a->refcount_value () == 2);
+ }
+
+ // StrictPtr (StrictPtr<Other> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ BasePtr b (a);
+
+ postcondition (b.in () == static_cast<Base*>(a.in ()) &&
+ b->refcount_value () == 2);
+ }
+
+ // ~StrictPtr
+ //
+ {
+ bool destroyed (false);
+ {
+ ImplPtr a (new Impl (destroyed));
+ }
+
+ postcondition (destroyed == true);
+ }
+
+ // operator= (Type* ptr)
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b;
+ b = a;
+
+ postcondition (b.in () == a && a->refcount_value () == 1);
+ }
+
+ // operator= (StrictPtr<Type> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ ImplPtr b;
+ b = a;
+
+ postcondition (b.in () == a.in () && a->refcount_value () == 2);
+ }
+
+ // operator= (StrictPtr<Other> const&)
+ //
+ {
+ ImplPtr a (new Impl);
+ BasePtr b;
+ b = a;
+
+ postcondition (b.in () == static_cast<Base*>(a.in ()) &&
+ b->refcount_value () == 2);
+ }
+
+ // operator==
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ bool r (b.in () == a);
+
+ postcondition (r == true);
+ }
+
+ // operator!=
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ bool r (b.in () != a);
+
+ postcondition (r == false);
+ }
+
+ // operator->
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b.operator-> ());
+
+ postcondition (a == c);
+ }
+
+ // in
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b.in ());
+
+ postcondition (a == c);
+ }
+
+ // retn
+ //
+ {
+ Impl* a (new Impl);
+ ImplPtr b (a);
+ Impl* c (b.retn ());
+
+ postcondition (a == c);
+
+ b = a; // give ownership back
+ }
+
+ // add_ref
+ //
+ {
+ ImplPtr a (new Impl);
+ ImplPtr b (add_ref (a));
+
+ postcondition (a.in () == b.in () && b->refcount_value () == 2);
+ }
+
+ // strict_cast
+ //
+ {
+ BasePtr a (new Impl);
+ ImplPtr b (strict_cast<Impl>(a));
+
+ postcondition (b != 0 && b->refcount_value () == 2);
+ }
+ }
+ catch (...)
+ {
+ return -1;
+ }
+}
+//$Id$
diff --git a/contrib/utility/Test/Synch/Inline/Makefile b/contrib/utility/Test/Synch/Inline/Makefile
new file mode 100644
index 00000000000..2101cc3ee8c
--- /dev/null
+++ b/contrib/utility/Test/Synch/Inline/Makefile
@@ -0,0 +1,24 @@
+# file : Test/Synch/Inline/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 := inline.cpp unit.cpp
+
+module_base := inline
+module_prefix :=
+module_suffix :=
+
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+
+$(call include, $(root)/BuildRules/Executable.post.rules)
+# $Id$
diff --git a/contrib/utility/Test/Synch/Inline/inline.cpp b/contrib/utility/Test/Synch/Inline/inline.cpp
new file mode 100644
index 00000000000..0b2db8a7d57
--- /dev/null
+++ b/contrib/utility/Test/Synch/Inline/inline.cpp
@@ -0,0 +1,18 @@
+// file : Test/Synch/Inline/inline.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+//
+// This is a link-time test to detect any problems with inline functions
+// (notably missing inline specifier).
+//
+
+#include "Utility/Synch/Policy/Null.hpp"
+
+int
+main ()
+{
+}
+
+//$Id$
diff --git a/contrib/utility/Test/Synch/Inline/unit.cpp b/contrib/utility/Test/Synch/Inline/unit.cpp
new file mode 100644
index 00000000000..b570c97ae5e
--- /dev/null
+++ b/contrib/utility/Test/Synch/Inline/unit.cpp
@@ -0,0 +1,8 @@
+// file : Test/Synch/Inline/unit.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/Synch/Policy/Null.hpp"
+
+//$Id$
diff --git a/contrib/utility/Test/Synch/Makefile b/contrib/utility/Test/Synch/Makefile
new file mode 100644
index 00000000000..c4b730ca6a5
--- /dev/null
+++ b/contrib/utility/Test/Synch/Makefile
@@ -0,0 +1,16 @@
+# file : Test/Synch/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 := Inline
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Utility/ExH/Compound.hpp b/contrib/utility/Utility/ExH/Compound.hpp
new file mode 100644
index 00000000000..664583fffb2
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Compound.hpp
@@ -0,0 +1,47 @@
+// file : Utility/ExH/Compound.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_COMPOUND_HPP
+#define UTILITY_EX_H_COMPOUND_HPP
+
+#include <string>
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <typename Type, typename Base>
+ class Compound : public virtual Base
+ {
+ public:
+ explicit
+ Compound (char const* description) throw ();
+
+ explicit
+ Compound (std::string const& description) throw ();
+
+ template <typename T>
+ explicit
+ Compound (T const& description) throw ();
+
+ Compound (Compound const& src) throw ();
+
+ virtual
+ ~Compound () throw ();
+
+ public:
+ Compound&
+ operator= (Compound const& src) throw ();
+
+ protected:
+ Compound () throw ();
+ };
+ }
+}
+
+#include "Utility/ExH/Compound.tpp"
+
+#endif // UTILITY_EX_H_COMPOUND_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Compound.tpp b/contrib/utility/Utility/ExH/Compound.tpp
new file mode 100644
index 00000000000..a4c798d97cb
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Compound.tpp
@@ -0,0 +1,71 @@
+// file : Utility/ExH/Compound.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/Converter.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ // c-tor's & d-tor
+ template <typename Type, typename Base>
+ Compound<Type, Base>::
+ Compound () throw ()
+ {
+ }
+
+ template <typename Type, typename Base>
+ Compound<Type, Base>::
+ Compound (char const* description) throw ()
+ {
+ Base::init (description);
+ }
+
+ template <typename Type, typename Base>
+ Compound<Type, Base>::
+ Compound (std::string const& description) throw ()
+ {
+ try
+ {
+ Base::init (description.c_str ());
+ }
+ catch (...)
+ {
+ }
+ }
+
+ template <typename Type, typename Base>
+ template <typename T>
+ Compound<Type, Base>::
+ Compound (T const& description) throw ()
+ {
+ Base::init (converter<T> (description).c_str ());
+ }
+
+ template <typename Type, typename Base>
+ Compound<Type, Base>::
+ Compound (Compound const& src) throw ()
+ {
+ Base::init (src.what ());
+ }
+
+ template <typename Type, typename Base>
+ Compound<Type, Base>::
+ ~Compound () throw ()
+ {
+ }
+
+ // operator=
+
+ template <typename Type, typename Base>
+ Compound<Type, Base>& Compound<Type, Base>::
+ operator= (Compound const& src) throw ()
+ {
+ Base::init (src.what ());
+ return *this;
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Converter.hpp b/contrib/utility/Utility/ExH/Converter.hpp
new file mode 100644
index 00000000000..563114fd1c4
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Converter.hpp
@@ -0,0 +1,24 @@
+// file : Utility/ExH/Converter.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_CONVERTER_HPP
+#define UTILITY_EX_H_CONVERTER_HPP
+
+#include <string>
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <typename T>
+ std::string
+ converter (T const& t);
+ }
+}
+
+#include "Utility/ExH/Converter.tpp"
+
+#endif // UTILITY_EX_H_CONVERTER_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Converter.tpp b/contrib/utility/Utility/ExH/Converter.tpp
new file mode 100644
index 00000000000..2d48015fe80
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Converter.tpp
@@ -0,0 +1,19 @@
+// file : Utility/ExH/Converter.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <typename T>
+ std::string
+ converter (T const& t)
+ {
+ // Default implementation just assumes that implicit converion exist.
+ return t;
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/ExH.hpp b/contrib/utility/Utility/ExH/ExH.hpp
new file mode 100644
index 00000000000..722ecd02d25
--- /dev/null
+++ b/contrib/utility/Utility/ExH/ExH.hpp
@@ -0,0 +1,22 @@
+// file : Utility/ExH/ExH.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_EX_H_HPP
+#define UTILITY_EX_H_EX_H_HPP
+
+#include "Utility/ExH/System/Exception.hpp"
+#include "Utility/ExH/System/DescriptiveException.hpp"
+
+#include "Utility/ExH/Logic/Exception.hpp"
+#include "Utility/ExH/Logic/DescriptiveException.hpp"
+
+#include "Utility/ExH/Compound.hpp"
+
+#include "Utility/ExH/Converter.hpp"
+#include "Utility/ExH/StringStreamConverter.hpp"
+
+#endif // UTILITY_EX_H_EX_H_HPP
+
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Logic/DescriptiveException.hpp b/contrib/utility/Utility/ExH/Logic/DescriptiveException.hpp
new file mode 100644
index 00000000000..9559014e64d
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Logic/DescriptiveException.hpp
@@ -0,0 +1,63 @@
+// file : Utility/ExH/Logic/DescriptiveException.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_LOGIC_DESCRIPTIVE_EXCEPTION_HPP
+#define UTILITY_EX_H_LOGIC_DESCRIPTIVE_EXCEPTION_HPP
+
+#include <memory>
+#include <string>
+
+
+#include "Utility/ExH/Logic/Exception.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace Logic
+ {
+ class DescriptiveException : public virtual Exception
+ {
+ public:
+ explicit
+ DescriptiveException (char const* description) throw ();
+
+ explicit
+ DescriptiveException (std::string const& description) throw ();
+
+ template <typename T>
+ explicit
+ DescriptiveException (T const& description) throw ();
+
+ DescriptiveException (DescriptiveException const& src) throw ();
+
+ virtual
+ ~DescriptiveException () throw ();
+
+ DescriptiveException&
+ operator= (DescriptiveException const& src) throw ();
+
+ protected:
+ DescriptiveException () throw ();
+
+ void
+ init (char const* description) throw ();
+
+ public:
+ virtual char const*
+ what () const throw ();
+
+ private:
+ std::auto_ptr<std::string> description_;
+ };
+ }
+ }
+}
+
+#include "Utility/ExH/Logic/DescriptiveException.ipp"
+#include "Utility/ExH/Logic/DescriptiveException.tpp"
+
+#endif // UTILITY_EX_H_LOGIC_DESCRIPTIVE_EXCEPTION_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Logic/DescriptiveException.ipp b/contrib/utility/Utility/ExH/Logic/DescriptiveException.ipp
new file mode 100644
index 00000000000..4a50a687777
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Logic/DescriptiveException.ipp
@@ -0,0 +1,104 @@
+// file : Utility/ExH/Logic/DescriptiveException.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace Logic
+ {
+ // c-tor's & d-tor
+
+ inline DescriptiveException::
+ DescriptiveException () throw ()
+ {
+ }
+
+ inline DescriptiveException::
+ DescriptiveException (char const* description) throw ()
+ {
+ init (description);
+ }
+
+ inline DescriptiveException::
+ DescriptiveException (std::string const& description) throw ()
+ {
+ try
+ {
+ init (description.c_str ());
+ }
+ catch (...)
+ {
+ }
+ }
+
+ inline DescriptiveException::
+ DescriptiveException (DescriptiveException const& src) throw ()
+ {
+ init (src.what ());
+ }
+
+ inline DescriptiveException::
+ ~DescriptiveException () throw ()
+ {
+ }
+
+ inline DescriptiveException& DescriptiveException::
+ operator= (DescriptiveException const& src) throw ()
+ {
+ init (src.what ());
+ return *this;
+ }
+
+
+ // accessors / modifiers
+
+ inline void
+ DescriptiveException::init (char const* description) throw ()
+ {
+ try
+ {
+ if (description == 0 || description[0] == '\0')
+ {
+ description_.reset (0);
+ }
+ else
+ {
+ if (description_.get () != 0)
+ {
+ *description_ = description;
+ }
+ else
+ {
+ description_.reset (new std::string (description));
+ }
+ }
+ }
+ catch (...)
+ {
+ description_.reset (0);
+ }
+ }
+
+ inline char const*
+ DescriptiveException::what () const throw ()
+ {
+ try
+ {
+ if (description_.get () != 0)
+ {
+ return description_->c_str ();
+ }
+ }
+ catch (...)
+ {
+ }
+
+ return Exception::what ();
+ }
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Logic/DescriptiveException.tpp b/contrib/utility/Utility/ExH/Logic/DescriptiveException.tpp
new file mode 100644
index 00000000000..02c65a67e2b
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Logic/DescriptiveException.tpp
@@ -0,0 +1,23 @@
+// file : Utility/ExH/Logic/DescriptiveException.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/Converter.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace Logic
+ {
+ template <typename T>
+ DescriptiveException::
+ DescriptiveException (T const& description) throw ()
+ {
+ init (converter<T> (description).c_str ());
+ }
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Logic/Exception.hpp b/contrib/utility/Utility/ExH/Logic/Exception.hpp
new file mode 100644
index 00000000000..e91e1811622
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Logic/Exception.hpp
@@ -0,0 +1,40 @@
+// file : Utility/ExH/Logic/Exception.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_LOGIC_EXCEPTION_HPP
+#define UTILITY_EX_H_LOGIC_EXCEPTION_HPP
+
+#include "Utility/ExH/System/Exception.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace Logic
+ {
+
+ // Logic::Exception inherits from System::Exception for the
+ // following reason. Semantically for some part of the
+ // system particular instance of Logic::Exception may seem as
+ // opaque System::Exception and the only way to handle it would
+ // be to propagate it further. In other words Logic::Exception
+ // can be seemlesly "converted" to System::Exception if there is
+ // no part of the system interested in handling it.
+ //
+
+ class Exception : public virtual System::Exception
+ {
+ public:
+ virtual
+ ~Exception () throw ();
+ };
+ }
+ }
+}
+
+#include "Utility/ExH/Logic/Exception.ipp"
+
+#endif // UTILITY_EX_H_LOGIC_EXCEPTION_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ExH/Logic/Exception.ipp b/contrib/utility/Utility/ExH/Logic/Exception.ipp
new file mode 100644
index 00000000000..d3b774be937
--- /dev/null
+++ b/contrib/utility/Utility/ExH/Logic/Exception.ipp
@@ -0,0 +1,20 @@
+// file : Utility/ExH/Logic/Exception.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace Logic
+ {
+ inline Exception::
+ ~Exception () throw ()
+ {
+ }
+ }
+ }
+}
+
+//$Id$
diff --git a/contrib/utility/Utility/ExH/StringStreamConverter.hpp b/contrib/utility/Utility/ExH/StringStreamConverter.hpp
new file mode 100644
index 00000000000..a9a495f22e2
--- /dev/null
+++ b/contrib/utility/Utility/ExH/StringStreamConverter.hpp
@@ -0,0 +1,26 @@
+// file : Utility/ExH/StringStreamConverter.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_STRING_STREAM_CONVERTER_HPP
+#define UTILITY_EX_H_STRING_STREAM_CONVERTER_HPP
+
+#include <sstream>
+
+#include "Utility/ExH/Converter.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <>
+ std::string
+ converter (std::ostringstream const& t);
+ }
+}
+
+#include "Utility/ExH/StringStreamConverter.ipp"
+
+#endif // UTILITY_EX_H_STRING_STREAM_CONVERTER_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ExH/StringStreamConverter.ipp b/contrib/utility/Utility/ExH/StringStreamConverter.ipp
new file mode 100644
index 00000000000..e454ac3f96c
--- /dev/null
+++ b/contrib/utility/Utility/ExH/StringStreamConverter.ipp
@@ -0,0 +1,18 @@
+// file : Utility/ExH/StringStreamConverter.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <>
+ inline std::string
+ converter (std::ostringstream const& t)
+ {
+ return t.str ();
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/System/DescriptiveException.hpp b/contrib/utility/Utility/ExH/System/DescriptiveException.hpp
new file mode 100644
index 00000000000..8bc3de8ba1e
--- /dev/null
+++ b/contrib/utility/Utility/ExH/System/DescriptiveException.hpp
@@ -0,0 +1,63 @@
+// file : Utility/ExH/System/DescriptiveException.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_SYSTEM_DESCRIPTIVE_EXCEPTION_HPP
+#define UTILITY_EX_H_SYSTEM_DESCRIPTIVE_EXCEPTION_HPP
+
+#include <string>
+#include "Utility/ExH/System/Exception.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace System
+ {
+ class DescriptiveException : public virtual Exception
+ {
+ public:
+ explicit
+ DescriptiveException (char const* description) throw ();
+
+ explicit
+ DescriptiveException (std::string const& description) throw ();
+
+ template <typename T>
+ explicit
+ DescriptiveException (T const& description) throw ();
+
+ DescriptiveException (DescriptiveException const& src) throw ();
+
+ virtual
+ ~DescriptiveException () throw ();
+
+ DescriptiveException&
+ operator= (DescriptiveException const& src) throw ();
+
+ protected:
+ DescriptiveException () throw ();
+
+ void
+ init (char const* description) throw ();
+
+ public:
+ virtual char const*
+ what () const throw ();
+
+ private:
+
+ static unsigned long const DESCRIPTION_SIZE = 256;
+
+ char description_ [DESCRIPTION_SIZE];
+ };
+ }
+ }
+}
+
+#include "Utility/ExH/System/DescriptiveException.ipp"
+#include "Utility/ExH/System/DescriptiveException.tpp"
+
+#endif // UTILITY_EX_H_SYSTEM_DESCRIPTIVE_EXCEPTION_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ExH/System/DescriptiveException.ipp b/contrib/utility/Utility/ExH/System/DescriptiveException.ipp
new file mode 100644
index 00000000000..d9768a518eb
--- /dev/null
+++ b/contrib/utility/Utility/ExH/System/DescriptiveException.ipp
@@ -0,0 +1,90 @@
+// file : Utility/ExH/System/DescriptiveException.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include <cstring>
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace System
+ {
+ // c-tor's & d-tor
+
+ inline DescriptiveException::
+ DescriptiveException () throw ()
+ {
+ description_[0] = '\0';
+ }
+
+ inline DescriptiveException::
+ DescriptiveException (char const* description) throw ()
+ {
+ init (description);
+ }
+
+ inline DescriptiveException::
+ DescriptiveException (std::string const& description) throw ()
+ {
+ try
+ {
+ init (description.c_str ());
+ }
+ catch (...)
+ {
+ }
+ }
+
+ inline DescriptiveException::
+ DescriptiveException (DescriptiveException const& src) throw ()
+ {
+ init (src.what ());
+ }
+
+ inline DescriptiveException::
+ ~DescriptiveException () throw ()
+ {
+ }
+
+ inline DescriptiveException& DescriptiveException::
+ operator= (DescriptiveException const& src) throw ()
+ {
+ init (src.what ());
+ return *this;
+ }
+
+
+ // accessors / modifiers
+
+ inline void DescriptiveException::
+ init (char const* description) throw ()
+ {
+ if (description != 0)
+ {
+ std::strncpy (description_, description, DESCRIPTION_SIZE - 1);
+ description_[DESCRIPTION_SIZE - 1] = '\0';
+ }
+ else
+ {
+ description_[0] = '\0';
+ }
+ }
+
+ inline char const* DescriptiveException::
+ what () const throw ()
+ {
+ if (description_[0] != '\0')
+ {
+ return description_;
+ }
+ else
+ {
+ return Exception::what ();
+ }
+ }
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/System/DescriptiveException.tpp b/contrib/utility/Utility/ExH/System/DescriptiveException.tpp
new file mode 100644
index 00000000000..320216acc2e
--- /dev/null
+++ b/contrib/utility/Utility/ExH/System/DescriptiveException.tpp
@@ -0,0 +1,23 @@
+// file : Utility/ExH/System/DescriptiveException.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/Converter.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace System
+ {
+ template <typename T>
+ inline DescriptiveException::
+ DescriptiveException (T const& description) throw ()
+ {
+ init (converter<T> (description).c_str ());
+ }
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ExH/System/Exception.hpp b/contrib/utility/Utility/ExH/System/Exception.hpp
new file mode 100644
index 00000000000..0ed7fbfa975
--- /dev/null
+++ b/contrib/utility/Utility/ExH/System/Exception.hpp
@@ -0,0 +1,29 @@
+// file : Utility/ExH/System/Exception.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_SYSTEM_EXCEPTION_HPP
+#define UTILITY_EX_H_SYSTEM_EXCEPTION_HPP
+
+#include <exception>
+
+namespace Utility
+{
+ namespace ExH
+ {
+ namespace System
+ {
+ // This is the only way to make predefined exceptions like
+ // std::bad_alloc, etc to appear in the right place of the hierarchy.
+ //
+
+ typedef std::exception Exception;
+ }
+ }
+}
+
+#endif // UTILITY_EX_H_SYSTEM_EXCEPTION_HPP
+
+
+//$Id$
diff --git a/contrib/utility/Utility/Hetero/Container.hpp b/contrib/utility/Utility/Hetero/Container.hpp
new file mode 100644
index 00000000000..d28d5fff0c4
--- /dev/null
+++ b/contrib/utility/Utility/Hetero/Container.hpp
@@ -0,0 +1,182 @@
+// file : Utility/Hetero/Container.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_CONTAINER_HPP
+#define UTILITY_HETERO_CONTAINER_HPP
+
+#include <typeinfo>
+
+namespace Utility
+{
+ namespace Hetero
+ {
+ //
+ //
+ //
+ class Typing {};
+
+ //
+ //
+ //
+ class Container
+ {
+ public:
+ ~Container ()
+ {
+ delete holder_;
+ }
+
+ public:
+ template <typename T>
+ Container (T const& t)
+ : holder_ (new TypedHolder<T> (t))
+ {
+ }
+
+ Container (Container const& c)
+ : holder_ (c.holder_->clone ())
+ {
+ }
+
+ public:
+ template <typename T>
+ Container&
+ operator= (T const& t)
+ {
+ delete holder_;
+ holder_ = 0;
+ holder_ = new TypedHolder<T> (t);
+ return *this;
+ }
+
+ Container&
+ operator= (Container const& c)
+ {
+ delete holder_;
+ holder_ = 0;
+ holder_ = c.holder_->clone ();
+ return *this;
+ }
+
+ public:
+ template <typename T>
+ operator T& ()
+ {
+ return value<T> ();
+ }
+
+ template <typename T>
+ operator T const& () const
+ {
+ return value<T> ();
+ }
+
+ public:
+ template <typename T>
+ T&
+ value ()
+ {
+ if (holder_->type () == typeid (T))
+ {
+ return dynamic_cast<TypedHolder<T>*>(holder_)->value ();
+ }
+ else
+ {
+ throw Typing ();
+ }
+ }
+
+ template <typename T>
+ T const&
+ value () const
+ {
+ if (holder_->type () == typeid (T))
+ {
+ return dynamic_cast<TypedHolder<T>*>(holder_)->value ();
+ }
+ else
+ {
+ throw Typing ();
+ }
+ }
+
+ public:
+ std::type_info const&
+ type () const
+ {
+ return holder_->type ();
+ }
+
+ public:
+ template <typename T>
+ friend T
+ operator+ (Container const& a, T const& b)
+ {
+ return a.value<T> () + b;
+ }
+
+ template <typename T>
+ friend T
+ operator+ (T const& a, Container const& b)
+ {
+ return a + b.value<T> ();
+ }
+
+ private:
+ struct Holder
+ {
+ virtual
+ ~Holder () {}
+
+ virtual Holder*
+ clone () const = 0;
+
+ virtual std::type_info const&
+ type () const = 0;
+ };
+
+ template <typename T>
+ struct TypedHolder : public Holder
+ {
+ TypedHolder (T const& value)
+ : value_ (value)
+ {
+ }
+
+ virtual Holder*
+ clone () const
+ {
+ return new TypedHolder<T> (value_);
+ }
+
+ virtual std::type_info const&
+ type () const
+ {
+ return typeid (T);
+ }
+
+ T const&
+ value () const
+ {
+ return value_;
+ }
+
+ T&
+ value ()
+ {
+ return value_;
+ }
+
+ private:
+ T value_;
+ };
+
+ Holder* holder_;
+ };
+ }
+}
+
+#endif // UTILITY_HETERO_CONTAINER_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Hetero/Shell.hpp b/contrib/utility/Utility/Hetero/Shell.hpp
new file mode 100644
index 00000000000..0d37a6ba09d
--- /dev/null
+++ b/contrib/utility/Utility/Hetero/Shell.hpp
@@ -0,0 +1,86 @@
+// file : Utility/Hetero/Shell.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_SHELL_HPP
+#define UTILITY_HETERO_SHELL_HPP
+
+namespace Utility
+{
+ namespace Hetero
+ {
+
+ //
+ //
+ //
+ class ShellCore
+ {
+ protected:
+ template <typename F, typename T0>
+ static typename F::RetType
+ apply (F& f, TypedContainer<TypeList<T0> >& c)
+ {
+ if (type_check <T0> (c)) return type_apply<T0> (f, c);
+
+ throw Utility::Hetero::Typing ();
+ }
+
+ template <typename F, typename T0, typename T1>
+ static typename F::RetType
+ apply (F& f, TypedContainer<TypeList<T0, T1> >& c)
+ {
+ if (type_check <T0> (c)) return type_apply<T0> (f, c);
+ if (type_check <T1> (c)) return type_apply<T1> (f, c);
+
+ throw Utility::Hetero::Typing ();
+ }
+
+ template <typename F, typename T0, typename T1, typename T2>
+ static typename F::RetType
+ apply (F& f, TypedContainer<TypeList<T0, T1, T2> >& c)
+ {
+ if (type_check <T0> (c)) return type_apply<T0> (f, c);
+ if (type_check <T1> (c)) return type_apply<T1> (f, c);
+ if (type_check <T2> (c)) return type_apply<T2> (f, c);
+
+ throw Utility::Hetero::Typing ();
+ }
+
+ private:
+ template <typename T>
+ static bool
+ type_check (Container& c)
+ {
+ return c.type () == typeid (T);
+ }
+
+ template <typename T, typename F>
+ static typename F::RetType
+ type_apply (F& f, Container& c)
+ {
+ return f (c. template value<T> ());
+ }
+ };
+
+
+ //
+ //
+ //
+ template <typename F>
+ struct Shell : F, ShellCore
+ {
+ using F::operator ();
+
+ template <typename T>
+ typename F::RetType
+ operator () (TypedContainer<T>& p)
+ {
+ return apply (*this, p);
+ }
+ };
+ }
+}
+
+#endif // UTILITY_HETERO_SHELL_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Hetero/TypeList.hpp b/contrib/utility/Utility/Hetero/TypeList.hpp
new file mode 100644
index 00000000000..ee7e96c2bcd
--- /dev/null
+++ b/contrib/utility/Utility/Hetero/TypeList.hpp
@@ -0,0 +1,46 @@
+// file : Utility/Hetero/TypeList.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_TYPE_LIST_HPP
+#define UTILITY_HETERO_TYPE_LIST_HPP
+
+namespace Utility
+{
+ namespace Hetero
+ {
+ class NullType {};
+
+ template <typename t0 = NullType,
+ typename t1 = NullType,
+ typename t2 = NullType>
+ struct TypeList
+ {
+ typedef t0 T0;
+ typedef t1 T1;
+ typedef t2 T2;
+ };
+
+ template <typename t0, typename t1>
+ struct TypeList<t0, t1, NullType>
+ {
+ typedef t0 T0;
+ typedef t1 T1;
+ };
+
+ template <typename t0>
+ struct TypeList<t0, NullType, NullType>
+ {
+ typedef t0 T0;
+ };
+
+ template <>
+ struct TypeList<NullType, NullType, NullType>
+ {
+ };
+ }
+}
+
+#endif // UTILITY_HETERO_TYPE_LIST_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Hetero/TypedContainer.hpp b/contrib/utility/Utility/Hetero/TypedContainer.hpp
new file mode 100644
index 00000000000..67f94bda0ec
--- /dev/null
+++ b/contrib/utility/Utility/Hetero/TypedContainer.hpp
@@ -0,0 +1,57 @@
+// file : Utility/Hetero/TypedContainer.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_TYPED_CONTAINER_HPP
+#define UTILITY_HETERO_TYPED_CONTAINER_HPP
+
+#include "Utility/Hetero/Container.hpp"
+#include "Utility/Hetero/TypeList.hpp"
+
+namespace Utility
+{
+ namespace Hetero
+ {
+ template <typename TL>
+ class TypedContainer : public Container
+ {
+ public:
+ typedef TL Types;
+
+ public:
+ template <typename T>
+ TypedContainer (T const& t)
+ : Container (t)
+ {
+ }
+
+ TypedContainer (TypedContainer const& c)
+ : Container (static_cast<Container const&> (c))
+ {
+ }
+
+ public:
+ template <typename T>
+ TypedContainer&
+ operator= (T const& t)
+ {
+ Container& self = *this;
+ self = t;
+ return *this;
+ }
+
+ TypedContainer&
+ operator= (TypedContainer const& c)
+ {
+ Container& self = *this;
+ Container const& other = c;
+ self = other;
+ return *this;
+ }
+ };
+ }
+}
+
+#endif // UTILITY_HETERO_TYPED_CONTAINER_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Hetero/Vector.hpp b/contrib/utility/Utility/Hetero/Vector.hpp
new file mode 100644
index 00000000000..3826bd6bb1f
--- /dev/null
+++ b/contrib/utility/Utility/Hetero/Vector.hpp
@@ -0,0 +1,47 @@
+// file : Utility/Hetero/Vector.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_VECTOR_HPP
+#define UTILITY_HETERO_VECTOR_HPP
+
+#include <vector>
+
+#include "Utility/Hetero/TypeList.hpp"
+#include "Utility/Hetero/TypedContainer.hpp"
+
+namespace Utility
+{
+ namespace Hetero
+ {
+ template <typename T0 = NullType,
+ typename T1 = NullType,
+ typename T2 = NullType>
+ class Vector;
+
+ template <>
+ class Vector<NullType, NullType, NullType>;
+
+ template <typename T0>
+ class Vector<T0, NullType, NullType> :
+ public std::vector<TypedContainer<TypeList<T0> > >
+ {
+ };
+
+ template <typename T0, typename T1>
+ class Vector<T0, T1, NullType> :
+ public std::vector<TypedContainer<TypeList<T0, T1> > >
+ {
+ };
+
+ template <typename T0, typename T1, typename T2>
+ class Vector :
+ public std::vector<TypedContainer<TypeList<T0, T1, T2> > >
+ {
+ };
+ }
+}
+
+#endif // UTILITY_HETERO_VECTOR_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/Introspection.hpp b/contrib/utility/Utility/Introspection/Introspection.hpp
new file mode 100644
index 00000000000..d514f62837a
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/Introspection.hpp
@@ -0,0 +1,14 @@
+// file : Utility/Introspection/Introspection.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_INTROSPECTION_INTROSPECTION_HPP
+#define UTILITY_INTROSPECTION_INTROSPECTION_HPP
+
+#include "Utility/Introspection/TypeId.hpp"
+#include "Utility/Introspection/TypeInfo.hpp"
+#include "Utility/Introspection/Object.hpp"
+
+#endif // UTILITY_INTROSPECTION_INTROSPECTION_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/Makefile b/contrib/utility/Utility/Introspection/Makefile
new file mode 100644
index 00000000000..43f2f67cb51
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/Makefile
@@ -0,0 +1,19 @@
+# file : Utility/Introspection/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/Archive.pre.rules)
+
+cxx_translation_units := TypeId.cpp Object.cpp
+
+module_base := Introspection
+
+CXX_PREPROCESS_FLAGS += -I $(root)
+
+$(call include, $(root)/BuildRules/Archive.post.rules)
+# $Id$
diff --git a/contrib/utility/Utility/Introspection/Object.cpp b/contrib/utility/Utility/Introspection/Object.cpp
new file mode 100644
index 00000000000..015a2736aad
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/Object.cpp
@@ -0,0 +1,24 @@
+// file : Utility/Introspection/Object.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/Introspection/Object.hpp"
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ namespace
+ {
+ TypeInfo object_ (typeid (Object));
+ }
+
+ TypeInfo const& Object::
+ static_type_info () throw ()
+ {
+ return object_;
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/Object.hpp b/contrib/utility/Utility/Introspection/Object.hpp
new file mode 100644
index 00000000000..fdf8228c9f3
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/Object.hpp
@@ -0,0 +1,47 @@
+// file : Utility/Introspection/Object.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_INTROSPECTION_OBJECT_HPP
+#define UTILITY_INTROSPECTION_OBJECT_HPP
+
+#include "Utility/Introspection/TypeInfo.hpp"
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ class Object
+ {
+ public:
+ static TypeInfo const&
+ static_type_info () throw ();
+
+ virtual TypeInfo const&
+ type_info () const throw ();
+
+ protected:
+ virtual
+ ~Object ();
+
+ Object () throw ();
+ Object (Object const&) throw ();
+
+ Object&
+ operator= (Object const&) throw ();
+
+ protected:
+ virtual void
+ type_info (TypeInfo const& tid) throw ();
+
+ private:
+ TypeInfo const* type_info_;
+ };
+ }
+}
+
+#include "Utility/Introspection/Object.ipp"
+
+#endif // UTILITY_INTROSPECTION_OBJECT_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/Object.ipp b/contrib/utility/Utility/Introspection/Object.ipp
new file mode 100644
index 00000000000..7b5de978c6e
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/Object.ipp
@@ -0,0 +1,48 @@
+// file : Utility/Introspection/Object.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ inline TypeInfo const& Object::
+ type_info () const throw ()
+ {
+ return *type_info_;
+ }
+
+ inline Object::
+ ~Object ()
+ {
+ }
+
+ inline Object::
+ Object () throw ()
+ {
+ type_info (static_type_info ());
+ }
+
+
+ inline Object::
+ Object (Object const&) throw ()
+ {
+ type_info (static_type_info ());
+ }
+
+
+ inline Object& Object::
+ operator= (Object const&) throw ()
+ {
+ return *this;
+ }
+
+ inline void Object::
+ type_info (TypeInfo const& tid) throw ()
+ {
+ type_info_ = &tid;
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/TypeId.cpp b/contrib/utility/Utility/Introspection/TypeId.cpp
new file mode 100644
index 00000000000..a0ceddac2a1
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/TypeId.cpp
@@ -0,0 +1,21 @@
+// file : Utility/Introspection/TypeId.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/Introspection/TypeId.hpp"
+
+#include <ostream>
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ std::ostream&
+ operator << (std::ostream& os, TypeId const& t)
+ {
+ return os << t.tid_->name ();
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/TypeId.hpp b/contrib/utility/Utility/Introspection/TypeId.hpp
new file mode 100644
index 00000000000..51f66f99a0b
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/TypeId.hpp
@@ -0,0 +1,47 @@
+// file : Utility/Introspection/TypeId.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_INTROSPECTION_TYPE_ID_HPP
+#define UTILITY_INTROSPECTION_TYPE_ID_HPP
+
+#include <typeinfo>
+#include <iosfwd>
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ class TypeId
+ {
+ public:
+ template<typename T>
+ TypeId (T const& t);
+
+ TypeId (std::type_info const& tid);
+
+ public:
+ bool
+ operator == (TypeId const& other) const;
+
+ bool
+ operator != (TypeId const& other) const;
+
+ bool
+ operator < (TypeId const& other) const;
+
+ friend std::ostream&
+ operator << (std::ostream& os, TypeId const& t);
+
+ private:
+ std::type_info const* tid_;
+ };
+ }
+}
+
+#include "Utility/Introspection/TypeId.tpp"
+#include "Utility/Introspection/TypeId.ipp"
+
+#endif // UTILITY_INTROSPECTION_TYPE_ID_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/TypeId.ipp b/contrib/utility/Utility/Introspection/TypeId.ipp
new file mode 100644
index 00000000000..83a5a503517
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/TypeId.ipp
@@ -0,0 +1,37 @@
+// file : Utility/Introspection/TypeId.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+// cvs-id : $Id$
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ inline TypeId::
+ TypeId (std::type_info const& tid)
+ : tid_ (&tid)
+ {
+ }
+
+
+ inline bool TypeId::
+ operator == (TypeId const& other) const
+ {
+ return *tid_ == *other.tid_;
+ }
+
+ inline bool TypeId::
+ operator != (TypeId const& other) const
+ {
+ return *tid_ != *other.tid_;
+ }
+
+ inline bool TypeId::
+ operator < (TypeId const& other) const
+ {
+ return tid_->before (*other.tid_);
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/TypeId.tpp b/contrib/utility/Utility/Introspection/TypeId.tpp
new file mode 100644
index 00000000000..7c3daef603c
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/TypeId.tpp
@@ -0,0 +1,18 @@
+// file : Utility/Introspection/TypeId.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ template<typename T>
+ inline TypeId::
+ TypeId (T const& t)
+ : tid_ (&typeid (t))
+ {
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/TypeInfo.hpp b/contrib/utility/Utility/Introspection/TypeInfo.hpp
new file mode 100644
index 00000000000..4321fdc522c
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/TypeInfo.hpp
@@ -0,0 +1,104 @@
+// file : Utility/Introspection/TypeInfo.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_INTROSPECTION_TYPE_INFO_HPP
+#define UTILITY_INTROSPECTION_TYPE_INFO_HPP
+
+#include <vector>
+
+#include "Utility/Introspection/TypeId.hpp"
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ //
+ //
+ //
+ struct Access
+ {
+ enum Value
+ {
+ PRIVATE,
+ PROTECTED,
+ PUBLIC
+ };
+ };
+
+ // Forward declaration of class TypeInfo.
+ //
+ //
+ class TypeInfo;
+
+ //
+ //
+ //
+ class BaseInfo
+ {
+ public:
+ BaseInfo (Access::Value access,
+ bool virtual_base,
+ TypeInfo const& ti);
+
+ public:
+ TypeInfo const&
+ type_info () const;
+
+ Access::Value
+ access () const;
+
+ bool
+ virtual_base () const;
+
+ private:
+ TypeInfo const* ti_;
+ bool virtual_base_;
+ Access::Value access_;
+ };
+
+
+ //
+ //
+ //
+ class TypeInfo
+ {
+ private:
+ typedef
+ std::vector<BaseInfo>
+ BaseInfoList;
+
+ public:
+ typedef
+ BaseInfoList::const_iterator
+ BaseIterator;
+
+ public:
+ TypeInfo (TypeId const& tid);
+
+ TypeId
+ type_id () const;
+
+ BaseIterator
+ begin_base () const;
+
+ BaseIterator
+ end_base () const;
+
+ void
+ add_base (Access::Value access,
+ bool virtual_base,
+ TypeInfo const& ti);
+
+ private:
+ TypeId tid_;
+ BaseInfoList base_;
+ };
+ }
+}
+
+#include "Utility/Introspection/TypeInfo.ipp"
+
+#endif // UTILITY_INTROSPECTION_TYPE_INFO_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Introspection/TypeInfo.ipp b/contrib/utility/Utility/Introspection/TypeInfo.ipp
new file mode 100644
index 00000000000..395cf7d6539
--- /dev/null
+++ b/contrib/utility/Utility/Introspection/TypeInfo.ipp
@@ -0,0 +1,77 @@
+// file : Utility/Introspection/TypeInfo.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace Introspection
+ {
+ // BaseInfo
+ //
+ //
+
+ inline BaseInfo::
+ BaseInfo (Access::Value access, bool virtual_base, TypeInfo const& ti)
+ : ti_ (&ti),
+ virtual_base_ (virtual_base),
+ access_ (access)
+ {
+ }
+
+ inline TypeInfo const& BaseInfo::
+ type_info () const
+ {
+ return *ti_;
+ }
+
+
+ inline Access::Value BaseInfo::
+ access () const
+ {
+ return access_;
+ }
+
+ inline bool BaseInfo::
+ virtual_base () const
+ {
+ return virtual_base_;
+ }
+
+
+ // TypeInfo
+ //
+ //
+ inline TypeInfo::
+ TypeInfo (TypeId const& tid)
+ : tid_ (tid)
+ {
+ }
+
+ inline TypeId TypeInfo::
+ type_id () const
+ {
+ return tid_;
+ }
+
+ inline TypeInfo::BaseIterator TypeInfo::
+ begin_base () const
+ {
+ return base_.begin ();
+ }
+
+
+ inline TypeInfo::BaseIterator TypeInfo::
+ end_base () const
+ {
+ return base_.end ();
+ }
+
+ inline void TypeInfo::
+ add_base (Access::Value access, bool virtual_base, TypeInfo const& ti)
+ {
+ base_.push_back (BaseInfo (access, virtual_base, ti));
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Makefile b/contrib/utility/Utility/Makefile
new file mode 100644
index 00000000000..e6951f317fa
--- /dev/null
+++ b/contrib/utility/Utility/Makefile
@@ -0,0 +1,16 @@
+# file : Utility/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 := Introspection
+
+$(call include, $(root)/BuildRules/Recursion.post.rules)
+# $Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/DefaultImpl.hpp b/contrib/utility/Utility/ReferenceCounting/DefaultImpl.hpp
new file mode 100644
index 00000000000..43160c09a03
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/DefaultImpl.hpp
@@ -0,0 +1,96 @@
+// file : Utility/ReferenceCounting/DefaultImpl.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_REFERENCE_COUNTING_DEFAULT_IMPL_HPP
+#define UTILITY_REFERENCE_COUNTING_DEFAULT_IMPL_HPP
+
+#include "Utility/ExH/Compound.hpp"
+#include "Utility/ExH/Logic/DescriptiveException.hpp"
+
+#include "Utility/Synch/Policy/Null.hpp"
+
+#include "Utility/ReferenceCounting/Interface.hpp"
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ // Default reference counter implementation with parameterised
+ // synchronization policy. It is assumed that none of the SynchPolicy
+ // types throw any logic exceptions. If in fact they do then these
+ // exceptions won't be handled and will be automatically converted
+ // to system exceptions.
+
+ template <typename SynchPolicy = Utility::Synch::Policy::Null>
+ class DefaultImpl : public virtual Interface
+ {
+ public:
+ class InconsistentState_ {};
+ typedef
+ ExH::Compound<InconsistentState_, Exception>
+ InconsistentState;
+
+ public:
+ DefaultImpl () throw (SystemException);
+
+ virtual
+ ~DefaultImpl () throw ();
+
+ public:
+ virtual void
+ add_ref () const throw (Exception, SystemException);
+
+ virtual void
+ remove_ref () const throw ();
+
+ virtual count_t
+ refcount_value () const throw (Exception, SystemException);
+
+ protected:
+ virtual void
+ add_ref_i () const throw (Exception, SystemException);
+
+ virtual bool
+ remove_ref_i () const throw (Exception, SystemException);
+
+ virtual count_t
+ refcount_value_i () const throw (Exception, SystemException);
+
+ typename SynchPolicy::Mutex&
+ lock_i () const throw ();
+
+ protected:
+ typedef
+ typename SynchPolicy::Mutex
+ Mutex_;
+
+ typedef
+ typename SynchPolicy::ReadGuard
+ ReadGuard_;
+
+ typedef
+ typename SynchPolicy::WriteGuard
+ WriteGuard_;
+
+ protected:
+ mutable count_t ref_count_;
+
+ private:
+ mutable Mutex_ lock_;
+
+ private:
+ // Copy semanic is not supported.
+ DefaultImpl (DefaultImpl const&) throw ();
+ DefaultImpl&
+ operator= (DefaultImpl const&) throw ();
+ };
+ }
+}
+
+#include "Utility/ReferenceCounting/DefaultImpl.ipp"
+
+#endif // UTILITY_REFERENCE_COUNTING_DEFAULT_IMPL_HPP
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/DefaultImpl.ipp b/contrib/utility/Utility/ReferenceCounting/DefaultImpl.ipp
new file mode 100644
index 00000000000..bac28c77ea2
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/DefaultImpl.ipp
@@ -0,0 +1,105 @@
+// file : Utility/ReferenceCounting/DefaultImpl.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ // c-tor & d-tor
+
+ template <typename SynchPolicy>
+ DefaultImpl<SynchPolicy>::
+ DefaultImpl () throw (Interface::SystemException)
+ : ref_count_ (1),
+ lock_ ()
+ {
+ }
+
+ template <typename SynchPolicy>
+ DefaultImpl<SynchPolicy>::
+ ~DefaultImpl () throw ()
+ {
+ }
+
+ // add_ref, remove_ref and refcount_value member functions
+
+ template <typename SynchPolicy>
+ void DefaultImpl<SynchPolicy>::
+ add_ref () const throw (Exception, SystemException)
+ {
+ WriteGuard_ guard (lock_);
+ add_ref_i ();
+ }
+
+ template <typename SynchPolicy>
+ void DefaultImpl<SynchPolicy>::
+ remove_ref () const throw ()
+ {
+ bool destroy (false);
+ try
+ {
+ WriteGuard_ guard (lock_);
+ destroy = remove_ref_i ();
+ }
+ catch (...)
+ {
+ // there is nothing we can do
+ }
+
+ if (destroy) delete this;
+ }
+
+ template <typename SynchPolicy>
+ Interface::count_t DefaultImpl<SynchPolicy>::
+ refcount_value () const throw (Exception, SystemException)
+ {
+ ReadGuard_ guard (lock_);
+ return refcount_value_i ();
+ }
+
+ // add_ref_i, remove_ref_i and refcount_value_i member functions
+
+ template <typename SynchPolicy>
+ void DefaultImpl<SynchPolicy>::
+ add_ref_i () const throw (Exception, SystemException)
+ {
+ ref_count_++;
+ }
+
+ template <typename SynchPolicy>
+ bool DefaultImpl<SynchPolicy>::
+ remove_ref_i () const throw (Exception, SystemException)
+ {
+ bool destroy (false);
+ if (ref_count_ > 0)
+ {
+ if (--ref_count_ == 0) destroy = true;
+ }
+ else
+ {
+ throw InconsistentState (
+ "Utility::ReferenceCounting::DefaultImpl::_remove_ref_i: "
+ "reference counter is zero.");
+ }
+ return destroy;
+
+ }
+
+ template <typename SynchPolicy>
+ Interface::count_t DefaultImpl<SynchPolicy>::
+ refcount_value_i () const throw (Exception, SystemException)
+ {
+ return ref_count_;
+ }
+
+ template <typename SynchPolicy>
+ typename SynchPolicy::Mutex& DefaultImpl<SynchPolicy>::
+ lock_i() const throw ()
+ {
+ return lock_;
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.hpp b/contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.hpp
new file mode 100644
index 00000000000..20346e859b3
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.hpp
@@ -0,0 +1,60 @@
+// file : Utility/ReferenceCounting/ExternalLockImpl.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_REFERENCE_COUNTING_EXTERNAL_LOCK_IMPL_HPP
+#define UTILITY_REFERENCE_COUNTING_EXTERNAL_LOCK_IMPL_HPP
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+
+ /*
+
+ Not ported yet.
+
+ class ExternalLockRefCounter : public virtual Util::RefCountBase
+ {
+ public:
+ ExternalLockRefCounter (ACE_Lock* lock = 0);
+ virtual ~ExternalLockRefCounter ();
+
+ void init (ACE_Lock* lock);
+
+ public:
+
+ virtual void _add_ref ();
+ virtual void _remove_ref ();
+ virtual unsigned long _refcount_value ();
+
+ protected:
+
+ virtual void _add_ref_i ();
+ virtual bool _remove_ref_i ();
+ virtual unsigned long _refcount_value_i ();
+
+ ACE_Lock* lock_i ();
+
+ private:
+
+ typedef ACE_Guard <ACE_Lock> Guard_;
+
+ ACE_Lock* lock_;
+ unsigned long ref_count_;
+
+ private:
+ ExternalLockRefCounter (const ExternalLockRefCounter& );
+ void operator= (const ExternalLockRefCounter& );
+ };
+
+ */
+ }
+}
+
+#include "Utility/ReferenceCounting/ExternalLockImpl.ipp"
+
+#endif // UTILITY_REFERENCE_COUNTING_EXTERNAL_LOCK_IMPL_HPP
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.ipp b/contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.ipp
new file mode 100644
index 00000000000..7552d411f27
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/ExternalLockImpl.ipp
@@ -0,0 +1,122 @@
+// file : Utility/ReferenceCounting/ExternalLockImpl.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ /*
+ inline
+ ExternalLockRefCounter::ExternalLockRefCounter (ACE_Lock* lock)
+ : lock_ (lock),
+ ref_count_ (1)
+ {
+ }
+
+ inline
+ void
+ ExternalLockRefCounter::init (ACE_Lock* lock)
+ {
+ lock_ = lock;
+ }
+
+ inline
+ ExternalLockRefCounter::~ExternalLockRefCounter ()
+ {
+ }
+
+ inline
+ ACE_Lock*
+ ExternalLockRefCounter::lock_i ()
+ {
+ return lock_;
+ }
+
+ inline
+ void
+ ExternalLockRefCounter::_add_ref ()
+ {
+ if (lock_)
+ {
+ Guard_ guard (*lock_);
+ _add_ref_i ();
+ }
+ else
+ {
+ _add_ref_i ();
+ }
+ }
+
+ inline
+ void
+ ExternalLockRefCounter::_remove_ref ()
+ {
+ bool destroy = false;
+ {
+ if (lock_)
+ {
+ Guard_ guard (*lock_);
+ destroy = _remove_ref_i ();
+ }
+ else
+ {
+ destroy = _remove_ref_i ();
+ }
+ }
+ if (destroy) delete this;
+ }
+
+ inline
+ unsigned long
+ ExternalLockRefCounter::_refcount_value ()
+ {
+ if (lock_)
+ {
+ Guard_ guard (*lock_);
+ return _refcount_value_i ();
+ }
+ else
+ {
+ return _refcount_value_i ();
+ }
+ }
+
+ inline
+ void
+ ExternalLockRefCounter::_add_ref_i ()
+ {
+ ref_count_++;
+ }
+
+ inline
+ bool
+ ExternalLockRefCounter::_remove_ref_i ()
+ {
+ bool destroy = false;
+ if (ref_count_ > 0)
+ {
+ if (--ref_count_ == 0) destroy = true;
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "ExternalLockRefCounter::_remove_ref() "
+ " _remove_ref() called while ref_coundt == 0\n"
+ ));
+ }
+ return destroy;
+ }
+
+ inline
+ unsigned long
+ ExternalLockRefCounter::_refcount_value_i ()
+ {
+ return ref_count_;
+ }
+ */
+ }
+}
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/Interface.hpp b/contrib/utility/Utility/ReferenceCounting/Interface.hpp
new file mode 100644
index 00000000000..9231860b84a
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/Interface.hpp
@@ -0,0 +1,84 @@
+// file : Utility/ReferenceCounting/Interface.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_REFERENCE_COUNTING_INTERFACE_HPP
+#define UTILITY_REFERENCE_COUNTING_INTERFACE_HPP
+
+#include "Utility/ExH/Compound.hpp"
+#include "Utility/ExH/System/Exception.hpp"
+#include "Utility/ExH/Logic/Exception.hpp"
+#include "Utility/ExH/Logic/DescriptiveException.hpp"
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ // Interface to a reference-countable object. Note that _remove_ref ()
+ // member function has a no-throw semantic. Even though it can lead to
+ // a diagnostic loss it was made no-throw because it has a destructor
+ // semantic.
+
+ class Interface
+ {
+ public:
+ typedef
+ unsigned long
+ count_t;
+
+ typedef
+ ExH::System::Exception
+ SystemException;
+
+ class Exception_ {};
+ typedef
+ ExH::Compound<Exception_, ExH::Logic::DescriptiveException>
+ Exception;
+
+ public:
+ virtual void
+ add_ref () const throw (Exception, SystemException) = 0;
+
+ virtual void
+ remove_ref () const throw () = 0;
+
+ virtual count_t
+ refcount_value () const throw (Exception, SystemException) = 0;
+
+ protected:
+ Interface () throw ();
+
+ virtual
+ ~Interface () throw ();
+
+ protected:
+ virtual void
+ add_ref_i () const throw (Exception, SystemException) = 0;
+
+ virtual bool
+ remove_ref_i () const throw (Exception, SystemException) = 0;
+
+ virtual count_t
+ refcount_value_i () const throw (Exception, SystemException) = 0;
+
+ private:
+ // Copy semanic is not supported.
+ Interface (Interface const&) throw ();
+ Interface&
+ operator= (Interface const&) throw ();
+ };
+
+ template <typename Type>
+ Type*
+ add_ref (Type* ptr)
+ throw (Interface::Exception, Interface::SystemException);
+ }
+}
+
+#include "Utility/ReferenceCounting/Interface.tpp"
+#include "Utility/ReferenceCounting/Interface.ipp"
+
+#endif // UTILITY_REFERENCE_COUNTING_INTERFACE_HPP
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/Interface.ipp b/contrib/utility/Utility/ReferenceCounting/Interface.ipp
new file mode 100644
index 00000000000..f901db4b248
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/Interface.ipp
@@ -0,0 +1,22 @@
+// file : Utility/ReferenceCounting/Interface.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ inline Interface::
+ ~Interface () throw ()
+ {
+ }
+
+ inline Interface::
+ Interface () throw ()
+ {
+ }
+ }
+}
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/Interface.tpp b/contrib/utility/Utility/ReferenceCounting/Interface.tpp
new file mode 100644
index 00000000000..6a6a1d2d263
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/Interface.tpp
@@ -0,0 +1,20 @@
+// file : Utility/ReferenceCounting/Interface.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ template <typename Type>
+ inline Type*
+ add_ref (Type* ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ if (ptr != 0) ptr->add_ref ();
+ return ptr;
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/ReferenceCounting.hpp b/contrib/utility/Utility/ReferenceCounting/ReferenceCounting.hpp
new file mode 100644
index 00000000000..a20fe0d888c
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/ReferenceCounting.hpp
@@ -0,0 +1,16 @@
+// file : Utility/ReferenceCounting/ReferenceCounting.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_REFERENCE_COUNTING_REFERENCE_COUNTING_HPP
+#define UTILITY_REFERENCE_COUNTING_REFERENCE_COUNTING_HPP
+
+#include "Utility/ReferenceCounting/Interface.hpp"
+#include "Utility/ReferenceCounting/DefaultImpl.hpp"
+#include "Utility/ReferenceCounting/SmartPtr.hpp"
+#include "Utility/ReferenceCounting/StrictPtr.hpp"
+
+#endif // UTILITY_REFERENCE_COUNTING_REFERENCE_COUNTING_HPP
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/SmartPtr.hpp b/contrib/utility/Utility/ReferenceCounting/SmartPtr.hpp
new file mode 100644
index 00000000000..682f0678ee1
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/SmartPtr.hpp
@@ -0,0 +1,103 @@
+// file : Utility/ReferenceCounting/SmartPtr.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_REFERENCE_COUNTING_SMART_PTR_HPP
+#define UTILITY_REFERENCE_COUNTING_SMART_PTR_HPP
+
+#include "Utility/ExH/Compound.hpp"
+#include "Utility/ExH/Logic/DescriptiveException.hpp"
+
+#include "Utility/ReferenceCounting/Interface.hpp"
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ template <typename T>
+ class SmartPtr
+ {
+ public:
+ typedef
+ T
+ Type;
+
+ class NotInitialized_ {};
+ typedef
+ ExH::Compound<NotInitialized_, ExH::Logic::DescriptiveException>
+ NotInitialized;
+
+ public:
+ // c-tor's
+
+ SmartPtr () throw ();
+ SmartPtr (Type* ptr) throw ();
+ SmartPtr (SmartPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ template <typename Other>
+ SmartPtr (SmartPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ // d-tor
+
+ ~SmartPtr () throw ();
+
+ // assignment & copy-assignment operators
+
+ SmartPtr<Type>&
+ operator= (Type* ptr) throw ();
+
+ SmartPtr<Type>&
+ operator= (SmartPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ template <typename Other>
+ SmartPtr<Type>&
+ operator= (SmartPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ //conversions
+
+ operator Type* () const throw ();
+
+ // accessors
+
+ Type*
+ operator-> () const throw (NotInitialized);
+
+ Type*
+ in () const throw ();
+
+ Type*
+ retn() throw ();
+
+ private:
+ Type* ptr_;
+ };
+
+ // Specialization of add_ref function for SmartPtr<T>
+ template <typename T>
+ T*
+ add_ref (SmartPtr<T> const& ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+
+ // Dynamic type conversion function for SmartPtr's
+ template <typename D, typename S>
+ D*
+ smart_cast (SmartPtr<S> const& s)
+ throw (Interface::Exception, Interface::SystemException);
+
+ // Acquisition function
+ template <typename T>
+ SmartPtr<T>
+ acquire (T* ptr) throw (Interface::Exception, Interface::SystemException);
+ }
+}
+
+#include "Utility/ReferenceCounting/SmartPtr.tpp"
+
+#endif // UTILITY_REFERENCE_COUNTING_SMART_PTR_HPP
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/SmartPtr.tpp b/contrib/utility/Utility/ReferenceCounting/SmartPtr.tpp
new file mode 100644
index 00000000000..6596c67f1b1
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/SmartPtr.tpp
@@ -0,0 +1,170 @@
+// file : Utility/ReferenceCounting/SmartPtr.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ // c-tor's & d-tor
+
+ template <typename T>
+ SmartPtr<T>::
+ SmartPtr () throw ()
+ : ptr_ (0)
+ {
+ }
+
+ template <typename T>
+ SmartPtr<T>::
+ SmartPtr (Type* ptr) throw ()
+ : ptr_ (ptr)
+ {
+ }
+
+ template <typename T>
+ SmartPtr<T>::
+ SmartPtr (SmartPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ : ptr_ (add_ref (s_ptr.in ()))
+ {
+ }
+
+ template <typename T>
+ template <typename Other>
+ SmartPtr<T>::
+ SmartPtr (SmartPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ : ptr_ (add_ref (s_ptr.in ()))
+ {
+ }
+
+
+ template <typename T>
+ SmartPtr<T>::
+ ~SmartPtr () throw ()
+ {
+ // This is an additional catch-all layer to protect from
+ // non-conformant Type.
+ try
+ {
+ if (ptr_ != 0) ptr_->remove_ref ();
+ }
+ catch (...)
+ {
+ }
+ }
+
+ // operator=
+
+ template <typename T>
+ SmartPtr<T>& SmartPtr<T>::
+ operator= (Type* ptr) throw ()
+ {
+ if (ptr_ != 0) ptr_->remove_ref ();
+ ptr_ = ptr;
+ return *this;
+ }
+
+
+ template <typename T>
+ SmartPtr<T>& SmartPtr<T>::
+ operator= (SmartPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ Type* old_ptr (ptr_);
+ Type* new_ptr (add_ref (s_ptr.in ())); // this can throw
+ if (old_ptr != 0) old_ptr->remove_ref ();
+
+ ptr_ = new_ptr; // commit
+
+ return *this;
+ }
+
+
+ template <typename T>
+ template <typename Other>
+ SmartPtr<T>& SmartPtr<T>::
+ operator= (SmartPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ Type* old_ptr (ptr_);
+ Other* new_ptr (add_ref (s_ptr.in ())); // this can throw
+ if (old_ptr != 0) old_ptr->remove_ref ();
+
+ ptr_ = new_ptr; // commit
+
+ return *this;
+ }
+
+ // conversions
+
+ template <typename T>
+ SmartPtr<T>::
+ operator T* () const throw ()
+ {
+ return ptr_;
+ }
+
+
+ // accessors
+
+ template <typename T>
+ T* SmartPtr<T>::
+ operator-> () const throw (NotInitialized)
+ {
+ if (ptr_ == 0)
+ {
+ throw NotInitialized(
+ "Utility::ReferenceCounting::SmartPtr::operator-> : "
+ "unable to dereference NULL pointer.");
+ }
+ return ptr_;
+ }
+
+ template <typename T>
+ T* SmartPtr<T>::
+ in () const throw ()
+ {
+ return ptr_;
+ }
+
+ template <typename T>
+ T* SmartPtr<T>::
+ retn() throw ()
+ {
+ Type* ret (ptr_);
+ ptr_ = 0;
+ return ret;
+ }
+
+ // Specialization of add_ref function for SmartPtr<T>
+ template <typename T>
+ T*
+ add_ref (SmartPtr<T> const& ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ // delegate to generic implementation
+ return add_ref (ptr.in ());
+ }
+
+ // Dynamic type conversion function for SmartPtr's
+ template <typename D, typename S>
+ D*
+ smart_cast (SmartPtr<S> const& s)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ return add_ref (dynamic_cast<D*>(s.in ()));
+ }
+
+ // Acquisition function
+ template <typename T>
+ SmartPtr<T>
+ acquire (T* ptr) throw (Interface::Exception, Interface::SystemException)
+ {
+ return SmartPtr<T> (ptr);
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/StrictPtr.hpp b/contrib/utility/Utility/ReferenceCounting/StrictPtr.hpp
new file mode 100644
index 00000000000..c88c90d5e50
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/StrictPtr.hpp
@@ -0,0 +1,108 @@
+// file : Utility/ReferenceCounting/StrictPtr.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_REFERENCE_COUNTING_STRICT_PTR_HPP
+#define UTILITY_REFERENCE_COUNTING_STRICT_PTR_HPP
+
+#include "Utility/ExH/Compound.hpp"
+#include "Utility/ExH/Logic/DescriptiveException.hpp"
+
+#include "Utility/ReferenceCounting/Interface.hpp"
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ template <typename T>
+ class StrictPtr
+ {
+ public:
+ typedef
+ T
+ Type;
+
+ class NotInitialized_ {};
+ typedef
+ ExH::Compound<NotInitialized_, ExH::Logic::DescriptiveException>
+ NotInitialized;
+
+ public:
+ // c-tor's
+
+ StrictPtr () throw ();
+
+ explicit
+ StrictPtr (Type* ptr) throw ();
+
+ StrictPtr (StrictPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ template <typename Other>
+ StrictPtr (StrictPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+ // d-tor
+
+ ~StrictPtr () throw ();
+
+ // assignment & copy-assignment operators
+
+ StrictPtr<Type>&
+ operator= (Type* ptr) throw ();
+
+ StrictPtr<Type>&
+ operator= (StrictPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ template <typename Other>
+ StrictPtr<Type>&
+ operator= (StrictPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ // conversions
+
+ // Note: implicit conversion (operator Type* ()) is not supported.
+
+ // comparison
+
+ bool
+ operator== (Type* other) const throw ();
+
+ bool
+ operator!= (Type* other) const throw ();
+
+ // accessors
+
+ Type*
+ operator-> () const throw (NotInitialized);
+
+ Type*
+ in () const throw ();
+
+ Type*
+ retn() throw ();
+
+ private:
+ Type* ptr_;
+ };
+
+ // Specialization of add_ref function for StrictPtr<T>
+ template <typename T>
+ T*
+ add_ref (StrictPtr<T> const& ptr)
+ throw (Interface::Exception, Interface::SystemException);
+
+ // Dynamic type conversion function for StrictPtr's
+ template <typename D, typename S>
+ StrictPtr<D>
+ strict_cast (StrictPtr<S> const& s)
+ throw (Interface::Exception, Interface::SystemException);
+ }
+}
+
+#include "Utility/ReferenceCounting/StrictPtr.tpp"
+
+#endif // UTILITY_REFERENCE_COUNTING_STRICT_PTR_HPP
+
+//$Id$
diff --git a/contrib/utility/Utility/ReferenceCounting/StrictPtr.tpp b/contrib/utility/Utility/ReferenceCounting/StrictPtr.tpp
new file mode 100644
index 00000000000..6a30188119c
--- /dev/null
+++ b/contrib/utility/Utility/ReferenceCounting/StrictPtr.tpp
@@ -0,0 +1,167 @@
+// file : Utility/ReferenceCounting/StrictPtr.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ReferenceCounting
+ {
+ // c-tor's & d-tor
+
+ template <typename T>
+ StrictPtr<T>::
+ StrictPtr () throw ()
+ : ptr_ (0)
+ {
+ }
+
+ template <typename T>
+ StrictPtr<T>::
+ StrictPtr (Type* ptr) throw ()
+ : ptr_ (ptr)
+ {
+ }
+
+ template <typename T>
+ StrictPtr<T>::
+ StrictPtr (StrictPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ : ptr_ (add_ref (s_ptr.in ()))
+ {
+ }
+
+ template <typename T>
+ template <typename Other>
+ StrictPtr<T>::
+ StrictPtr (StrictPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ : ptr_ (add_ref (s_ptr.in ()))
+ {
+ }
+
+
+ template <typename T>
+ StrictPtr<T>::
+ ~StrictPtr () throw ()
+ {
+ // This is an additional catch-all layer to protect from
+ // non-conformant Type.
+ try
+ {
+ if (ptr_ != 0) ptr_->remove_ref ();
+ }
+ catch (...)
+ {
+ }
+ }
+
+ // operator=
+
+ template <typename T>
+ StrictPtr<T>&
+ StrictPtr<T>::operator= (Type* ptr) throw ()
+ {
+ if (ptr_ != 0) ptr_->remove_ref ();
+ ptr_ = ptr;
+ return *this;
+ }
+
+ template <typename T>
+ StrictPtr<T>& StrictPtr<T>::
+ operator= (StrictPtr<Type> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ Type* old_ptr (ptr_);
+ Type* new_ptr (add_ref (s_ptr.in ())); // this can throw
+ if (old_ptr != 0) old_ptr->remove_ref ();
+
+ ptr_ = new_ptr; // commit
+
+ return *this;
+ }
+
+
+ template <typename T>
+ template <typename Other>
+ StrictPtr<T>& StrictPtr<T>::
+ operator= (StrictPtr<Other> const& s_ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ Type* old_ptr (ptr_);
+ Other* new_ptr (add_ref (s_ptr.in ())); // this can throw
+ if (old_ptr != 0) old_ptr->remove_ref ();
+
+ ptr_ = new_ptr; // commit
+
+ return *this;
+ }
+
+ // comparison
+
+ template <typename T>
+ bool StrictPtr<T>::
+ operator== (Type* other) const throw ()
+ {
+ return ptr_ == other;
+ }
+
+ template <typename T>
+ bool StrictPtr<T>::
+ operator!= (Type* other) const throw ()
+ {
+ return ptr_ != other;
+ }
+
+ // accessors
+
+ template <typename T>
+ T* StrictPtr<T>::
+ operator-> () const throw (NotInitialized)
+ {
+ if (ptr_ == 0)
+ {
+ throw NotInitialized(
+ "Utility::ReferenceCounting::StrictPtr::operator-> : "
+ "unable to dereference NULL pointer.");
+ }
+ return ptr_;
+ }
+
+ template <typename T>
+ T* StrictPtr<T>::
+ in () const throw ()
+ {
+ return ptr_;
+ }
+
+ template <typename T>
+ T* StrictPtr<T>::
+ retn() throw ()
+ {
+ Type* ret (ptr_);
+ ptr_ = 0;
+ return ret;
+ }
+
+ // Specialization of add_ref function for StrictPtr<T>
+ template <typename T>
+ T*
+ add_ref (StrictPtr<T> const& ptr)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ // delegate to generic implementation
+ return add_ref (ptr.in ());
+ }
+
+ // Dynamic type conversion function for StrictPtr's
+ template <typename D, typename S>
+ StrictPtr<D>
+ strict_cast (StrictPtr<S> const& s)
+ throw (Interface::Exception, Interface::SystemException)
+ {
+ return StrictPtr<D>(add_ref (dynamic_cast<D*>(s.in ())));
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Utility/Synch/Policy/Null.hpp b/contrib/utility/Utility/Synch/Policy/Null.hpp
new file mode 100644
index 00000000000..cfc9c8f788e
--- /dev/null
+++ b/contrib/utility/Utility/Synch/Policy/Null.hpp
@@ -0,0 +1,54 @@
+// file : Utility/Synch/Policy/Null.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_SYNCH_POLICY_NULL_HPP
+#define UTILITY_SYNCH_POLICY_NULL_HPP
+
+namespace Utility
+{
+ namespace Synch
+ {
+ namespace Policy
+ {
+
+ class NullMutex
+ {
+ };
+
+ class NullGuard
+ {
+ public:
+ explicit
+ NullGuard (NullMutex&) throw ();
+
+ private:
+ NullGuard (NullGuard const&) throw ();
+
+ NullGuard&
+ operator= (NullGuard const&) throw ();
+ };
+
+ struct Null
+ {
+ typedef
+ NullMutex
+ Mutex;
+
+ typedef
+ NullGuard
+ ReadGuard;
+
+ typedef
+ NullGuard
+ WriteGuard;
+ };
+ }
+ }
+}
+
+#include "Utility/Synch/Policy/Null.ipp"
+
+#endif // UTILITY_SYNCH_POLICY_NULL_HPP
+//$Id$
diff --git a/contrib/utility/Utility/Synch/Policy/Null.ipp b/contrib/utility/Utility/Synch/Policy/Null.ipp
new file mode 100644
index 00000000000..dbc4c78b698
--- /dev/null
+++ b/contrib/utility/Utility/Synch/Policy/Null.ipp
@@ -0,0 +1,20 @@
+// file : Utility/Synch/Policy/Null.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace Synch
+ {
+ namespace Policy
+ {
+ inline NullGuard::
+ NullGuard (NullMutex&) throw ()
+ {
+ }
+ }
+ }
+}
+
+//$Id$
diff --git a/contrib/utility/Vault/StringConverter.hpp b/contrib/utility/Vault/StringConverter.hpp
new file mode 100644
index 00000000000..0bcb94676b7
--- /dev/null
+++ b/contrib/utility/Vault/StringConverter.hpp
@@ -0,0 +1,27 @@
+// file : Utility/ExH/StringConverter.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_EX_H_STRING_CONVERTER_HPP
+#define UTILITY_EX_H_STRING_CONVERTER_HPP
+
+#include <string>
+
+#include "Utility/ExH/Converter.hpp"
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <>
+ char const*
+ converter (std::string const& t) throw ();
+ }
+}
+
+#include "Utility/ExH/StringConverter.ipp"
+
+#endif // UTILITY_EX_H_STRING_CONVERTER_HPP
+
+//$Id$
diff --git a/contrib/utility/Vault/StringConverter.ipp b/contrib/utility/Vault/StringConverter.ipp
new file mode 100644
index 00000000000..c508c8c752a
--- /dev/null
+++ b/contrib/utility/Vault/StringConverter.ipp
@@ -0,0 +1,18 @@
+// file : Utility/ExH/StringConverter.ipp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace ExH
+ {
+ template <>
+ inline char const*
+ converter (std::string const& t) throw ()
+ {
+ return t.c_str ();
+ }
+ }
+}
+//$Id$
diff --git a/contrib/utility/Vault/hetero/map b/contrib/utility/Vault/hetero/map
new file mode 100644
index 00000000000..0a6113e5c31
--- /dev/null
+++ b/contrib/utility/Vault/hetero/map
@@ -0,0 +1,13 @@
+// file : Utility/hetero/map
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_MAP
+#define UTILITY_HETERO_MAP
+
+#include "Utility/hetero/map.hpp"
+
+#endif // UTILITY_HETERO_MAP
+
+// $Id$
diff --git a/contrib/utility/Vault/hetero/map.hpp b/contrib/utility/Vault/hetero/map.hpp
new file mode 100644
index 00000000000..b6a3e920633
--- /dev/null
+++ b/contrib/utility/Vault/hetero/map.hpp
@@ -0,0 +1,249 @@
+// file : Utility/hetero/map.hpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#ifndef UTILITY_HETERO_MAP_HPP
+#define UTILITY_HETERO_MAP_HPP
+
+#include <typeinfo>
+#include <map>
+
+namespace Utility
+{
+ namespace hetero
+ {
+ template <typename Key>
+ class map
+ {
+ private:
+ struct ValueBase
+ {
+ virtual
+ ~ValueBase () {}
+ };
+
+ template <typename T>
+ class Value : public ValueBase
+ {
+ public:
+ Value (T const& t)
+ : t_ (t)
+ {
+ }
+
+ T t_;
+ };
+
+ typedef
+ std::map<Key, ValueBase*>
+ ValueMap;
+
+ typedef
+ typename std::map<Key, ValueBase*>::value_type
+ ValueType;
+
+ public:
+
+ class Typing {};
+
+ template <typename T>
+ struct type
+ {
+ typedef std::pair <Key const, T> value_type;
+ };
+
+ template <typename First>
+ struct Pair
+ {
+ First first;
+
+ Pair ()
+ : first (),
+ second_ (0)
+ {
+ }
+
+ Pair (First const& k, ValueBase* v)
+ : first (k),
+ second_ (v)
+ {
+ }
+
+ template <typename T>
+ T&
+ second () throw (Typing)
+ {
+ Value<T>* v = dynamic_cast<Value<T>*> (second_);
+ if (v == 0) throw Typing ();
+
+ return v->t_;
+ }
+
+ template <typename T>
+ T const&
+ second () const throw (Typing)
+ {
+ Value<T>* v = dynamic_cast<Value<T>*> (second_);
+ if (v == 0) throw Typing ();
+
+ return v->t_;
+ }
+
+ private:
+ ValueBase* second_;
+ };
+
+ friend
+ class iterator
+ {
+ public:
+ iterator (typename ValueMap::iterator const& i)
+ : i_ (i)
+ {
+ }
+
+ public:
+
+ Pair<Key>&
+ operator* ()
+ {
+ current_ = Pair<Key> (i_->first, i_->second);
+ return current_;
+ }
+
+ Pair<Key>*
+ operator-> ()
+ {
+ current_ = Pair<Key> (i_->first, i_->second);
+ return &current_;
+ }
+
+ public:
+ bool
+ operator== (iterator const& other)
+ {
+ return i_ == other.i_;
+ }
+
+ bool
+ operator!= (iterator const& other)
+ {
+ return i_ != other.i_;
+ }
+
+ private:
+ typename ValueMap::iterator i_;
+ Pair<Key> current_;
+ };
+
+
+ friend
+ class const_iterator
+ {
+ public:
+ const_iterator (typename ValueMap::const_iterator const& i)
+ : i_ (i)
+ {
+ }
+
+ public:
+
+ Pair<Key> const&
+ operator* ()
+ {
+ current_ = Pair<Key> (i_->first, i_->second);
+ return current_;
+ }
+
+ Pair<Key> const*
+ operator-> ()
+ {
+ current_ = Pair<Key> (i_->first, i_->second);
+ return &current_;
+ }
+
+ public:
+ bool
+ operator== (const_iterator const& other)
+ {
+ return i_ == other.i_;
+ }
+
+ bool
+ operator!= (const_iterator const& other)
+ {
+ return i_ != other.i_;
+ }
+
+ private:
+ typename ValueMap::const_iterator i_;
+ Pair<Key> current_;
+ };
+
+ public:
+ iterator
+ begin ()
+ {
+ return iterator (map_.begin ());
+ }
+
+ const_iterator
+ begin () const
+ {
+ return const_iterator (map_.begin ());
+ }
+
+ iterator
+ end ()
+ {
+ return iterator (map_.end ());
+ }
+
+ const_iterator
+ end () const
+ {
+ return const_iterator (map_.end ());
+ }
+
+ public:
+
+ template <typename T>
+ bool
+ insert (std::pair <Key, T> const& x)
+ {
+ ValueType v (x.first, new Value<T> (x.second));
+ return map_.insert (v).second;
+ }
+
+ template <typename T>
+ bool
+ insert (Key const& k, T const& t)
+ {
+ ValueType v (k, new Value<T> (t));
+ return map_.insert (v).second;
+ }
+
+ public:
+ iterator
+ find (Key const& k)
+ {
+ return iterator (map_.find (k));
+ }
+
+ const_iterator
+ find (Key const& k) const
+ {
+ return const_iterator (map_.find (k));
+ }
+
+ private:
+ ValueMap map_;
+ };
+ }
+}
+
+#include "Utility/hetero/map.tpp"
+
+#endif // UTILITY_HETERO_MAP_HPP
+//$Id$
diff --git a/contrib/utility/Vault/hetero/map.tpp b/contrib/utility/Vault/hetero/map.tpp
new file mode 100644
index 00000000000..f2e0dfe69b8
--- /dev/null
+++ b/contrib/utility/Vault/hetero/map.tpp
@@ -0,0 +1,12 @@
+// file : utility/hetero/map.tpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+namespace Utility
+{
+ namespace hetero
+ {
+ }
+}
+//$Id$
diff --git a/contrib/utility/Version b/contrib/utility/Version
new file mode 100644
index 00000000000..937a6c086f5
--- /dev/null
+++ b/contrib/utility/Version
@@ -0,0 +1,3 @@
+1.2.2
+
+$Id$
diff --git a/contrib/utility/license.html b/contrib/utility/license.html
new file mode 100644
index 00000000000..9563d7dadfd
--- /dev/null
+++ b/contrib/utility/license.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+
+file : kolpackov.net/license.html
+author : Boris Kolpackov <boris@kolpackov.net>
+copyright : Copyright (c) 2003 Boris Kolpackov
+license : http://kolpackov.net/license.html
+
+-->
+
+<html>
+
+<head>
+
+ <title>kolpackov.net/license.html</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2001-2003 Boris Kolpackov"/>
+ <meta name="keywords" content="Boris,Kolpackov,Kolpakov,software,license,copyright"/>
+ <meta name="description" content="software license"/>
+ <meta http-equiv="Content-Language" content="en"/>
+
+ <style type="text/css">
+ body {
+ font-family: monospace;
+ }
+ </style>
+
+</head>
+
+<body>
+
+<div align="center">
+<table width="640" border="0" cellspacing="0" cellpadding="0">
+<tr>
+<td>
+
+ <p>This software or documentation is provided 'as-is', without any
+ express or implied warranty. In no event will the author or contributors
+ be held liable for any damages arising from the use of this software
+ or documentation.</p>
+
+ <p>Permission is granted to anyone to use this software or documentation
+ for any purpose, including commercial applications, and to alter it and
+ redistribute it freely, subject to the following restrictions:</p>
+
+<blockquote>
+
+ <p>1. The origin of this software or documentation must not be
+ misrepresented; you must not claim that you wrote the original
+ software or documentation. If you use this software or
+ documentation in a product, an acknowledgment in the product
+ documentation would be appreciated but is not required.</p>
+
+ <p>2. Altered source versions must be plainly marked as such, and must
+ not be misrepresented as being the original software or documentation.
+ Altered source versions may be contributed back to the author to be
+ integrated into the original software or documentation at the
+ author's discretion.</p>
+
+ <p>3. Neither this notice or reference to it nor any copyright, author or
+ contributor clause may be removed from or altered in any software
+ source distribution or documentation covered by this license.</p>
+
+ <p>4. Neither the name of the author, nor the names of contributors may be
+ used to endorse or promote products derived from this software or
+ documentation without specific prior written permission.</p>
+
+</blockquote>
+
+</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
+
+<!-- $Id$ -->