From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../x-cvsweb-markup/index.html | 368 +++++++++++++++++++++ 1 file changed, 368 insertions(+) create mode 100644 cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup/index.html (limited to 'cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup') diff --git a/cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup/index.html b/cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup/index.html new file mode 100644 index 00000000..96267c90 --- /dev/null +++ b/cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup/index.html @@ -0,0 +1,368 @@ + + + +code/nelns/agent_service/filestream_n.h - view - 1.1 + +
[BACK] Return to filestream_n.h + CVS log [TXT][DIR] Up to Nevrax / code / nelns / agent_service

File: Nevrax / code / nelns / agent_service / Attic / filestream_n.h (download)
+Revision 1.1, Wed Apr 18 13:54:25 2001 UTC (15 months, 1 week ago) by valignat +
Branch: MAIN +
+RENAMED code/server to code/nelns.
+
+

#ifndef NELNS_FILE_STREAM_H
+#define NELNS_FILE_STREAM_H
+
+#include "stdio.h"
+#include <ostream>
+#include <istream>
+#include "nel/misc/stream.h"
+
+sint64 atoiInt64(const char *ident,sint64 base = 10)
+{
+        uint64 k = 0;
+
+        while(*ident != 0)
+        {
+                switch(*(ident++))
+                {
+                case '0':
+                        k +=0;
+                        break;
+                case '1':
+                        k +=1;
+                        break;
+                case '2':
+                        k +=2;
+                        break;
+                case '3':
+                        k +=3;
+                        break;
+                case '4':
+                        k +=4;
+                        break;
+                case '5':
+                        k +=5;
+                        break;
+                case '6':
+                        k +=6;
+                        break;
+                case '7':
+                        k +=7;
+                        break;
+                case '8':
+                        k +=8;
+                        break;
+                case '9':
+                        k +=9;
+                        break;
+                case 'a':
+                        k +=10;
+                        break;
+                case 'b':
+                        k +=11;
+                        break;
+                case 'c':
+                        k +=12;
+                        break;
+                case 'd':
+                        k +=13;
+                        break;
+                case 'e':
+                        k +=14;
+                        break;
+                case 'f':
+                        k +=15;
+                        break;
+
+                case 'A':
+                        k +=10;
+                        break;
+                case 'B':
+                        k +=11;
+                        break;
+                case 'C':
+                        k +=12;
+                        break;
+                case 'D':
+                        k +=13;
+                        break;
+                case 'E':
+                        k +=14;
+                        break;
+                case 'F':
+                        k +=15;
+                        break;
+
+                case 0:
+                        return k;
+                        break;
+                }
+                if(*ident != 0) k *= base;
+        }
+
+        return k;
+}
+
+void itoaInt64(sint64 numbre,char *str,sint64 base = 10) 
+{                                                                       
+        str[0] = 0;
+        char b[256];
+        if(!numbre)
+        {
+                str[0] = '0';
+                str[1] = 0;
+        }
+        memset(b,0,255);
+        memset(b,'0',64);
+        sint n;
+        uint64 x = numbre;
+        char baseTable[] = "0123456789abcdef";
+        for(n = 0; n < 64; n ++)
+        {
+                sint num = (sint)(x % base);
+                b[64 - n] = baseTable[num];
+                if(!x) 
+                {
+                        int k;
+                        int j = 0;
+                        for(k = 64 - n + 1; k <= 64; k++)         
+                        {
+                                str[j ++] = b[k];
+                        }
+                        str[j] = 0;
+                        break;
+                }
+                x /= base;
+        }
+                
+}
+
+class CCharOStream: public NLMISC::IStream
+{
+private:
+        std::ostream &_Os;
+public: 
+        CCharOStream(std::ostream *os):NLMISC::IStream(false,false), _Os(*os)
+        {                
+        }
+
+        virtual void        serial(uint8 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(sint8 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(uint16 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(sint16 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(uint32 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(sint32 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(uint64 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                itoaInt64((sint64)b,text);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(sint64 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                itoaInt64(b,text,10);
+                _Os << text << std::endl;
+        }
+
+        virtual void        serial(float &b) throw(NLMISC::EStream)
+        {
+                _Os << b << std::endl;
+        }
+        virtual void        serial(double &b) throw(NLMISC::EStream)
+        {
+                _Os << b << std::endl;
+        }
+        virtual void        serial(bool &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+#ifndef NL_OS_CYGWIN
+        virtual void        serial(char &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                sprintf(text,"%d",b);
+                _Os << text << std::endl;
+        }
+#endif
+        virtual void        serial(std::string &b) throw(NLMISC::EStream)
+        {
+                _Os << strlen(b.data()) + 1;
+                _Os << " ";
+                _Os << b << std::endl;
+        }
+        virtual void        serial(ucstring &b) throw(NLMISC::EStream)
+        {
+
+        }
+
+        virtual void                serialBuffer(uint8 *buf, uint len)throw(NLMISC::EReadError)
+        {
+        }
+        virtual void                serialBit(bool &bit) throw(NLMISC::EReadError)
+        {
+        }
+                
+        ~CCharOStream()
+        {
+        }
+
+};
+
+class CCharIStream: public NLMISC::IStream
+{
+private:
+        std::istream &_Is;
+public:
+        CCharIStream(std::istream *is):NLMISC::IStream(true,false), _Is(*is)
+        {                
+        }
+
+        virtual void        serial(uint8 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (uint8)atoi(text);
+        }
+
+        virtual void        serial(sint8 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (sint8)atoi(text);
+        }
+
+        virtual void        serial(uint16 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (uint16)atoi(text);
+        }
+        virtual void        serial(sint16 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (sint16)atoi(text);
+        }
+
+        virtual void        serial(uint32 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (uint32)atoi(text);
+        }
+
+        virtual void        serial(sint32 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (sint32)atoi(text);
+        }
+        virtual void        serial(uint64 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (uint64)atoiInt64(text);
+        }
+
+        virtual void        serial(sint64 &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = atoiInt64(text);
+        }
+
+        virtual void        serial(float &b) throw(NLMISC::EStream)
+        {
+                _Is >> b;
+        }
+        virtual void        serial(double &b) throw(NLMISC::EStream)
+        {
+                _Is >> b;
+        }
+
+        virtual void        serial(bool &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (atoi(text) != 0);
+        }
+#ifndef NL_OS_CYGWIN
+        virtual void        serial(char &b) throw(NLMISC::EStream)
+        {
+                char text[100];
+                _Is >> text;
+                b = (char)atoi(text);
+        }
+#endif
+        virtual void        serial(std::string &b) throw(NLMISC::EStream)
+        {
+                int i;
+                _Is >> i;
+                char *t = new char [i + 1];
+                _Is.read(t,i);
+                t[i] = 0;
+                std::string s(&t[1]);
+                b = s;
+                delete t;
+
+        }
+        virtual void        serial(ucstring &b) throw(NLMISC::EStream)
+        {
+        }
+
+        virtual void                serialBuffer(uint8 *buf, uint len)throw(NLMISC::EReadError)
+        {
+        }
+        virtual void                serialBit(bool &bit) throw(NLMISC::EReadError)
+        {
+        }
+
+        ~CCharIStream()
+        {
+        }
+};
+
+
+#endif
+
\ No newline at end of file -- cgit v1.2.1