Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
null1.hh
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 2k
Category:
Game Server Simulator
Development Platform:
C/C++
- #ifndef __null1_hh__
- #define __null1_hh__
- #include <ostream>
- using namespace std;
- #include "define_short.h"
- //! with_class = Null
- //: Thrown when a *Null* value is trying to be converted into a type
- //: it can't convert to.
- class BadNullConversion {};
- class null_type {
- public:
- template <class Type> operator Type () {throw BadNullConversion();}
- };
- //:
- const null_type null = null_type();
- //: Type to use for the behavior parameter for *Null<>*
- struct NullisNull {
- static null_type null_is() {return null_type();}
- static ostream& null_ostr(ostream& o) {o << "(NULL)"; return o;}
- };
- //: Type to use for the behavior parameter for *Null<>*
- struct NullisZero {
- static int null_is() {return 0;}
- static ostream& null_ostr(ostream &o) {o << 0; return o;}
- };
- //: Type to use for the behavior parameter for *Null<>*
- struct NullisBlank {
- static const char * null_is() {return "";}
- static ostream& null_ostr(ostream &o) {o << ""; return o;}
- };
- //: Container class for holding null types.
- template <class Type, class Behavior = NullisNull>
- class Null {
- public:
- Type data;
- bool is_null;
- typedef Type value_type;
- public:
- Null () {} //:
- Null (Type x) : data(x), is_null(false) {}
- //:
- Null (const null_type &n) : is_null(true) {}
- //: Gives Null the null value
- // Note: the global const *null* (not NULL) is of value null_type thus
- // you can say something like *Null<Type> x = null*.
- operator Type& () {
- if (is_null) return data = Behavior::null_is();
- else return data; }
- //:
- Null& operator = (const Type &x) {data = x; is_null = false; return *this;}
- //:
- Null& operator = (const null_type &n) {is_null = true; return *this;}
- //:
- };
- //: OEP - Specialization for <void>
- template <> class Null<void> {
- public:
- bool is_null;
- typedef void value_type;
- public:
- Null () : is_null(false) {}
- //:
- Null (const null_type &n) : is_null(true) {}
- //: Gives Null the null value
- // Note: the global const *null* (not NULL) is of value null_type thus
- // you can say something like *Null<Type> x = null*.
- //:
- Null& operator = (const null_type &n) {is_null = true; return *this;}
- //:
- };
- #endif