ANSI String Class

Introduction

ANSI string is a type used in most VCL forms. Contrary to the following documentation, the type ANSIString is declared using the type String (defined in classes.hpp) , as opposed to string (from ) You will notice that while there are a large number of methods associated with String, there are no I/O methods. To write a String to a stream, use c_str() to convert it to a simple c-string and use the insert operator (<< ). Reading a string off a line is a bit more complex. The following function will read a String that covers a line (including blanks). It has protection against a read that occurred before it and left an end of line marker.

String  myReadLine(istream &in)
 {
	long int eoln;
	char inval[255];
	char *ptr;
	do
	{
		in.getline(inval,255);
		ptr = strchr(inval,'\0');
		eoln = ptr -inval;
	} while (!eoln && !in.eof());
	return String(inval);
 }

This function is not associated with any class, so you can import it anytime you need it.

Header

Classes.hpp

Description

C++Builder implements the AnsiString type as a class. AnsiString is designed to function like the Delphi long string type. Accordingly, AnsiString provides the following string handling characteristics which are required when you call VCL-type functions that use any of the Delphi long string types.

If you don’t provide an initial value, AnsiString variables are initialized to zero upon instantiation.

Methods

		~AnsiString
		AnsiCompare
		AnsiCompareIC
		AnsiLastChar
		AnsiPos
		AnsiString
		ByteType
		c_str
		CurrToStr
		CurrToStrF
		Delete
		FloatToStrF
		FmtLoadStr
		Format
		FormatFloat
		Insert
		IntToHex
		IntToHex

		IsDelimiter
		IsEmpty
		IsLeadByte
		IsPathDelimiter
		IsTrailByte
		LastDelimiter
		Length
		LoadStr
		LowerCase
		operator !=
		operator []
		operator +
		operator +=
		operator <
		operator <=
		operator =
		operator ==

		operator >
		operator >=
		Pos
		SetLength
		StringOfChar
		SubString
		ToDouble
		ToInt
		ToIntDef
		Trim
		TrimLeft
		TrimRight
		TStringMbcsByteType
		Unique
		UpperCase
		WideChar
		WideCharBufSize