diff --git a/mrw/arg.cpp b/mrw/arg.cpp
new file mode 100644
index 0000000..6dda7ea
--- /dev/null
+++ b/mrw/arg.cpp
@@ -0,0 +1,132 @@
+/** @file
+
+ $Id$
+
+ $Date$
+ $Author$
+
+ @copy © Marc Wäckerlin
+ @license LGPL, see file COPYING
+
+ $Log$
+ Revision 1.1 2004/08/28 16:13:42 marc
+ mrw-c++-0.92 (mrw)
+ - new file: version.cpp
+ - new file header for all sources
+ - work around warning in mrw::auto
+ - possibility to compile without log4cxx
+ - work around bugs in demangle.h and libiberty.h
+ - corrections in documentation
+ - added simple tracing mechanism
+ - more warnings
+ - small corrections in Auto<>::Free and a new test for it
+ - possibility to compile without stack trace
+
+*/
+#include
+#include
+
+namespace mrw {
+
+ const std::string& Param::Value::toString() const throw(std::exception) {
+ throw mrw::bad_cast();
+ }
+
+ int Param::Value::toInt() const throw(std::exception) {
+ throw mrw::bad_cast();
+ }
+
+ bool Param::Value::toBool() const throw(std::exception) {
+ throw mrw::bad_cast();
+ }
+
+ void Param::IntValue::operator=(const std::string& s) throw(std::exception) {
+ if (!(std::stringstream(s)>>_i)) throw mrw::bad_cast();
+ }
+
+ const mrw::SmartPointer& Param::operator[](unsigned int i) const
+ throw(std::exception) {
+ if (i<_params.size()) return _params[i];
+ throw mrw::out_of_range
+ (((std::stringstream&)
+ (std::stringstream()<<"check failed: "
+ <& Param::setable(unsigned int i)
+ throw(std::exception) {
+ if (i<_params.size()) return _params[i];
+ throw mrw::out_of_range
+ (((std::stringstream&)
+ (std::stringstream()<<"check failed: "
+ <second;
+ }
+
+ const Opt& Args::find(const std::string& s) const throw(std::exception) {
+ LongOpts::const_iterator it(_longopts.find(s));
+ if (it==_longopts.end()) throw mrw::out_of_range(s);
+ return *it->second;
+ }
+
+ Args& Args::parse(int argc, const char*const*const argv)
+ throw(std::exception) {
+ if (argc>0) _filename = argv[0];
+ for (int i(1); isecond->args().size()>=argc)
+ throw mrw::invalid_argument(arg);
+ it->second->set();
+ for (int j(0), l(it->second->args().size()); jsecond->args().setable(j)) = argv[++i];
+ }
+ } else if (arg.find("-")==0) { // short arguments
+ // first check all, then set all
+ for (int j(1), l(arg.size()); jsecond->args().size()>0 &&
+ (j+1!=l || i+it->second->args().size()>=argc))
+ throw mrw::invalid_argument(arg);
+ }
+ for (int j(1), l(arg.size()); jsecond->set();
+ if (j+1==l && it->second->args().size()>0) {
+ for (int k(0); k < it->second->args().size(); ++k) {
+ *(it->second->args().setable(k)) = argv[++i];
+ }
+ }
+ }
+ } else {
+ if (arg!="--") _otherargs.push_back(arg);
+ while (++i
-#include // close
-#include // fstat
-#include // mmap
-
-namespace mrw {
-
- //----------------------------------------------------------------------------
-
- AutoFile& AutoFile::reset(int fd) throw() {
- if (_fd!=-1) close(_fd);
- _fd = fd;
- return *this;
- }
-
- //----------------------------------------------------------------------------
- AutoMapper::AutoMapper(int fd, size_t sz, void* addr,
- int prot, int flags, off_t off) throw(): _cont(0) {
- if (!(_sz=sz)) {
- struct stat st;
- if (fd==-1 || fstat(fd, &st)==-1) return;
- _sz = st.st_size;
- }
- if ((_cont=mmap(addr, _sz, prot, flags, fd, off))==MAP_FAILED) release();
- }
-
- //----------------------------------------------------------------------------
- AutoMapper::~AutoMapper() throw() {
- if (_cont && _sz) munmap(_cont, _sz);
- }
-}
diff --git a/mrw/smartpointer_test.cpp b/mrw/smartpointer_test.cpp
new file mode 100644
index 0000000..c9fad17
--- /dev/null
+++ b/mrw/smartpointer_test.cpp
@@ -0,0 +1,162 @@
+/** @file
+
+ $Id$
+
+ $Date$
+ $Author$
+
+ @copy © Marc Wäckerlin
+ @license LGPL, see file COPYING
+
+ $Log$
+ Revision 1.1 2004/08/28 16:13:42 marc
+ mrw-c++-0.92 (mrw)
+ - new file: version.cpp
+ - new file header for all sources
+ - work around warning in mrw::auto
+ - possibility to compile without log4cxx
+ - work around bugs in demangle.h and libiberty.h
+ - corrections in documentation
+ - added simple tracing mechanism
+ - more warnings
+ - small corrections in Auto<>::Free and a new test for it
+ - possibility to compile without stack trace
+
+*/
+#include
+#include
+#include
+#include
+#include
+#include
+
+class Content {
+private:
+ int& _drop;
+ Content();
+public:
+ Content(int& drop): _drop(drop) {}
+ virtual ~Content() {++_drop;}
+};
+class A: public Content {public: A(int& d): Content(d) {} virtual void fn() {}};
+class B: public A {public: B(int& d): A(d) {}};
+class C: public A {public: C(int& d): A(d) {}};
+class SmartPointerTest:
+ public mrw::SmartPointerParent, public CppUnit::TestFixture {
+public:
+ void SimpleConstructor() {
+ mrw::SmartPointer p1;
+ CPPUNIT_ASSERT(!(getPointer(p1) || getCounter(p1)));
+ }
+ void CopyConstructor() {
+ mrw::SmartPointer p1;
+ mrw::SmartPointer p2(p1);
+ CPPUNIT_ASSERT(!(getPointer(p1) || getCounter(p1) ||
+ getPointer(p2) || getCounter(p2)));
+ }
+ void PointerConstructor() {
+ int drops(0);
+ mrw::SmartPointer p1(0);
+ mrw::SmartPointer p2(new Content(drops));
+ CPPUNIT_ASSERT(!(getPointer(p1) || getCounter(p1) ||
+ drops!=0 || !getPointer(p2) || !getCounter(p2) ||
+ getCounter(p2)->get()!=1));
+ }
+ void CastConstructor() {
+ int drops1(0);
+ mrw::SmartPointer pa(new B(drops1));
+ mrw::SmartPointer pb(pa);
+ mrw::SmartPointer pc(pa);
+ mrw::SmartPointer pa2(pb);
+ CPPUNIT_ASSERT(!(drops1!=0 || !getPointer(pa) || !getCounter(pa) ||
+ getPointer(pb)!=getPointer(pa) ||
+ getCounter(pb)!=getCounter(pa) ||
+ getPointer(pc) || getCounter(pc) ||
+ getCounter(pa)->get()!=3 ||
+ getPointer(pa2)!=getPointer(pa) ||
+ getCounter(pa2)!=getCounter(pa)));
+ }
+ void Destructor() {
+ int drops(0);
+ mrw::SmartPointer* p1 =
+ new mrw::SmartPointer(new Content(drops));
+ delete p1;
+ CPPUNIT_ASSERT(!(drops!=1));
+ }
+ void CopyAssign() {
+ int drops1(0);
+ int drops2(0);
+ mrw::SmartPointer p1(new Content(drops1));
+ mrw::SmartPointer p2(new Content(drops2));
+ p2 = p1;
+ p1 = p2;
+ CPPUNIT_ASSERT(!(drops1!=0 || !getPointer(p1) || !getCounter(p1) ||
+ getCounter(p1)->get()!=2 ||
+ getPointer(p1)!=getPointer(p2) ||
+ drops2!=1 || !getPointer(p2) || !getCounter(p2) ||
+ getCounter(p2)->get()!=2 ||
+ getCounter(p1)!=getCounter(p2)));
+ }
+ void PointerAssign() {
+ int drops1(0);
+ int drops2(0);
+ int drops3(0);
+ mrw::SmartPointer p1(new Content(drops1));
+ mrw::SmartPointer p2(0);
+ p1 = new Content(drops2);
+ p1 = 0;
+ p2 = new Content(drops3);
+ CPPUNIT_ASSERT(!(drops1!=1 || getPointer(p1) || getCounter(p1) ||
+ drops2!=1 || !getPointer(p2) || !getCounter(p2) ||
+ drops3!=0 || getCounter(p2)->get()!=1));
+ }
+ void CastAssign() {
+ int drops1(0);
+ int drops2(0);
+ int drops3(0);
+ mrw::SmartPointer pa(new B(drops1));
+ mrw::SmartPointer pb(new B(drops2));
+ mrw::SmartPointer pc(new C(drops3));
+ pa = pa;
+ pa = pb;
+ pa = pc;
+ pb = pa;
+ pc = pa;
+ CPPUNIT_ASSERT(!(drops1!=1 || drops2!=1 || drops3!=0 ||
+ !getPointer(pa) || getPointer(pa)!=getPointer(pc) ||
+ !getCounter(pa) || getCounter(pa)!=getCounter(pc) ||
+ getCounter(pa)->get()!=2 || getPointer(pb) ||
+ getCounter(pb)));
+ }
+ void PointerAccess() {
+ mrw::SmartPointer p1(new std::string);
+ mrw::SmartPointer p2;
+ *p1 = "Hallo Welt!";
+ CPPUNIT_ASSERT(!(p1.operator->()!=&*p1 || p1->find("Welt")!=6 ||
+ p2.operator->()));
+ }
+ void OperatorBool() {
+ mrw::SmartPointer p1(new std::string);
+ mrw::SmartPointer p2;
+ CPPUNIT_ASSERT(!(!p1 || p2));
+ }
+ CPPUNIT_TEST_SUITE(SmartPointerTest);
+ CPPUNIT_TEST(SimpleConstructor);
+ CPPUNIT_TEST(CopyConstructor);
+ CPPUNIT_TEST(PointerConstructor);
+ CPPUNIT_TEST(CastConstructor);
+ CPPUNIT_TEST(Destructor);
+ CPPUNIT_TEST(CopyAssign);
+ CPPUNIT_TEST(PointerAssign);
+ CPPUNIT_TEST(CastAssign);
+ CPPUNIT_TEST(PointerAccess);
+ CPPUNIT_TEST(OperatorBool);
+ CPPUNIT_TEST_SUITE_END();
+};
+CPPUNIT_TEST_SUITE_REGISTRATION(SmartPointerTest);
+
+int main() {
+ CppUnit::TextUi::TestRunner runner;
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ return runner.run() ? 0 : 1;
+}
diff --git a/mrw/version.cpp.in b/mrw/version.cpp.in
new file mode 100644
index 0000000..d485f48
--- /dev/null
+++ b/mrw/version.cpp.in
@@ -0,0 +1,31 @@
+/** @file
+
+ $Id$
+
+ $Date$
+ $Author$
+
+ @copy © Marc Wäckerlin
+ @license LGPL, see file COPYING
+
+ $Log$
+ Revision 1.1 2004/08/28 16:13:42 marc
+ mrw-c++-0.92 (mrw)
+ - new file: version.cpp
+ - new file header for all sources
+ - work around warning in mrw::auto
+ - possibility to compile without log4cxx
+ - work around bugs in demangle.h and libiberty.h
+ - corrections in documentation
+ - added simple tracing mechanism
+ - more warnings
+ - small corrections in Auto<>::Free and a new test for it
+ - possibility to compile without stack trace
+
+*/
+
+#include
+
+namespace mrw {
+ const std::string version("@(#)@PACKAGENAME@-@MAJOR@.@MINOR@@SUPPORT@");
+}