⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tools.h

📁 一个非常好的GIS开源新版本
💻 H
📖 第 1 页 / 共 2 页
字号:
// Tools Library//// Copyright (C) 2004  Navel Ltd.//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU// Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA////  Email://    mhadji@gmail.com#ifndef __tools_h#define __tools_h#ifdef _MSC_VER#include <locale>#include <limits>#endif//_MSC_VER#include <stdint.h>#include <assert.h>#include <iostream>#include <iomanip>#include <iterator>#include <string>#include <sstream>#include <fstream>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <list>#include <algorithm>#include <cmath>#include <climits>#if TIME_WITH_SYS_TIME	#include <sys/time.h>	#include <time.h>#else	#if HAVE_SYS_TIME_H		#include <sys/time.h>	#else		#include <time.h>	#endif#endif#ifndef WIN32#include <sys/resource.h>#endif#include <unistd.h>#if HAVE_PTHREAD_H#include <pthread.h>#endif#include "SmartPointer.h"#include "PointerPool.h"#include "PoolPointer.h"typedef uint8_t byte;#define interface classnamespace Tools{	enum IntervalType	{		IT_RIGHTOPEN = 0x0,		IT_LEFTOPEN,		IT_OPEN,		IT_CLOSED	};	enum Level	{		LVL_VERYLOW = 0x0,		LVL_LOW,		LVL_MEDIUM,		LVL_HIGH,		LVL_VERYHIGH	};	enum VariantType	{		VT_LONG = 0x0,		VT_BYTE,		VT_SHORT,		VT_FLOAT,		VT_DOUBLE,		VT_CHAR,		VT_USHORT,		VT_ULONG,		VT_INT,		VT_UINT,		VT_BOOL,		VT_PCHAR,		VT_PVOID,		VT_EMPTY,		VT_LONGLONG,		VT_ULONGLONG	};	enum Architecture	{		ARCH_LITTLEENDIAN = 0x0,		ARCH_BIGENDIAN,		ARCH_NONIEEE	};	enum RandomGeneratorType	{		RGT_DRAND48 = 0x0,		RGT_MERSENNE	};	//	// Exceptions	//	class Exception	{	public:		virtual std::string what() = 0;		virtual ~Exception() {}	};	class IndexOutOfBoundsException : public Exception	{	public:		IndexOutOfBoundsException(int i);		virtual ~IndexOutOfBoundsException() {};		virtual std::string what();	private:		std::string m_error;	}; // IndexOutOfBoundsException	class IllegalArgumentException : public Exception	{	public:		IllegalArgumentException(std::string s);		virtual ~IllegalArgumentException() {};		virtual std::string what();	private:		std::string m_error;	}; // IllegalArgumentException	class IllegalStateException : public Exception	{	public:		IllegalStateException(std::string s);		virtual ~IllegalStateException() {};		virtual std::string what();	private:		std::string m_error;	}; // IllegalStateException	class EndOfStreamException : public Exception	{	public:		EndOfStreamException(std::string s);		virtual ~EndOfStreamException() {};		virtual std::string what();	private:		std::string m_error;	}; // EndOfStreamException	class ResourceLockedException : public Exception	{	public:		ResourceLockedException(std::string s);		virtual ~ResourceLockedException() {};		virtual std::string what();	private:		std::string m_error;	}; // ResourceLockedException	class InvalidPageException : public Exception	{	public:		InvalidPageException(long id);		virtual ~InvalidPageException() {};		virtual std::string what();	private:		std::string m_error;	}; // InvalidPageException	class NotSupportedException : public Exception	{	public:		NotSupportedException(std::string s);		virtual ~NotSupportedException() {};		virtual std::string what();	private:		std::string m_error;	}; // NotSupportedException	class ParseErrorException : public Exception	{	public:		ParseErrorException(std::string s);		virtual ~ParseErrorException() {};		virtual std::string what();	private:		std::string m_error;	}; // ParseErrorException	//	// Interfaces	//	interface IInterval	{	public:		virtual ~IInterval() {}		virtual IInterval& operator=(const IInterval&) = 0;		virtual double getLowerBound() const = 0;		virtual double getUpperBound() const = 0;		virtual void setBounds(double, double) = 0;		virtual bool intersectsInterval(const IInterval&) const = 0;		virtual bool intersectsInterval(IntervalType type, double start, double end) const = 0;		virtual bool containsInterval(const IInterval&) const = 0;		virtual IntervalType getIntervalType() const = 0;	}; // IInterval	interface IObject	{	public:		virtual ~IObject() {}		virtual IObject* clone() = 0;			// return a new object that is an exact copy of this one.			// IMPORTANT: do not return the this pointer!	}; // IObject	interface ISerializable //: public virtual IObject	{	public:		virtual ~ISerializable() {}		virtual unsigned long getByteArraySize() = 0;			// returns the size of the required byte array.		virtual void loadFromByteArray(const byte* data) = 0;			// load this object using the byte array.		virtual void storeToByteArray(byte** data, unsigned long& length) = 0;			// store this object in the byte array.	};	interface IComparable //: public virtual IObject	{	public:		virtual ~IComparable() {}		virtual bool operator<(const IComparable& o) const = 0;		virtual bool operator>(const IComparable& o) const = 0;		virtual bool operator==(const IComparable& o) const = 0;	}; //IComparable	interface IObjectComparator	{	public:		virtual ~IObjectComparator() {}		virtual int compare(IObject* o1, IObject* o2) = 0;	}; // IObjectComparator	interface IObjectStream	{	public:		virtual ~IObjectStream() {}		virtual IObject* getNext() = 0;			// returns a pointer to the next entry in the			// stream or 0 at the end of the stream.		virtual bool hasNext() = 0;			// returns true if there are more items in the stream.		virtual unsigned long size() = 0;			// returns the total number of entries available in the stream.		virtual void rewind() = 0;			// sets the stream pointer to the first entry, if possible.	}; // IObjectStream	namespace Geometry	{		class Region;		class Point;		enum Quadrant		{			Q_UPPERRIGHT = 0x0,			Q_LOWERRIGHT,			Q_UPPERLEFT,			Q_LOWERLEFT		};		// since all base classes are interfaces (there is no state involved) all		// inheritance can be virtual for efficiency.		interface IShape : public virtual ISerializable		{		public:			virtual bool intersectsShape(const IShape& in) const = 0;			virtual bool containsShape(const IShape& in) const = 0;			virtual bool touchesShape(const IShape& in) const = 0;			virtual void getCenter(Point& out) const = 0;			virtual unsigned long getDimension() const = 0;			virtual void getMBR(Region& out) const = 0;			virtual double getArea() const = 0;			virtual double getMinimumDistance(const IShape& in) const = 0;			virtual ~IShape() {}		}; // IShape		// since all base classes are interfaces (there is no state involved) all		// inheritance can be virtual for efficiency.		interface ITimeShape : public virtual IShape, public virtual IInterval		{		public:			virtual bool intersectsShapeInTime(const ITimeShape& in) const = 0;			virtual bool intersectsShapeInTime(const IInterval& ivI, const ITimeShape& in) const = 0;			virtual bool containsShapeInTime(const ITimeShape& in) const = 0;			virtual bool containsShapeInTime(const IInterval& ivI, const ITimeShape& in) const = 0;			virtual bool touchesShapeInTime(const ITimeShape& in) const = 0;			virtual bool touchesShapeInTime(const IInterval& ivI, const ITimeShape& in) const = 0;			virtual double getAreaInTime() const = 0;			virtual double getAreaInTime(const IInterval& ivI) const = 0;			virtual double getIntersectingAreaInTime(const ITimeShape& r) const = 0;			virtual double getIntersectingAreaInTime(const IInterval& ivI, const ITimeShape& r) const = 0;			virtual ~ITimeShape() {}		}; // ITimeShape		// since all base classes are interfaces (there is no state involved) all		// inheritance can be virtual for efficiency.		interface IEvolvingShape : public virtual IShape		{		public:			virtual void getVMBR(Region& out) const = 0;			virtual void getMBRAtTime(double t, Region& out) const = 0;			virtual ~IEvolvingShape() {}		}; // IEvolvingShape	}	IObjectStream* externalSort(IObjectStream& source, unsigned long bufferSize);	IObjectStream* externalSort(IObjectStream& source, IObjectComparator& pComp, unsigned long bufferSize);	class Variant	{	public:		Variant();		VariantType m_varType;		union		{			long lVal;                 // VT_LONG			long long llVal;           // VT_LONGLONG			byte bVal;                 // VT_BYTE			short iVal;                // VT_SHORT			float fltVal;              // VT_FLOAT			double dblVal;             // VT_DOUBLE			char cVal;                 // VT_CHAR			unsigned short uiVal;      // VT_USHORT			unsigned long  ulVal;      // VT_ULONG			unsigned long long ullVal; // VT_ULONGLONG			int intVal;                // VT_INT			unsigned int uintVal;      // VT_UINT			bool blVal;                // VT_BOOL			char* pcVal;          // VT_PCHAR			void* pvVal;          // VT_PVOID		} m_val;	}; // Variant	class PropertySet : public ISerializable	{	public:		PropertySet() {}		PropertySet(const byte* data);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -