diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup/index.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1&content-type=text/x-cvsweb-markup/index.html | 368 |
1 files changed, 368 insertions, 0 deletions
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 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> +<HEAD><style> A { color:black }</style> +<!-- hennerik CVSweb $Revision: 1.93 $ --> +<TITLE>code/nelns/agent_service/filestream_n.h - view - 1.1</TITLE></HEAD> +<BODY BGCOLOR="#eeeeee"> +<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="filestream_n.h"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="filestream_n.h">filestream_n.h</A> + CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/nelns/">nelns</a> / <a href="/cvs/cvsweb.cgi/code/nelns/agent_service/">agent_service</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/">code</a> / <a href="/cvs/cvsweb.cgi/code/nelns/">nelns</a> / <a href="/cvs/cvsweb.cgi/code/nelns/agent_service/">agent_service</a> / <a href="/cvs/cvsweb.cgi/code/nelns/agent_service/Attic/">Attic</a> / <a href="/cvs/cvsweb.cgi/code/nelns/agent_service/Attic/filestream_n.h">filestream_n.h</a> (<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nelns/agent_service/Attic/filestream_n.h?rev=1.1','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR> +Revision <B>1.1</B>, <i>Wed Apr 18 13:54:25 2001 UTC</i> (15 months, 1 week ago) by <i>valignat</i> +<BR>Branch: <b>MAIN</b> +<PRE> +RENAMED code/server to code/nelns. +</PRE> +</td></tr></table><HR noshade><PRE>#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 +</PRE>
\ No newline at end of file |