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

📄 cstring.hpp

📁 bt848,bt878 a采集卡的探测
💻 HPP
字号:
 /*
 * Clases para manejar Strings
 */

#ifndef _CString_HPP
#define _CString_HPP

#include <windows.h>
#include <tchar.h> // Make all functions UNICODE safe.
#include "CMemory.hpp"

// Be careful, this CString operates on references - Does NOT copy on write!

class CString  {

protected:

	CMemory string;				// The block that contains the string

public:

	// Constructors
	CString( ) ;
	CString( LPTSTR pusz );
	CString( CString& d ) { string = d.string; }

	// Operators
	CString& operator=( LPTSTR pusz );
	CString& operator=( CString& d ) { string = d.string; return *this; }

	// Operator+=
	friend CString& operator+=( CString& i, LPTSTR pusz );
	friend CString& operator+=( CString& i, CString& d );

	// operator+
	friend CString	operator+( LPTSTR pusz ,CString& s1);
	friend CString	operator+( CString& d ,CString& s1);
	friend CString	operator+( CString& s1, LPTSTR pusz );

	// comparison ops. (case sensitive)
	friend bool operator<( CString& c2,LPTSTR pusz );
	friend bool operator<( LPTSTR pusz ,CString& c2);
	friend bool operator<( CString& c1, CString& c2 );
	friend bool operator<=( CString& c2,LPTSTR pusz );
	friend bool operator<=( LPTSTR pusz ,CString& c2);
	friend bool operator<=( CString& c1, CString& c2 );
	friend bool operator>( CString& c2,LPTSTR pusz );
	friend bool operator>( LPTSTR pusz ,CString& c2);
	friend bool operator>( CString& c1, CString& c2 );
	friend bool operator>=( CString& c2,LPTSTR pusz );
	friend bool operator>=( LPTSTR pusz ,CString& c2);
	friend bool operator>=( CString& c1, CString& c2 );
	friend bool operator==( CString& c2,LPTSTR pusz );
	friend bool operator==( LPTSTR pusz ,CString& c2);
	friend bool operator==( CString& c1, CString& c2 );
	friend bool operator!=( CString& c2,LPTSTR pusz );
	friend bool operator!=( LPTSTR pusz ,CString& c2);
	friend bool operator!=( CString& c1, CString& c2 );

	// Comparison Ops. (Count specified)
	friend int NCmp( CString& c2 ,LPTSTR pusz ,const UINT n);
	friend int NCmp( LPTSTR pusz ,CString& c2 ,const UINT n);
	friend int NCmp( CString& c1 ,CString& c2 ,const UINT n);

	// Properties
	UINT Len() const		{ return string.Size()-sizeof(TCHAR); }		// Len
	bool IsEmpty() const	{ return string.Size()<=sizeof(TCHAR); }	// IsEmpty
	LPTSTR Ptr() const		{ return LPTSTR(string.Ptr()); }			// Pointer to the String
	TCHAR operator[] (const UINT idx) const { return Ptr()[idx]; }		// Read char operator

	bool SetLen(const UINT vx);				
	void Zero() { SetLen(0); }
	void Empty() {Zero();}				
	void Flush() {Zero();}				

	// Some useful fns.
	friend CString AllTrim(CString& c);									// AllTrim
	friend CString LeftTrim(CString& c);								// LeftTrim
	friend CString RightTrim(CString& c);								// RightTrim
	friend CString Left(CString& s,const UINT c);						// Leave n chars to the left
	friend CString Right(CString& s,const UINT c);						// Leave n chars from the right
	friend CString Mid(CString& s,const UINT p,const UINT c);			// leave from char 'p' (base 0) c chars.
	friend CString Printf(LPTSTR string, ... );							// printf-like fn that gives result on String
	friend CString LoadStringResource(HINSTANCE instance,UINT res);		// To load an String Resource

	// Destructor
	~CString() {}

};

// Utility fns
INT MessageBox(HWND hwnd,CString& Message,LPCTSTR caption,UINT type);

#endif

⌨️ 快捷键说明

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