From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,e1556455f39dbe02 X-Google-Attributes: gid109fba,public X-Google-Thread: 10ba33,e1556455f39dbe02 X-Google-Attributes: gid10ba33,public X-Google-Thread: fee84,e1556455f39dbe02 X-Google-Attributes: gidfee84,public X-Google-Thread: 11035d,e1556455f39dbe02 X-Google-Attributes: gid11035d,public From: Jean-Claude Magras Subject: Re: Need help with Template Problems Date: 1997/05/11 Message-ID: <33763A26.6AA@texas.net> X-Deja-AN: 240922866 References: <3374CBCC.6A25@texas.net> <33762FA8.4F0F@texas.net> Organization: Texas Networking, Inc. Newsgroups: gnu.g++.help,comp.unix.solaris,comp.unix.osf.osf1,comp.lang.c++ This is a multi-part message in MIME format. --------------2E266F0C4459 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Greetings, I apologize about the problems with the files sent before. Solaris2.5.1-sparc-2.7.2.1 and libg++ 2.7.2 Again. Any help appreciated. Book references,code diffs,etc. This code once worked but After I returned to it from a hiatus it didnt. The previous post enumerates the errors received. Sincerely, J.C. Magras -- Why are the Israelis invoking the death penalty for an Israeli selling land to a Palestinian? (This according to Editorial of NY >Times--available on Yahoo) Unix Software Engineer looking for C++/UNIX/Motif/Perl/Tk/Flex Software Engineering position **NOW**. Currently in Austin at (512) 672-5778/magrasjc@texas.net. have Answering machine. --------------2E266F0C4459 Content-Type: text/plain; charset=us-ascii; name="NODE.h" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="NODE.h" #ifndef _NODE_H #define _NODE_H #include #include #include "security.h" #include "jWare.h" // streambuf.h , #209 class filname_ { public: filname_::filname_(); filname_ & filname_::operator= ( filname_ &that); bool filname_::operator==( filname_ &that); bool filname_::operator!=( filname_ &that); bstring *FILEname_bstrP; ifstream *a_istrmP; ofstream *a_ostrmP; modeDEV *filemodeP; } ; // // filname_ :default constructor // filname_::filname_ () { a_istrmP =0; a_ostrmP =0; FILEname_bstrP=0; filemodeP =0; } // // filname_ :assignment constructor // filname_ & filname_::operator=( filname_ &that) { this->a_istrmP = that.a_istrmP; this->a_ostrmP = that.a_ostrmP; this->FILEname_bstrP = that.FILEname_bstrP; this->filemodeP = that.filemodeP; } // // filname_ :overload of equality test operator // bool filname_::operator==( filname_ &that) { return ( ( this->a_istrmP == that.a_istrmP ) && ( this->a_ostrmP == that.a_ostrmP ) && ( this->FILEname_bstrP == that.FILEname_bstrP ) ); } // // filname_ :overload of inequality test operator // bool filname_::operator!=( filname_ &that) { return !( ( this->a_istrmP == that.a_istrmP ) && ( this->a_ostrmP == that.a_ostrmP ) && ( this->FILEname_bstrP == that.FILEname_bstrP ) ); } // unified address class class addrINFO { public: struct sockaddr_in TCPaddr; filname_ FILEaddr; } ; #ifdef DOCUMENTATION #define _BO #define BO_ _BOKeywordsBO_: template _BOAuthorBO_: magras _BOBase NameBO_:NetProtocol _BODerived NamesBO_: pTCPIP, fileNODE, strNODE _BOclass ParamaterBO_: [ipcT]Descriptor for the communications medium being used Serves as the actual object through which the user communcaties with the other party. addrINFO should probably be a typedef for for each class type derived from this template. _BOenumerationsBO_: jIsEOFvalid --true if this a data container not a stream? jHitEOF --false if we have read to the very end of the file or if this a stream type data source #endif //DOCUMENTATION #pragma interface "NODE.h" typedef struct { int IPsocket; } TCPIPd; template class NetProtocol; template class NetProtocol { protected: bool accepted; // this is used by server type instances U IPsocket; // an actual instance of the IPC being used bstring *error_pbstr; // used to record error messages public: enum {jIsEOFvalid,jHitEOF}; // addressing information--addrINFO should probably be a typedef for for each class type derived from this template addrINFO ouraddr; // default constructor NetProtocol::NetProtocol(); // copy constructor NetProtocol(NetProtocol &old) ; ~NetProtocol(); // destructor // assignment operator NetProtocol& operator= (const NetProtocol&); // sole test operator used by ordering mechanisms in STL container classes bool operator< (const NetProtocol& that); // here for our use bool operator==(const U& that); // public access to server mode connection data bool NetProtocol::jProto_is_accepted(); void NetProtocol::jProto_set_accepted(bool ) ; // indicate an error on this connection -- invalidate this descriptor void jProto_set_error_string(bstring& error_); // check if socket descriptor is valid and has no errors on the connection bool jProto_get_status(); // return the error string bstring& jProto_get_error(); // access the native descriptor void jProto_set_native( U ); U jProto_get_native(); // descriptor semantics control bool jProto_iocntrl(unsigned int); }; #endif --------------2E266F0C4459 Content-Type: text/plain; charset=us-ascii; name="NODE.C" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="NODE.C" #include "NODE.h" #ifndef _NODE_C template class NetProtocol ; template U& NetProtocol:: operator=(const U& that) { this->IPsocket = that->IPsocket; this->error_pbstr = that->error_pbstr; this->accepted = that->accepted; memcpy(&(that->ouraddr), &(this->ouraddr),sizeof(struct addrINFO)); } // default constructor template NetProtocol< U>:: NetProtocol() { this->IPsocket=0; // invalid descriptor this->error_pbstr=0; // no error string this->accepted=false; // this descriptor has not accepted a connection } // // This definition necessary for container class definition // This is the sole comparison operator used by the STL // Equality check by a bool NetProtocol:: operator<(const U& that) { return (this->IPsocket < that->IPsocket); } // equality test between instances --NOT needed by STL template bool NetProtocol:: operator==(const U& that) { return (this->IPsocket == that->IPsocket); } // copy constructor template NetProtocol:: NetProtocol(NetProtocol &old) { this->IPsocket = old.IPsocket; // should this be dup() ? this->error_pbstr = old.error_pbstr; this->accepted = old.accepted; } // Default template destructor template NetProtocol:: ~NetProtocol() { // handle an error string attachment if (error_pbstr) delete error_pbstr; } // start of user functions // test to see if this server connection has accepted a client's // connection attempt template bool NetProtocol:: jProto_is_accepted() { return accepted; } // simply return the variable 4 now // record that this server endpoint has accepted a client connect attempt template void NetProtocol:: jProto_set_accepted(bool state) { accepted = state; } // set the error string when an error is detected with this descriptor template void NetProtocol< U>:: jProto_set_error_string(bstring& error_) { error_pbstr=new bstring(error_); // make a copy of the bstring passed in this->IPsocket=0; // invalidate descriptor } // set the native descriptor -- this will probably be // moved to protected status template void NetProtocol< U>:: jProto_set_native(U socketno) { this->IPsocket=socketno; } // return the native descriptor -- this will probably be // moved to protected status template U NetProtocol< U>:: jProto_get_native() { return (T)IPsocket; }; // return true if the descriptor is valid (nocalls to set_error_string()) // against it template bool NetProtocol< U>::jProto_get_status() { if (IPsocket==0) return false; else return true; } // define a default semantics for a derived class template bool NetProtocol::jProto_iocntrl(unsigned int opcode) { switch (opcode) { case jIsEOFvalid: return false; // semantics of stream object case jHitEOF: return false; default : return false; }; } // return the error string if the descriptor is invalid // if descriptor is valid it returns a bstring of "" template bstring &NetProtocol:: jProto_get_error() { bstring *dflt_pbstr; // check if descriptor is valid-- which could be anything... if (this->jProto_get_status()==false && this->error_pbstr !=NULL) return(*error_pbstr); else { dflt_pbstr=new bstring(""); return *dflt_pbstr; } } #define _NODE_C #endif --------------2E266F0C4459 Content-Type: text/plain; charset=us-ascii; name="testT.C" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="testT.C" #pragma implementation "NODE.C" #include "NODE.C" main() { NetProtocol n1; } --------------2E266F0C4459--