Using Variant to Store Point
来源:互联网 发布:安知玉如意书包网 编辑:程序博客网 时间:2024/06/08 09:43
Using Variant to Store Point
Variant is a very powerful data type to store 'any' data. With the help of COM class _variant_t, VARIANT bacomes very easy to use. But _variant_t dosen't support all kinds of data type, for example, point data with two or three elements. Variant can hold pointer, but the memory management becomes a stubborn problem when copying variant. I'm trying to find a better way to solve the problem, but I don't want to rewrite a variant. So, dose the way exist?
Many UI-libs use variant to hold data of properties, such as BCGPControlBar, and they do support point displaying. Actually the point elements are formated to a string so that they be stored into one property. But it's very boring to parse values between points and variant, so it's a good idea to write a adapter for them. This adapter takes charge to format point data to string, extract point data from string, and ex-convert with _variant_t.
if we have a point class like this:
class Point3D
{
public :
Point3D() {}
Point3D( double x, double y, double z);
double x();
double y();
double z();
private :
double x, y, z;
} ;
we can write our point adapter as following:
class PointAdapter
{
private :
CString m_strData;
public :
PointAdapter();
PointAdapter( const Point3D & point);
PointAdapter( const _variant_t & point);
operator Point3D() const ;
operator _variant_t() const ;
} ;
now, we can use the classes:
Point3D point( 1 , 2 , 3 );
_variant_t var = PointAdapter(point);
Point3D point2 = PointAdapter(var);
- Using Variant to Store Point
- Store binary data to MySQL using escape_string in MySQLdb
- Point to Point Communication
- VARIANT to CString
- Point to Point Protocol (PPP)
- JMS(点对点point-to-point)
- 5.1. Point-to-Point Channel
- 14. 66. 2. 用Vector存储JTree的值 Using Vector to store JTree values
- variant
- variant
- VARIANT
- Variant
- Variant
- VARIANT
- VARIANT
- Variant
- point to pointer
- Up to this point
- 字符编码笔记:ASCII,Unicode和UTF-8
- OPENCV应用中BMP与IPLIAMGE图像格式的相互转换
- 疯狂.NET 通用权限设计 C/S后台管理,B/S前台调用源码样例程序源码下载之 --- 数据集权限
- 关于struts2中使用POI的方式导出EXCEL文件时的国际化问题
- Spring中获得bean的方法
- Using Variant to Store Point
- 1分钟学会使用Tor代理教程
- 几种获得spring里注册Bean的方法
- C++虚函数表解析
- struts2+hibernate分页
- Visual Studio 2005(2008)更改App_Code.dll名称
- 饮品店:单价低于5元有市场
- Digital Forensics Framework v0.4.3 available
- XNA开发软件硬件环境介绍及下载链接