Loading...
Searching...
No Matches
StringAlias Class Reference

## Public Member Functions

void | SetAlias (String &string, String &alias)
const String & | GetAlias (const String &string) const
int | GetAliases (StringArray &list) const
bool | ReadFromFile (const char *filename)
bool | ReadFromFile (IFILE &input)

## Detailed Description

Definition at line 24 of file StringAlias.h.

## Constructor & Destructor Documentation

## StringAlias()

StringAlias::StringAlias | ( |  | ) |

inline

Definition at line 27 of file StringAlias.h.

{}

## ~StringAlias()

virtual StringAlias::~StringAlias | ( |  | ) |

inline virtual

Definition at line 28 of file StringAlias.h.

{}

## Member Function Documentation

## GetAlias()

const String & StringAlias::GetAlias | ( | const String & | string | ) | const

Definition at line 34 of file StringAlias.cpp.

{
int index = lookup.Integer(string);
if (index < 0)
return string;
else
return aliases[index];
}

## GetAliases()

int StringAlias::GetAliases | ( | StringArray & | list | ) | const

Definition at line 45 of file StringAlias.cpp.

{
if(lookup.Entries() == 0)
{
return 0;
}
int edits = 0;
for(int i = 0; i < list.Length(); i++)
{
int index = lookup.Integer(list[i]);
if(index >= 0)
{
list[i] = aliases[index];
edits++;
}
}
return edits;
}

## ReadFromFile() [1/2]

bool StringAlias::ReadFromFile | ( | const char * | filename | ) |

Definition at line 66 of file StringAlias.cpp.

{
IFILE input = ifopen(filename, "rt");
if (input == NULL)
return false;
ReadFromFile(input);
ifclose(input);
return true;
}
ifopen
IFILE ifopen(const char *filename, const char *mode, InputFile::ifileCompression compressionMode=InputFile::DEFAULT)
Open a file with the specified name and mode, using a filename of "-" to indicate stdin/stdout.
Definition InputFile.h:562
ifclose
int ifclose(IFILE &file)
Close the file.
Definition InputFile.h:580
IFILE
InputFile * IFILE
Define IFILE as a pointer to an InputFile object.
Definition InputFile.h:551

## ReadFromFile() [2/2]

bool StringAlias::ReadFromFile | ( | IFILE & | input | ) |

Definition at line 80 of file StringAlias.cpp.

{
StringArray lines, tokens;
lines.Read(input);
for (int j = 0; j < lines.Length(); j++)
{
tokens.ReplaceTokens(lines[j]);
if (tokens.Length() != 2) continue;
SetAlias(tokens[0], tokens[1]);
}
return true;
}

## SetAlias()

void StringAlias::SetAlias | ( | String & | string,
|  | String & | alias )

Definition at line 21 of file StringAlias.cpp.

{
int index = lookup.Integer(string);
if (index < 0)
{
aliases.Push(alias);
lookup.SetInteger(string, aliases.Length() - 1);
}
else
aliases[index] = alias;
}

The documentation for this class was generated from the following files:

- general/StringAlias.h
- general/StringAlias.cpp