Advanced Strategic Command
Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
ASCString Class Reference

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

#include <ascstring.h>

Inheritance diagram for ASCString:
Inheritance graph
[legend]

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 More...
 
ASCStringreplaceAll_ci (const ASCString &old, const ASCString &newString)
 replaces all occurances of old with newString ; case insensitive More...
 
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. More...
 

Static Public Member Functions

static ASCString toString (int i)
 converts the parameter to a String More...
 
static ASCString toString (unsigned int i)
 
static ASCString toString (double d)
 converts the parameter to a String with base radix More...
 

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 14 of file ascstring.h.

Member Typedef Documentation

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

Definition at line 22 of file ascstring.h.

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

Definition at line 30 of file ascstring.h.

Constructor & Destructor Documentation

ASCString::ASCString ( )
inline

Construct an ASCString object.

Definition at line 105 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
pSa pointer to a NULL-terminated array of charT element types.

Definition at line 115 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
pSa pointer to a NULL-terminated array of charT element types.
nthe number of elements from pS to use to initialise the ASCString object.

Definition at line 127 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
nthe repeat count of c.
ca single charT element type to be repeated n times.

Definition at line 139 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
firsta const iterator delimiting the begining of a range of charT element types to be used to construct this ASCString.
lasta const iterator delimiting the ending of a range of charT element types to be used to construct this ASCString.

Definition at line 153 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
sa const reference to an ASCCharTString object to be used to construct this ASCString.

Definition at line 164 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
sa const reference to an ASCCharTString object to be used to construct this ASCString.
posthe position of the first character in s to be used to construct this ASCString.
nthe count of characters used to construct this ASCString begining at position pos.

Definition at line 178 of file ascstring.h.

ASCString::ASCString ( const ASCAdaptatorString s)
inlineexplicit

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

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

Definition at line 197 of file ascstring.h.

References ASCStringHelpers::_ConvertToCharT().

ASCString::ASCString ( const ASCAdaptatorString s,
size_type  pos,
size_type  n 
)
inlineexplicit

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

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

Definition at line 225 of file ascstring.h.

References ASCStringHelpers::_ConvertToCharT().

Member Function Documentation

int ASCString::compare_ci ( const ASCCharTString s) const
inline

Compare two strings, case insensitive.

Parameters
sa const reference to an ASCCharTString object to be used to construct this ASCString.

Definition at line 296 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

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

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 306 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 317 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 327 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

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 337 of file ascstring.h.

References ASCStringHelpers::_Stricmp().

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
pFormata 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 checkforvictory(), compareMapResources(), AttackPanel::dispValue(), StoringPosition::eventDraw(), DestructUnitCommand::getCommandString(), PowerGenerationSwitchCommand::getCommandString(), ReactionFireSwitchCommand::getCommandString(), CargoMoveCommand::getCommandString(), CancelResearchCommand::getCommandString(), TrainUnitCommand::getCommandString(), RecycleUnitCommand::getCommandString(), JumpDriveCommand::getCommandString(), RepairUnitCommand::getCommandString(), InternalAmmoTransferCommand::getCommandString(), SetResourceProcessingRateCommand::getCommandString(), TransferControlCommand::getCommandString(), RepairBuildingCommand::getCommandString(), ConstructBuildingCommand::getCommandString(), RemoveProductionLineCommand::getCommandString(), RenameContainerCommand::getCommandString(), ChangeDiplomaticState::getCommandString(), DestructBuildingCommand::getCommandString(), ConstructUnitCommand::getCommandString(), DiplomacyCommand::getCommandString(), BuildProductionLineCommand::getCommandString(), PutObjectCommand::getCommandString(), AttackCommand::getCommandString(), PutMineCommand::getCommandString(), DirectResearchCommand::getCommandString(), ServiceCommand::getCommandString(), MoveUnitCommand::getCommandString(), TurnPassed::getDetailledName(), ResourceTribute::getDetailledName(), tinvalidversion::getMessage(), GuiFunctions::AttackGui::getName(), GuiFunctions::ObjectBuildingGui::getName(), getPlayerStrength(), GetVideoModes::GetVideoModes(), DiplomacyCommand::go(), tnetworkloaders::loadnwgame(), VisibilityLayer::paintSingleField(), printTech(), CargoDialog::setUnitInfoWidgets(), showUnitEndurance(), toString::tos(), toString(), FloatProperty::toString(), Resources::toString(), DoubleArrayProperty::toString(), MapCoordinate::toString(), MapCoordinate3D::toString(), transfer_all_outstanding_tribute(), ChangeView::undoAction(), and writeMessageFile().

ASCString & ASCString::operator= ( const ASCAdaptatorString s)
inline

Definition at line 256 of file ascstring.h.

Referenced by FileName::operator=().

ASCString & ASCString::operator= ( const ASCCharTString s)
inline

Assign a new value to an ASCString object.

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

Definition at line 275 of file ascstring.h.

ASCString & ASCString::operator= ( const charT pS)
inline

Definition at line 282 of file ascstring.h.

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 239 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 248 of file ascstring.cpp.

References copytoLower().

Referenced by FileTransfer::send().

ASCString & ASCString::toLower ( )
ASCString ASCString::toString ( int  i)
static

converts the parameter to a String

Definition at line 193 of file ascstring.cpp.

References format().

Referenced by ActionResult::ActionResult(), AllianceSetupWidget::AllianceSetupWidget(), tsearchreactionfireingunits::attack(), JumpDriveCommand::available(), BuildingTypeCountWidget::BuildingTypeCountWidget(), BuildingTypeResourceWidget::BuildingTypeResourceWidget(), ChanceSettingsDialog::buildUpForm(), VehicleType::calcProductionCost(), checkForUniqueUnitIDs(), PackageRepository::checkPackageDependency(), checkUnitsForCrash(), ChooseTech::ChooseTech(), FileTransfer::constructFileName(), DashboardPanel::DashboardPanel(), SavegameWidget::display(), StoringPosition::eventDraw(), ExperienceOverview::eventDraw(), EventEditor::EventEditor(), execaction_pg(), trunreplay::execnextreplaymove(), GuiFunctions::BuildVehicleCommand::execute(), executeUserAction(), CGameOptions::Mouse::getButtonName(), ContainerCommand::getContainer(), ContainerAction::getContainer(), CancelResearchCommand::getDescription(), ConvertContainer::getDescription(), InflictDamage::getDescription(), RemoveMine::getDescription(), DestructUnitCommand::getDescription(), RemoveObject::getDescription(), RepairBuildingCommand::getDescription(), CargoMoveCommand::getDescription(), ChangeDiplomaticState::getDescription(), TrainUnitCommand::getDescription(), DirectResearchCommand::getDescription(), RemoveProductionLineCommand::getDescription(), SetResourceProcessingRateCommand::getDescription(), BuildProductionLineCommand::getDescription(), ConsumeAmmo::getDescription(), RepairUnitCommand::getDescription(), ChangeContainerProperty::getDescription(), ChangeUnitProperty::getDescription(), ChangeObjectProperty::getDescription(), ChangeUnitMovement::getDescription(), SoundSystem::getDiagnosticText(), getDiplomaticStateImage(), WeatherAreaInformation::getInformation(), WindInformation::getInformation(), getInstances(), ActionResult::getMessage(), Player::getName(), CargoGuiFunctions::RecycleUnitCommandButton::getName(), getnextfilenumname(), getPlayerStrength(), getProductionString(), UnitAction::getUnit(), getVisibilityStatistics(), WeapDist::getWeaponStrength(), InvalidID::InvalidID(), log(), Maped_MainScreenWidget::Maped_MainScreenWidget(), DashboardPanel::painter(), AttackPanel::painter(), UnitTrainingLayer::paintSingleField(), VisibilityLayer::paintSingleField(), ASCGUI_Window::parsePanelASCTXT(), PlayerColorPanel::PlayerColorPanel(), ObjectStorage< T >::print(), LuaCommandWriter::printCommand(), LuaCommandListRecorder< CommandList >::printCommand(), GameAction::read(), VehicleTypeRenderer::renderWidget(), ReplayRecorderDialog::ReplayRecorderDialog(), resourceAnalysis(), ResourcePlacementDialog::ResourcePlacementDialog(), UnitTypeTransformation::run(), SpawnBuilding::runAction(), SpawnObject::runAction(), SpawnUnit::runAction(), Package::runTextIO(), ObjectType::runTextIO(), ResourcePlacementDialog::scrollTrackEventFuel(), ResourcePlacementDialog::scrollTrackEventFuelFreeRatio(), ResourcePlacementDialog::scrollTrackEventMaterial(), ResourcePlacementDialog::scrollTrackEventMaterialFreeRatio(), Maped_MainScreenWidget::selectionChanged(), FileTransfer::send(), ASCGUI_Window::setLabelText(), Transferrable::show(), showCargoSummary(), showSDLInfo(), showSurfaceInfo(), ShowNewTechnology::showTechnology(), showUnitAiProperties(), DashboardPanel::showUnitData(), showUnitEndurance(), WeaponInfoPanel::showWeapon(), TechWidget::TechWidget(), testStreamEncoding1(), testStreamEncoding2(), toString::tos(), VersionIdentifier::toString(), VehicleCounterFactory::toString(), ASCImageArrayProperty::toString(), GameAction::undo(), SpawnBuilding::undoAction(), SpawnObject::undoAction(), DirectResearchCommand::undoAction(), SpawnUnit::undoAction(), ResearchWindow::update(), Maped_MainScreenWidget::updateStatusBar(), CargoDialog::updateVariables(), UnitInfoDialog::userHandler(), VehiclePropertyEditor::VehiclePropertyEditor(), VehicleTypeCountWidget::VehicleTypeCountWidget(), VehicleTypeResourceWidget::VehicleTypeResourceWidget(), viewEventInfo(), viewMiningPower(), viewterraininfo(), viewUnitSetinfo(), WeatherDialog::WeatherDialog(), WindSpeedSettingsDialog::WindSpeedSettingsDialog(), and writeMessageFile().

ASCString ASCString::toString ( unsigned int  i)
static

Definition at line 200 of file ascstring.cpp.

References format().

ASCString ASCString::toString ( double  d)
static

converts the parameter to a String with base radix

converts the parameter to a String

Definition at line 218 of file ascstring.cpp.

References format().

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 
)

Friends And Related Function Documentation

ASCString copytoLower ( const ASCString String)
related

Duplicate and convert to lowercase.

Parameters
Stringa 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 loadASCFieldImageArray(), and replaceAll_ci().

ASCString copytoUpper ( const ASCString String)
related

Duplicate and convert to uppercase.

Parameters
Stringa 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: