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

📄 twin.h

📁 上传文件到服务器-similar windows drawing the image coding, code-and following through vc 6.0
💻 H
字号:


#if !defined(AFX_TWIN_H__062482F4_E318_48C9_B813_36A395D49559__INCLUDED_)
#define AFX_TWIN_H__062482F4_E318_48C9_B813_36A395D49559__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <vector>
#include <iterator>
#include <map>


#include <COMDEF.H>
#include <EnBSTR.h>




using namespace std;
//extern class TwinVector;



typedef map<_bstr_t, _bstr_t > BSTRT2BSTRT;
class MapBstrt2Bstrt: public BSTRT2BSTRT
{
	
};


class Twin  
{
public:
	//constructors:
	Twin() : bstrName(L""), bstrValue(L"") {};
    
	//_______________________________________________________
	Twin(_bstr_t NewName, _bstr_t NewValue)  
	{
		bstrName  = L"";
		bstrValue  = L"";
		
		bstrName  += NewName;
		bstrValue  += NewValue;
	};
	
	Twin(long lName, long lValue)
	{
		
#ifdef UNICODE
		wchar_t     chOut[6];
#else
		char     chOut[6];
#endif
		
		
		wsprintf(chOut, _T("%d"), lName );
		bstrName  = chOut;  
		
		wsprintf(chOut, _T("%d"), lValue );
		bstrValue  = chOut;  
	};
	//_______________________________________________________
	
	
	virtual ~Twin(){ };
	
	
	
	//methods 
	_bstr_t    GetName()      {return   bstrName ;};
	_bstr_t    GetValue()      {return   bstrValue ;};
	
	void    PutName(_bstr_t  NewName)  {bstrName  = NewName  ;};
	void    PutValue(_bstr_t NewValue)  {bstrValue  = NewValue  ;};
	
	//_______________________________________________________
	void    PutName(long lName)  
	{
#ifdef UNICODE
		wchar_t     chOut[6];
#else
		char     chOut[6];
#endif
		wsprintf(chOut, _T("%d"), lName );
		bstrName  = chOut;
	};

	void    PutValue(long lValue)  
	{
#ifdef UNICODE
		wchar_t     chOut[6];
#else
		char     chOut[6];
#endif
		wsprintf(chOut, _T("%d"), lValue );
		bstrValue  = chOut;
		
	};
	//_______________________________________________________
	
	
	//_______________________________________________________
	MapBstrt2Bstrt   GetValueAsMap()
	{
		MapBstrt2Bstrt    map;
		MapBstrt2Bstrt::iterator itMap;
		
		CEnBSTR     bstrToken;
		CEnBSTR     bstrTokenWord  = L"=";
		CEnBSTR     word;
		CEnBSTR     enbstrName;
		CEnBSTR     enbstrValue;
		
		CEnBSTR     enbstr(bstrValue);
		long     l;
		
		//find ";" or "&"
		if ( enbstr.find(L";") >0 ) 
			bstrToken    = ";";
		else
			if ( enbstr.find(L"&") >0 ) 
				bstrToken    = "&";
			else
				if ( enbstr.find(L"=") >0 )  //maybe is just one
					bstrToken    = "&";
				
				
				if (bstrToken.length() > 0)
				{
					l			= enbstr.length();
					word		= enbstr.mid(l-1);
					if (word != bstrToken)  enbstr  +=  bstrToken;
					
					
					while(enbstr.find(bstrToken) > 0)
					{
						l		= enbstr.find(bstrToken);
						word	= enbstr.left(l);    
						enbstr  = enbstr.mid(l+1);
						
						//fill the map
						l    = word.find(bstrTokenWord);
						if (l>0)
						{
							enbstrName		= word.left(l);
							enbstrValue		= word.mid(l+1);
							
							//trim
							enbstrName.replace(L" ", "");
							enbstrValue.replace(L" ", "");
   
							map[enbstrName]	= enbstrValue;
							
							//attributtes
							//bstrName		= enbstrName;
							//bstrValue		= enbstrValue;
						}
					}
					
				}
				
				/* if (! map.empty() )
				{  
				itMap = map.begin();
				AfxMessageBox( (*itMap).first + (*itMap).second );
				}
				*/
				return map;
	};
	//_______________________________________________________
	
private:
	//attributes:
	_bstr_t    bstrName;
	_bstr_t    bstrValue;
	
};

#endif // !defined(AFX_TWIN_H__062482F4_E318_48C9_B813_36A395D49559__INCLUDED_)

⌨️ 快捷键说明

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