OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ossimXmlAttribute Class Reference

#include <ossimXmlAttribute.h>

Inheritance diagram for ossimXmlAttribute:
ossimObject ossimErrorStatusInterface ossimReferenced

Public Member Functions

 ossimXmlAttribute (ossimString &spec)
 
 ossimXmlAttribute ()
 
 ossimXmlAttribute (const ossimXmlAttribute &src)
 
 ossimXmlAttribute (const ossimString &name, const ossimString &value)
 
virtual ossimObjectdup () const
 
 ~ossimXmlAttribute ()
 
bool read (std::istream &in)
 
const ossimStringgetName () const
 
const ossimStringgetValue () const
 
void setNameValue (const ossimString &name, const ossimString &value)
 
void setName (const ossimString &name)
 
void setValue (const ossimString &value)
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 

Protected Member Functions

bool readName (std::istream &in)
 
bool readValue (std::istream &in)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimString theName
 
ossimString theValue
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Friends

OSSIMDLLEXPORT friend std::ostream & operator<< (std::ostream &os, const ossimXmlAttribute *xml_attr)
 

Detailed Description

Definition at line 21 of file ossimXmlAttribute.h.

Constructor & Destructor Documentation

◆ ossimXmlAttribute() [1/4]

ossimXmlAttribute::ossimXmlAttribute ( ossimString spec)

Definition at line 39 of file ossimXmlAttribute.cpp.

References read().

40 {
41  std::stringstream in(spec);
42 
43  read(in);
44 }
bool read(std::istream &in)
std::basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
Definition: ossimIosFwd.h:38

◆ ossimXmlAttribute() [2/4]

ossimXmlAttribute::ossimXmlAttribute ( )

Definition at line 116 of file ossimXmlAttribute.cpp.

117 {
118 }

◆ ossimXmlAttribute() [3/4]

ossimXmlAttribute::ossimXmlAttribute ( const ossimXmlAttribute src)

Definition at line 46 of file ossimXmlAttribute.cpp.

47  :theName(src.theName),
48  theValue(src.theValue)
49 {
50 }

◆ ossimXmlAttribute() [4/4]

ossimXmlAttribute::ossimXmlAttribute ( const ossimString name,
const ossimString value 
)

Definition at line 120 of file ossimXmlAttribute.cpp.

References setNameValue().

122 {
123  setNameValue(name, value);
124 }
void setNameValue(const ossimString &name, const ossimString &value)

◆ ~ossimXmlAttribute()

ossimXmlAttribute::~ossimXmlAttribute ( )

Definition at line 112 of file ossimXmlAttribute.cpp.

113 {
114 }

Member Function Documentation

◆ dup()

virtual ossimObject* ossimXmlAttribute::dup ( ) const
inlinevirtual

Reimplemented from ossimObject.

Definition at line 30 of file ossimXmlAttribute.h.

31  {
32  return new ossimXmlAttribute(*this);
33  }

◆ getName()

const ossimString & ossimXmlAttribute::getName ( ) const

Definition at line 126 of file ossimXmlAttribute.cpp.

References theName.

127 {
128  return theName;
129 }

◆ getValue()

const ossimString & ossimXmlAttribute::getValue ( ) const

◆ read()

bool ossimXmlAttribute::read ( std::istream &  in)

Definition at line 52 of file ossimXmlAttribute.cpp.

Referenced by ossimXmlAttribute().

53 {
54  xmlskipws(in);
55  if(in.fail()) return false;
56  if(readName(in))
57  {
58  xmlskipws(in);
59  if((in.peek() != '=')||
60  (in.fail()))
61  {
63  return false;
64  }
65  in.ignore(1);
66  if(readValue(in))
67  {
68  return true;
69  }
70  else
71  {
73  return false;
74  }
75  }
76  return false;
77 
78 #if 0
79  //
80  // Pull out name:
81  //
82  theName = spec.before('=');
83  theName = theName.trim();
84  if (theName.empty())
85  {
86  ossimNotify(ossimNotifyLevel_FATAL) << "ossimXmlAttribute::ossimXmlAttribute \n"
87  << "Bad attribute format encountered near:\n\""<< spec<<"\"\n"
88  << "Parsing aborted...\n";
90 
91  return;
92  }
93  spec = spec.after('=');
94 
95  //***
96  // Read value:
97  //***
98  char quote_char = spec[0];
99  spec = spec.after(quote_char); // after first quote
100  theValue = spec.before(quote_char); // before second quote
101 
102  //
103  // Reposition attribute specification to the start of next attribute or end
104  // of tag:
105  //
106  spec = spec.after(quote_char); // after second quote
107  ossimString next_entry ("-?[+0-9A-Za-z<>]+");
108  spec = spec.fromRegExp(next_entry.c_str());
109 #endif
110 }
ossimString before(const ossimString &str, std::string::size_type pos=0) const
METHOD: before(str, pos) Returns string beginning at pos and ending one before the token str If strin...
bool readValue(std::istream &in)
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
bool empty() const
Definition: ossimString.h:411
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool readName(std::istream &in)

◆ readName()

bool ossimXmlAttribute::readName ( std::istream &  in)
protected

Definition at line 161 of file ossimXmlAttribute.cpp.

162 {
163  xmlskipws(in);
164  theName = "";
165  char c = in.peek();
166  while((c != ' ')&&
167  (c != '\n')&&
168  (c != '\r')&&
169  (c != '\t')&&
170  (c != '=')&&
171  (c != '<')&&
172  (c != '/')&&
173  (c != '>')&&
174  (!in.fail()))
175  {
176  theName += (char)in.get();
177  c = in.peek();
178  }
179 
180  return ((!in.fail())&&
181  (theName != ""));
182 }

◆ readValue()

bool ossimXmlAttribute::readValue ( std::istream &  in)
protected

Definition at line 184 of file ossimXmlAttribute.cpp.

185 {
186  xmlskipws(in);
187  if(in.fail()) return false;
188  theValue = "";
189  char c = in.peek();
190  bool done = false;
191  char startQuote = '\0';
192  if((c == '\'')||
193  (c == '"'))
194  {
195  startQuote = c;
196  theValue += in.get();
197  while(!done&&!in.fail())
198  {
199  c = in.peek();
200  if(c==startQuote)
201  {
202  theValue += c;
203  done = true;
204  in.ignore(1);
205  }
206  else if(c == '\n')
207  {
208  done = true;
209  }
210  else
211  {
212  theValue += in.get();
213  }
214  }
215  }
216 
217  bool is_empty = false;
218  std::string::size_type p = 0;
219  //then this could be empty with two qoutes
220  if(theValue.size() == 2 && theValue[p] == startQuote && theValue[p+1] == startQuote)
221  {
222  theValue = "";
223  is_empty = true;
224  }
225  if(theValue != "")
226  {
227  std::string::iterator startIter = theValue.begin();
228  std::string::iterator endIter = theValue.end();
229  --endIter;
230  if(*startIter == startQuote)
231  {
232  ++startIter;
233  }
234  else
235  {
236  return false;
237  setErrorStatus();
238  }
239  if(*endIter != startQuote)
240  {
241  return false;
242  setErrorStatus();
243  }
244  theValue = ossimString(startIter, endIter);
245  }
246  return ((!in.bad())&& (is_empty || theValue !=""));
247 }
std::string::iterator end()
Definition: ossimString.h:423
std::string::size_type size() const
Definition: ossimString.h:405
std::string::iterator begin()
Definition: ossimString.h:420

◆ setName()

void ossimXmlAttribute::setName ( const ossimString name)

Definition at line 143 of file ossimXmlAttribute.cpp.

References theName.

144 {
145  theName = name;
146 }

◆ setNameValue()

void ossimXmlAttribute::setNameValue ( const ossimString name,
const ossimString value 
)

◆ setValue()

void ossimXmlAttribute::setValue ( const ossimString value)

Definition at line 148 of file ossimXmlAttribute.cpp.

References theValue.

Referenced by ossimXmlNode::setAttribute().

149 {
150  theValue = value;
151 }

Friends And Related Function Documentation

◆ operator<<

OSSIMDLLEXPORT friend std::ostream& operator<< ( std::ostream &  os,
const ossimXmlAttribute xml_attr 
)
friend

Definition at line 153 of file ossimXmlAttribute.cpp.

154 {
155  os << " " << xml_attr->theName << "=\"" << xml_attr->theValue << "\"";
156 
157  return os;
158 }

Member Data Documentation

◆ theName

ossimString ossimXmlAttribute::theName
protected

Definition at line 48 of file ossimXmlAttribute.h.

Referenced by getName(), operator<<(), setName(), and setNameValue().

◆ theValue

ossimString ossimXmlAttribute::theValue
protected

Definition at line 49 of file ossimXmlAttribute.h.

Referenced by getValue(), operator<<(), setNameValue(), and setValue().


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