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

📄 string.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 4 页
字号:
/*------------------------------------------------------------------------------*
 * File Name: string.h															*
 * Creation: CPY 4/2/2001														*
 * Purpose: Origin C header	for string class and other related functions		*
 * Copyright (c) OriginLab Corp.2001											*
 * All Rights Reserved															*
 *------------------------------------------------------------------------------*/

#ifndef _STRING_H
#define _STRING_H

#include <common.h> // must always include this
#include <OC_const.h> // consts used in Origin internal functions

 
typedef vector<string> StringArray;

/** >Composite Data Types
		An Origin C string is a null terminated array of characters similar to objects
		created using the MFC CString class. The Origin C string class includes many
		useful methods for manipulating strings (text data). An array of strings has been
		implmented using the following type definition: typedef vector<string> StringArray;
	Example:
		string str = "  abcdefg   ";
		str.TrimRight();
		str.TrimLeft();
		ASSERT( str.Compare("abcdefg")==0 );
		ASSERT( str.Compare("ABCDEFG")!=0 );
		ASSERT( str.CompareNoCase("ABCDEFG")==0 );
		str = str.Left(5);
		str = str.Mid(1);
		ASSERT( str.Compare("bcde")==0 );
		ASSERT( str.Find('d')==2 );
*/
class string  
{

public:

	/**
		Remarks:
			Default constructor, creates a new empty string object
		Example:
			string str1;  //empty string
			ASSERT(str1.IsEmpty());
		Parameters:
			None.
		Return:
			None.
	*/
	string( );
	
	/**
		Remarks:
			Constructs a string object from a null-terminated string.
		Example:
			string str2("cow");  //create from a string literal
			ASSERT(str2.Compare("cow")==0);
		Parameters:
			lpcszSrc = A null-terminated string to be copied into this string object.
		Return:
			None.
	*/
	string( LPCSTR lpcszSrc );
	
	/**
		Remarks:
			Constructs a string object from a character that is repeated nRepeat times.
		Example:
			string str3('a',6);  
			ASSERT(str3.Compare("aaaaaa")==0);
		Parameters:
			ch = A single character to be repeated nRepeat times.
			nRepeat = The repeat count for ch.
		Return:
			None.
	*/
	string( char ch, int nRepeat = 1 );	
		
	/**
		Remarks:
			Constructs a string object from an array of characters of length nlength,
			not null-terminated.
		Example:
			char * str="Origin C";
			int nLength=8;
			string str4(str,nLength);
			ASSERT(str4.Compare("Origin C")==0);
		Parameters:
			lpch = A pointer to an array of characters.
			nLength = length of characters.
		Return:
			None.
	*/
	string( LPCTSTR lpch, int nLength );

#ifdef	ORIGIN_COM_SUPPORT
	/**
			Constructs a string object from any _VARIANT type variable which holds a string
		Remarks:
			This function is available only for OriginPro versions, or with a special COM enabled license
		Example:
			void test()
			{
			   _VARIANT obj;
			   string s = "Hello";
			   obj = s;
			   string str = obj;
			}
 
		Parameters:
			var = a _VARIANT object
		Return:
			None.
	*/
	string( _VARIANT var );
	
#endif //#ifdef	ORIGIN_COM_SUPPORT

#if  _OC_VER > 0x0703
	/**
			Set the content of this string from a vector of bytes
		Example:
			vector<byte> vTemp = {'A','B','C','D'};
			string str ="something to make it longer";
			str.SetBytes(vTemp);
			ASSERT(str.Compatre("ABCD") == 0);
			
		Parameters:
			vb = [in] vector of bytes to be put into this string
		Return:
			Returns TRUE on success
		SeeAlso:
			vectorbase::SetBytes
	*/
 	BOOL     SetBytes(vector<byte>& vb);

	/**
			Copy the charactors of this string into a byte vector
		Example:
			string str = "ABCD";
			vector<byte> vResult;
			str.GetBytes(vResult);
			ASSERT(vResult.GetSize() == 4);
		Parameters:
			vb = [out] vector of bytes to receive the charactors from this string
		Return:
			Returns TRUE on success
		SeeAlso:
			vectorbase::GetBytes
	*/
 	BOOL     GetBytes(vector<byte>& vb);
#endif // _OC_VER > 0x0703
	/**
		Remarks:
			This member function outputs the string. 
		Example:
			string str="Hello World";
			str.Write(WRITE_OUTPUT_LOG);  //Hello World typed out to the Results Log
		Parameters:
			iDestination = one of enum {WRITE_SCRIPT_WINDOW, WRITE_STATUS_BAR, WRITE_OUTPUT_LOG, WRITE_MESSAGE_BOX, WRITE_COMPILER_OUTPUT};
		Return:
			None.
		SeeAlso:
			string::WriteLine
	*/
	void	Write( int iDestination );// 0 = ScriptWindow
	
	/**
		Remarks:
			This member function outputs the string adding return and
			newline characters automatically. 
		Example:
			string str="Hello World";
			str.WriteLine(2);  //Hello World typed out to the Results Log cursor is at next line
		Parameters:
			iDestination = one of enum {WRITE_SCRIPT_WINDOW, WRITE_STATUS_BAR, WRITE_OUTPUT_LOG, WRITE_MESSAGE_BOX, WRITE_COMPILER_OUTPUT};
		Return:
			None.
		SeeAlso:
			string::Write
	*/
	void	WriteLine( int iDestination );// will add \r\n automatically

	
	/**
		Remarks:
			This member function formats and stores a series of characters 
			and values in the string. Each optional argument (if any) is
			converted and output according to the corresponding format 
			specification in lpcszFormat.  Please note that it is your responsibility
			to match the data type with the correct formatting specification.
		Example1:
			char sz[10] = "abcdefg";
			int nn = 10;
			double dd = 3.1416;
			string str;
			str.Format("Results = %s, %d, %5.4f", sz, nn, dd);
			ASSERT(0 == str.Compare("Results = abcdefg, 10, 3.1416"));

		Example2:
			// the following usage will generate runtime error due to 
			// incorrect data being used
			string str;
			str.Format("x1=%f, x2=%f", 5, 3.4); // 5 is not a double, will generate runtime error
			str.Format("x1=%f, x2=%f", 5.0, 3.4);// this will work correctly

		Parameters:
			lpcszFormat = A format-control string.
		Return:
			none.
		SeeAlso:
			printf
	*/
	void	Format( LPCSTR lpcszFormat, ... );
	
	
	/**
		Remarks:
			This member function returns the number of bytes (or number
			of characters in this string object.  The count does not 
			include a null terminator.
		Example:
			string str1( "cow" );
			ASSERT( str1.GetLength() == 3 );
		Parameters:
			None.
		Return:
			An integer value equal to the length (number of bytes minus 
			the null character) of this string.
	*/
	int		GetLength( );		

	/**
		Remarks:
			This member function with no parameters trims leading whitespace
			characters from the string.  It removes newline, space, and tab
			characters.
		Example:
			string str="   Hello World";
			str.TrimLeft();
			ASSERT(str.Compare("Hello World")==0);
		Parameters:
			None.
		Return:
			None.
		SeeAlso:
			string::Mid, string::Left, string::Right, string::MakeUpper, string::MakeLower, string::Format
	*/
	void	TrimLeft( );
	
	/**
		Remarks:
			Remove a particular character from this string.
		Example:
			string str="Hello World";
			str.TrimLeft('H');
			ASSERT(str.Compare("ello World")==0);
		Parameters:
			chTarget = character to be trimmed.
		Return:
			None.
		SeeAlso:
			string::Mid, string::Left, string::Right, string::MakeUpper, string::MakeLower, string::Format
	*/		
	void	TrimLeft( char chTarget );
	
	/**
		Remarks:
			Remove a group of characters from this string.
		Example:
			string str="****Hello World";
			str.TrimLeft("****");
			ASSERT(str.Compare("Hello World")==0);
		Parameters:
			lpszTargets = A pointer to a string containing the target
			characters to be trimmed.
		Return:
			None.
		SeeAlso:
			string::Mid, string::Left, string::Right, string::MakeUpper, string::MakeLower, string::Format
	*/
	void	TrimLeft( LPCSTR lpszTargets );
	
	/**
		Remarks:
			This member function with no parameters trims trailing 
			whitespace characters from the string. It removes trailing 
			newline, space, and tab characters from the string. 
		Example:
			string str="Hello World    ";
			str.TrimRight();
			ASSERT(str.Compare("Hello World")==0);
		Parameters:
			None.
		Return:
			None.
		SeeAlso:
			string::Mid, string::Left, string::Right, string::MakeUpper, string::MakeLower, string::Format
	*/
	void	TrimRight( );
	
	/**
		Remarks:
			Removes a particular character from the end of a string. 
		Example:
			string str="Hello World";
			str.TrimRight('d');
			ASSERT(str.Compare("Hello Worl")==0);
		Parameters:
			chTarget = character to be trimmed.
		Return:
			None.
		SeeAlso:
			string::Mid, string::Left, string::Right, string::MakeUpper, string::MakeLower, string::Format
	*/
	void    TrimRight( char chTarget );
	
	/**
		Remarks:
			Removes a particular group of character from the end of a 
			string. 
		Example:
			string str="Hello World****";
			str.TrimRight("****");
			ASSERT(str.Compare("Hello World")==0);
		Parameters:
			lpszTargets = A pointer to a string containing the target
			characters to be trimmed.
		Return:
			None.
		SeeAlso:
			string::Mid, string::Left, string::Right, string::MakeUpper, string::MakeLower, string::Format
	*/
	void	TrimRight( LPCSTR lpszTargets );
	
	/**
		Remarks:
			Extracts the leftmost nCount characters from this string
			object and returns a copy of the extracted substring. If
			nCount exceeds the string length, then the entire string 
			is extracted.
		Example:
			string str1("abcdef");
			ASSERT ( 0==str1.Left(2).Compare("ab") );
		Parameters:
			nCount = The number of characters to extract starting from the
			left.
		Return:
			A string object containing a copy of the specified range of 
			characters. Note that the returned string object may be 
			empty. 
		SeeAlso:
			string::Right
	*/
	string  Left( int nCount );	
		
	/**
		Remarks:
			Extracts the rightmost nCount characters from this string
			object and returns a copy of the extracted substring. If
			nCount exceeds the string length, then the entire string is
			extracted. 
		Example:
			string str1("abcdef");
			ASSERT ( 0 == str1.Right(2).Compare("ef") );
		Parameters:
			nCount = The number of characters to extract starting from the
			right.
		Return:
			A string object containing a copy of the specified range of 
			characters. Note that the returned string object may be 
			empty. 
		SeeAlso:
			string::Left
	*/
	string  Right( int nCount );
	
	/**
		Remarks:
			This member function performs a case-sensitive comparison 
			of this string object with another string.
		Example:
			string str1("abc");
			string str2("abd");
			ASSERT(str1.Compare("abb")==1);
			ASSERT(str1.Compare(str2)==-1);
			ASSERT(str1.Compare("abc")==0);
		Parameters:
			lpsz = The other string used for comparison.
		Return:
			Zero if the strings are identical, < 0 if this string 

⌨️ 快捷键说明

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