44 safe_ptr(T *ptr =
nullptr): ptr(ptr ? ptr : &fake)
48 operator bool()
const {
return true; }
59 const void *
data()
const;
74 std::size_t
indexOf(
const char *needle,
size_t from = 0)
const;
75 std::size_t
indexOf(
const std::string &needle,
size_t from = 0)
const;
77 std::size_t
lastIndexOf(
const char *needle,
size_t from = 0)
const;
78 std::size_t
lastIndexOf(
const std::string &needle,
size_t from = 0)
const;
81 bool startsWith(
const std::string &needle)
const;
83 bool endsWith(
const char *needle)
const;
84 bool endsWith(
const std::string &needle)
const;
87 operator const char *()
const {
return toCString(); }
88 operator double ()
const {
return toDouble(); }
89 operator int ()
const {
return toInt(); }
94 operator size_t ()
const {
return toInt(); }
110 std::string
name()
const;
145 void print(FILE *f,
int level = 0)
const;
190 std::list<LilXmlDocument>
parseChunk(
const char *data,
size_t size);
206 , mSize(value ? strlen(value) : 0)
300 return toString().find_first_of(needle, from);
305 return toString().find_first_of(needle, from);
310 return toString().find_last_of(needle, from);
315 return toString().find_last_of(needle, from);
399 result.push_back(element);
437 inline LilXmlDocument::LilXmlDocument(
XMLEle *root)
442 : mRoot(
std::move(other.mRoot))
447 return mRoot !=
nullptr;
468 FILE *fp = fopen(fileName,
"r");
487 std::list<LilXmlDocument> result;
489 if (nodes !=
nullptr)
491 for (
auto it = nodes; *it; ++it)
const LilXmlValue & value() const
LilXmlAttribute(XMLAtt *a)
~LilXmlDocument()=default
std::unique_ptr< XMLEle, void(*)(XMLEle *)> mRoot
LilXmlElement root() const
Elements getElementsByTagName(const char *tagName) const
Elements getElements() const
LilXmlAttribute addAttribute(const char *name, const char *value)
LilXmlValue context() const
void removeAttribute(const char *name)
std::string tagName() const
LilXmlAttribute getAttribute(const char *name) const
std::list< LilXmlElement > Elements
void setContext(const char *data)
void print(FILE *f, int level=0) const
std::unique_ptr< LilXML, void(*)(LilXML *)> mHandle
const char * errorMessage() const
bool hasErrorMessage() const
std::list< LilXmlDocument > parseChunk(const char *data, size_t size)
LilXmlDocument readFromFile(FILE *file)
char mErrorMessage[MAXRBUF]
IPState toIPState(safe_ptr< bool > ok=nullptr) const
std::size_t indexOf(const char *needle, size_t from=0) const
std::size_t lastIndexOf(const char *needle, size_t from=0) const
std::string toString() const
double toDouble(safe_ptr< bool > ok=nullptr) const
ISState toISState(safe_ptr< bool > ok=nullptr) const
IPerm toIPerm(safe_ptr< bool > ok=nullptr) const
LilXmlValue(const char *value)
int toInt(safe_ptr< bool > ok=nullptr) const
double toDoubleSexa(safe_ptr< bool > ok=nullptr) const
ISRule toISRule(safe_ptr< bool > ok=nullptr) const
const char * toCString() const
bool endsWith(const char *needle) const
bool startsWith(const char *needle) const
const void * data() const
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
IPerm
Permission hint, with respect to client.
ISRule
Switch vector rule hint.
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
Implementations for common driver routines.
int crackIPerm(const char *str, IPerm *ip)
Extract property permission state (RW, RO, WO) from the supplied string.
int crackIPState(const char *str, IPState *ip)
Extract property state (Idle, OK, Busy, Alert) from the supplied string.
int crackISRule(const char *str, ISRule *ip)
Extract switch rule (OneOfMany, OnlyOne..etc) from the supplied string.
int crackISState(const char *str, ISState *ip)
Extract switch state (On or Off) from the supplied string.
Interface to the reference INDI C API device implementation on the Device Driver side.
XMLAtt * findXMLAtt(XMLEle *ep, const char *name)
Find an XML attribute within an XML element.
LilXML * newLilXML()
Create a new lilxml parser.
XMLEle ** parseXMLChunk(LilXML *lp, char *buf, int size, char ynot[])
Process an XML chunk.
XMLAtt * addXMLAtt(XMLEle *ep, const char *name, const char *valu)
Add an XML attribute to an existing XML element.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.
void editXMLEle(XMLEle *ep, const char *pcdata)
set the pcdata of the given element
char * tagXMLEle(XMLEle *ep)
Return the tag of an XML element.
void rmXMLAtt(XMLEle *ep, const char *name)
Remove an XML attribute from an XML element.
void prXMLEle(FILE *fp, XMLEle *ep, int level)
Print an XML element.
XMLEle * readXMLFile(FILE *fp, LilXML *lp, char ynot[])
Handy wrapper to read one xml file.
XMLEle * nextXMLEle(XMLEle *ep, int init)
Iterate an XML element for a list of nesetd XML elements.
char * nameXMLAtt(XMLAtt *ap)
Return the name of an XML attribute.
void delXMLEle(XMLEle *ep)
delXMLEle Delete XML element.
void delLilXML(LilXML *lp)
Delete a lilxml parser.
int pcdatalenXMLEle(XMLEle *ep)
Return the number of characters in pcdata in an XML element.
char * valuXMLAtt(XMLAtt *ap)
Return the value of an XML attribute.
A little DOM-style library to handle parsing and processing an XML file.
Namespace to encapsulate INDI client, drivers, and mediator classes.