version 1.2, 2003/10/22 14:26:01
|
version 1.3, 2004/06/03 23:22:28
|
|
|
// | // |
// Author: Tony Fiorentino (fiorentino_tony@emc.com) | // Author: Tony Fiorentino (fiorentino_tony@emc.com) |
// | // |
// Modified By: |
// Modified By: Keith Petley (keithp@veritas.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "Attribute.h" | #include "Attribute.h" |
| |
|
PEGASUS_USING_STD; |
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
Attribute::Attribute(const String & attrEntry, const Char16 & delimiter) : |
Attribute::Attribute(const String & attrEntry) |
String(attrEntry), _delimit(delimiter) |
|
{ | { |
|
_tag = attrEntry; |
} | } |
| |
Attribute::~Attribute() | Attribute::~Attribute() |
{ | { |
|
if(_vals.size()) { |
|
_vals.clear(); |
|
} |
} | } |
| |
String |
const Array <String> & |
Attribute::getValue(const String & defaultValue) |
Attribute::getValues() const |
{ |
|
Uint32 idxDelimiter = find(_delimit); |
|
Uint32 idxValue = idxDelimiter + 1; |
|
|
|
if (idxDelimiter != PEG_NOT_FOUND && idxValue < size()) |
|
{ | { |
return subString(idxValue); |
return _vals; |
} | } |
else |
|
|
const String & |
|
Attribute::getTag() const |
{ | { |
return defaultValue; |
return _tag; |
} |
|
} | } |
| |
Boolean |
void |
Attribute::setValue(const String & value) |
Attribute::addValue(const String & value) |
{ | { |
String newAttrEntry; |
_vals.append(value); |
|
} |
Uint32 idx = find(_delimit); |
|
| |
if (idx != PEG_NOT_FOUND) |
PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const Attribute& attr) |
{ | { |
newAttrEntry = subString(0, idx) + value; |
os << attr.getTag(); |
clear(); |
Array <String> vals = attr.getValues(); |
assign(newAttrEntry); |
for(int i = 0; i < vals.size(); i++) { |
return true; |
if(i == 0) { |
|
os << " = "; |
|
} else { |
|
os << " | "; |
} | } |
|
os << vals[i]; |
return false; |
|
} | } |
|
return os; |
Char16 |
|
Attribute::getDelimiter() |
|
{ |
|
return _delimit; |
|
} | } |
|
|
#define PEGASUS_ARRAY_T Attribute | #define PEGASUS_ARRAY_T Attribute |
#include <Pegasus/Common/ArrayImpl.h> | #include <Pegasus/Common/ArrayImpl.h> |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |