Skip site navigation (1)Skip section navigation (2)
Date:      17 Apr 2002 07:13:40 -0700
From:      Max Okumoto <okumoto@ucsd.edu>
To:        freebsd-libh@FreeBSD.ORG
Subject:   cleanup of HSystem 2nd try (stage 9)
Message-ID:  <hfwuv64dm3.fsf@multivac.sdsc.edu>

next in thread | raw e-mail | index | archive | help

* Cleaned up main by adding usefull named variables and added a doxygen
  comment explaining what it does.

Index: lib/tcl/tcl_interface_gen.cc
===================================================================
RCS file: /home/libh/cvs/libh/lib/tcl/tcl_interface_gen.cc,v
retrieving revision 1.10
diff -u -w -r1.10 tcl_interface_gen.cc
--- lib/tcl/tcl_interface_gen.cc	2002/04/17 02:34:55	1.10
+++ lib/tcl/tcl_interface_gen.cc	2002/04/17 14:11:37
@@ -42,24 +42,38 @@
 #include <ctime>
 #include <cstdio>
 
+/**
+ * Main entry point for tcl bindings generator.  Create the interface code
+ * between tcl and C++
+ *
+ * @returns	0 for success,
+ *		1 for incorrect number of args,
+ *		2 for some an exception.
+ */
 int main( int argc, char** argv )
 {
+	const string	progname = argv[0];
+
 	if ( argc != 3 ) {
-		cerr << "Usage: " << argv[0] << " <system-name> <file-to-generate>" << endl;
+		cerr << "Usage: " << progname << " <system-name> <file-to-generate>" << endl;
 		return 1;
 	}
 
+	const string	name = argv[1];
+	const string	ofile = argv[2];
+
 	try {
 		Systems systems;
 		build_systems( systems );
 
-		Systems::iterator system = systems.find( HSystem( argv[1] ) );
+		Systems::const_iterator system = systems.find(HSystem(name));
 		if ( system == systems.end() )
-			throw runtime_error( string( "System " ) + argv[1] + " is unknown" );
+			throw runtime_error("System " + name + " is unknown");
 
-		ofstream out( argv[2] );
+		ofstream out(ofile.c_str());
 		if ( !out )
-			throw runtime_error( string( "Unable to create " ) + argv[2] + ": " + ::strerror( errno ) );
+			throw runtime_error("Unable to create " + ofile +
+					    ": " + ::strerror(errno));
 
 		HSystem& s = const_cast<HSystem&>( *system );
 		s.gen_file( out );

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-libh" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?hfwuv64dm3.fsf>