Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ASCString Class Reference

The ASCString class provides an abstract way to manipulate strings. More...

#include <ascstring.h>

Inheritance diagram for ASCString:

Inheritance graph
[legend]
List of all members.

Public Types

typedef ASCStringHelpers::charT charT
typedef ASCStringHelpers::NoncharT NoncharT

Public Member Functions

 ASCString ()
 ASCString (const charT *pS)
 ASCString (const charT *pS, size_type n)
 ASCString (size_type n, charT c)
 ASCString (const_iterator first, const_iterator last)
 ASCString (const ASCCharTString &s)
 ASCString (const ASCCharTString &s, size_type pos, size_type n)
 ASCString (const ASCAdaptatorString &s)
 ASCString (const ASCAdaptatorString &s, size_type pos, size_type n)
ASCStringoperator= (const ASCAdaptatorString &s)
ASCStringoperator= (const ASCCharTString &s)
ASCStringoperator= (const charT *pS)
int compare_ci (const ASCCharTString &s) const
int compare_ci (size_type p0, size_type n0, const ASCCharTString &s)
int compare_ci (size_type p0, size_type n0, const ASCCharTString &s, size_type pos, size_type n)
int compare_ci (const charT *pS) const
int compare_ci (size_type p0, size_type n0, const charT *pS, size_type pos) const
ASCStringreplaceAll (const ASCString &old, const ASCString &newString)
 replaces all occurances of old with newString
ASCStringreplaceAll_ci (const ASCString &old, const ASCString &newString)
 replaces all occurances of old with newString ; case insensitive
ASCStringtoLower ()
ASCStringtoUpper ()
ASCStringformat (const charT *pFormat,...)
ASCStringvaformat (const charT *pFormat, va_list ap)
void printf ()
bool endswith (const ASCString &s) const
 Checks if the last characters of string are equal to s.

Static Public Member Functions

static ASCString toString (int i)
 converts the parameter to a String
static ASCString toString (double d)
 converts the parameter to a String

Related Functions

(Note that these are not member functions.)

ASCString copytoLower (const ASCString &String)
ASCString copytoUpper (const ASCString &String)

Detailed Description

The ASCString class provides an abstract way to manipulate strings.

Depending on the prepocessor definition _UNICODE, ASCString will use Unicode text or C-null terminated char array.

Warning:
Be extremely carefull if you have to modify this class. No virtual destructor is provided. This may result in memory leaks if you modify this class to free dynamically allocated memory in its destructor. The same warning applies to classes deriving from ASCString ( if any ).
    ASCString* pStr = new ASCString( "My string" );

    ASCInheritedString* pInherited = ( ASCInheritedString* ) pStr;

    // pStr's destructor will not be called when deleting pInherited. 
    // If ASCString has been modified to free memory in its destructor, 
    // this memory will never be freed up.
    delete pInherited;      

Definition at line 13 of file ascstring.h.


Member Typedef Documentation

typedef ASCStringHelpers::charT ASCString::charT
 

charT is an alias to ASCStringHelpers::charT, the character type used to represent strings internally.

Definition at line 21 of file ascstring.h.

typedef ASCStringHelpers::NoncharT ASCString::NoncharT
 

NoncharT is an alias to ASCStringHelpers::NoncharT, the complementary character type used to convert strings not using charT types.

Definition at line 29 of file ascstring.h.


Constructor & Destructor Documentation

ASCString::ASCString  )  [inline]
 

Construct an ASCString object.

Definition at line 103 of file ascstring.h.

ASCString::ASCString const charT pS  )  [inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
pS a pointer to a NULL-terminated array of charT element types.

Definition at line 113 of file ascstring.h.

ASCString::ASCString const charT pS,
size_type  n
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
pS a pointer to a NULL-terminated array of charT element types.
n the number of elements from pS to use to initialise the ASCString object.

Definition at line 125 of file ascstring.h.

ASCString::ASCString size_type  n,
charT  c
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
n the repeat count of c.
c a single charT element type to be repeated n times.

Definition at line 137 of file ascstring.h.

ASCString::ASCString const_iterator  first,
const_iterator  last
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
first a const iterator delimiting the begining of a range of charT element types to be used to construct this ASCString.
last a const iterator delimiting the ending of a range of charT element types to be used to construct this ASCString.

Definition at line 151 of file ascstring.h.

ASCString::ASCString const ASCCharTString s  )  [inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
s a const reference to an ASCCharTString object to be used to construct this ASCString.

Definition at line 162 of file ascstring.h.

ASCString::ASCString const ASCCharTString s,
size_type  pos,
size_type  n
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
s a const reference to an ASCCharTString object to be used to construct this ASCString.
pos the position of the first character in s to be used to construct this ASCString.
n the count of characters used to construct this ASCString begining at position pos.

Definition at line 176 of file ascstring.h.

ASCString::ASCString const ASCAdaptatorString s  )  [inline, explicit]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
s a const reference to an ASCAdaptatorString object to be used to construct this ASCString.
Exceptions:
range_error The range_error exception is raised when not all the characters of ASCAdaptatorString can be converted to ASCCharTString's characters.

Definition at line 195 of file ascstring.h.

References ASCStringHelpers::_ConvertToCharT().

ASCString::ASCString const ASCAdaptatorString s,
size_type  pos,
size_type  n
[inline, explicit]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
s a const reference to an ASCAdaptatorString object to be used to construct this ASCString.
pos the position of the first character in s to be used to construct this ASCString.
n the count of characters used to construct this ASCString begining at position pos.
Exceptions:
range_error The range_error exception is raised when not all the characters of ASCAdaptatorString can be converted to ASCCharTString's characters.

Definition at line 223 of file ascstring.h.

References ASCStringHelpers::_ConvertToCharT().


Member Function Documentation

int ASCString::compare_ci size_type  p0,
size_type  n0,
const charT pS,
size_type  pos
const [inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Compare the range [ p0 , n0 ] of this ASCString with up to [ 0, pos ] elements of pS.

Definition at line 335 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

int ASCString::compare_ci const charT pS  )  const [inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 325 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

int ASCString::compare_ci size_type  p0,
size_type  n0,
const ASCCharTString s,
size_type  pos,
size_type  n
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Compare the range [ p0 , n0 ] of this ASCString with the range [ pos, n ] of ASCCharTString.

Definition at line 315 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

int ASCString::compare_ci size_type  p0,
size_type  n0,
const ASCCharTString s
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Compare the range [ p0 , n0 ] of this ASCString with the whole ASCCharTString.

Definition at line 304 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

int ASCString::compare_ci const ASCCharTString s  )  const [inline]
 

Compare two strings, case insensitive.

Parameters:
s a const reference to an ASCCharTString object to be used to construct this ASCString.

Definition at line 294 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

Referenced by NamedIntProperty::operation_eq(), TagIntProperty::operation_eq(), TagArrayProperty::operation_eq(), BoolProperty::operation_eq(), ASCGUI_Window::parsePanelASCTXT(), and TextFormatParser::startLevel().

bool ASCString::endswith const ASCString s  )  const
 

Checks if the last characters of string are equal to s.

Definition at line 146 of file ascstring.cpp.

Referenced by FileTransfer::constructFileName(), and IconRepository::getIcon().

ASCString & ASCString::format const charT pFormat,
  ...
 

Format this ASCString as sprintf does.

Parameters:
pFormat a format-control string.
... Optional arguments
Returns:
returns a reference on this ASCString.
See standard system documentation for more information on sprintf.

Definition at line 78 of file ascstring.cpp.

References vaformat().

Referenced by compareMapResources(), AttackPanel::dispValue(), ResourceTribute::getDetailledName(), TurnPassed::getDetailledName(), tinvalidversion::getMessage(), GuiFunctions::BuildingConstruction::getName(), GuiFunctions::VehicleBuildingGui::getName(), GuiFunctions::ObjectBuildingGui::getName(), GuiFunctions::AttackGui::getName(), getPlayerStrength(), GetVideoModes::GetVideoModes(), tnetworkloaders::loadnwgame(), VisibilityLayer::paintSingleField(), printTech(), DiplomaticStateVector::propose(), showUnitEndurance(), DiplomaticStateVector::sneakAttack(), MapCoordinate::toString(), Resources::toString(), DoubleArrayProperty::toString(), FloatProperty::toString(), toString(), transfer_all_outstanding_tribute(), CargoInfoWindow::update(), and viewterraininfo().

ASCString & ASCString::operator= const charT pS  )  [inline]
 

Definition at line 280 of file ascstring.h.

ASCString & ASCString::operator= const ASCCharTString s  )  [inline]
 

Assign a new value to an ASCString object.

Parameters:
s a const reference to an ASCCharTString object to be assigned to this ASCString.
Returns:
returns a reference to this ASCString.

Definition at line 273 of file ascstring.h.

ASCString & ASCString::operator= const ASCAdaptatorString s  )  [inline]
 

Definition at line 254 of file ascstring.h.

Referenced by FileName::operator=().

void ASCString::printf  ) 
 

Print this ASCString to the standard output stream.

Note:
this function is provided for convenience. It is equivalent to :
    ASCString strFoo ( "foo" );

    printf ( "%s", strFoo.c_str () );

See standard system documentation for more information on printf.

Definition at line 137 of file ascstring.cpp.

References ASCStringHelpers::_Printf().

ASCString & ASCString::replaceAll const ASCString old,
const ASCString newString
 

replaces all occurances of old with newString

Definition at line 231 of file ascstring.cpp.

Referenced by FileTransfer::send().

ASCString & ASCString::replaceAll_ci const ASCString old,
const ASCString newString
 

replaces all occurances of old with newString ; case insensitive

Definition at line 240 of file ascstring.cpp.

References copytoLower().

Referenced by FileTransfer::send().

ASCString & ASCString::toLower  ) 
 

Convert this ASCString to lowercase.

Returns:
returns a reference on this ASCString.

Definition at line 36 of file ascstring.cpp.

References ASCStringHelpers::_Strcpy(), and ASCStringHelpers::_Strlwr().

Referenced by copytoLower(), editTechAdapter(), TextPropertyGroup::Entry::Entry(), PropertyContainer::find(), PropertyContainer::Property::findEntry(), loadASCFieldImage(), ItemSelectorWidget::nameMatch(), TextFormatParser::parseLine(), TextPropertyGroup::processAlias(), TechAdapter::runTextIO(), PropertyContainer::Property::setName(), ASCGUI_Window::setup(), and TextFormatParser::startLevel().

ASCString ASCString::toString double  d  )  [static]
 

converts the parameter to a String

Definition at line 210 of file ascstring.cpp.

References format().

ASCString ASCString::toString int  i  )  [static]
 

converts the parameter to a String

Definition at line 193 of file ascstring.cpp.

References format().

Referenced by AllianceSetupWidget::AllianceSetupWidget(), tsearchreactionfireingunits::attack(), BuildingTypeCountWidget::BuildingTypeCountWidget(), BuildingTypeResourceWidget::BuildingTypeResourceWidget(), ChanceSettingsDialog::buildUpForm(), checkForUniqueUnitIDs(), ChooseTech::ChooseTech(), FileTransfer::constructFileName(), DashboardPanel::DashboardPanel(), ExperienceOverview::eventDraw(), EventEditor::EventEditor(), execaction_pg(), execuseraction2(), CGameOptions::Mouse::getButtonName(), SoundSystem::getDiagnosticText(), getDiplomaticStateImage(), WeatherAreaInformation::getInformation(), WindInformation::getInformation(), Player::getName(), CargoGuiFunctions::RecycleUnit::getName(), getnextfilenumname(), getPlayerStrength(), getProductionString(), getVisibilityStatistics(), WeapDist::getWeaponStrength(), InvalidID::InvalidID(), Maped_MainScreenWidget::Maped_MainScreenWidget(), DashboardPanel::painter(), AttackPanel::painter(), VisibilityLayer::paintSingleField(), ASCGUI_Window::parsePanelASCTXT(), PlayerColorPanel::PlayerColorPanel(), ObjectStorage< T >::print(), VehicleTypeRenderer::renderWidget(), ReplayRecorderDialog::ReplayRecorderDialog(), resourceAnalysis(), ObjectType::runTextIO(), Maped_MainScreenWidget::selectionChanged(), FileTransfer::send(), ASCGUI_Window::setLabelText(), Transferrable::show(), showCargoSummary(), showSDLInfo(), showtechnology(), DashboardPanel::showUnitData(), showUnitEndurance(), WeaponInfoPanel::showWeapon(), TechWidget::TechWidget(), VehicleCounterFactory::toString(), ASCImageArrayProperty::toString(), ResearchWindow::update(), BuildingControlWindow::update(), Maped_MainScreenWidget::updateStatusBar(), UnitInfoDialog::userHandler(), VehicleTypeCountWidget::VehicleTypeCountWidget(), VehicleTypeResourceWidget::VehicleTypeResourceWidget(), viewMiningPower(), viewterraininfo(), viewUnitSetinfo(), WeatherDialog::WeatherDialog(), and WindSpeedSettingsDialog::WindSpeedSettingsDialog().

ASCString & ASCString::toUpper  ) 
 

Convert this ASCString to uppercase.

Returns:
returns a reference on this ASCString.

Definition at line 55 of file ascstring.cpp.

References ASCStringHelpers::_Strcpy(), and ASCStringHelpers::_Strupr().

Referenced by copytoUpper(), and BuildingType::LocalCoordinate::LocalCoordinate().

ASCString & ASCString::vaformat const charT pFormat,
va_list  ap
 

Definition at line 91 of file ascstring.cpp.

References ASCStringHelpers::_Vsnprintf().

Referenced by displaymessage2(), fatalError(), format(), and MessagingHubBase::message().


Friends And Related Function Documentation

ASCString copytoLower const ASCString String  )  [related]
 

Duplicate and convert to lowercase.

Parameters:
String a const reference to an ASCString object which will be duplicated and converted to lowercase.
Returns:
returns an ASCString object that contains a lowercased copy of String.

Definition at line 167 of file ascstring.cpp.

References toLower().

Referenced by replaceAll_ci().

ASCString copytoUpper const ASCString String  )  [related]
 

Duplicate and convert to uppercase.

Parameters:
String a const reference to an ASCString object which will be duplicated and converted to uppercase.
Returns:
returns an ASCString object that contains an uppercased copy of String.

Definition at line 185 of file ascstring.cpp.

References toUpper().


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 02:16:13 2008 for Advanced Strategic Command by  doxygen 1.4.2