More constness in Xml

This commit is contained in:
Ivan Skytte Jørgensen
2016-05-29 18:18:26 +02:00
parent ccc64cb432
commit a757e3d1cb
2 changed files with 17 additions and 6 deletions

@ -794,7 +794,7 @@ char *Xml::getMetaContentPointer( const char *field, int32_t fieldLen, const cha
// generation purposes in Summary class
// . "name" is usually "name" or "http-equiv"
// . if "convertHtmlEntities" is true we turn < into &lt; and > in &gt;
int32_t Xml::getMetaContent( char *buf, int32_t bufLen, char *field, int32_t fieldLen, char *name,
int32_t Xml::getMetaContent( char *buf, int32_t bufLen, const char *field, int32_t fieldLen, const char *name,
int32_t startNode, int32_t *matchedNode ) {
// return 0 length if no buffer space
if ( bufLen <= 0 ) return 0;
@ -1067,7 +1067,7 @@ int32_t Xml::isRSSFeed ( ) {
return 0;
}
char *Xml::getRSSTitle ( int32_t *titleLen , bool *isHtmlEncoded ) const {
char *Xml::getRSSTitle ( int32_t *titleLen , bool *isHtmlEncoded ) {
// assume it is html encoded (i.e. <'s are encoded as &lt;'s)
*isHtmlEncoded = true;
// . extract the RSS/Atom title
@ -1088,6 +1088,10 @@ char *Xml::getRSSTitle ( int32_t *titleLen , bool *isHtmlEncoded ) const {
return title;
}
const char *Xml::getRSSTitle ( int32_t *titleLen , bool *isHtmlEncoded ) const {
return const_cast<Xml*>(this)->getRSSTitle(titleLen,isHtmlEncoded);
}
char *Xml::getRSSDescription ( int32_t *descLen , bool *isHtmlEncoded ) {
// assume it is html encoded (i.e. <'s are encoded as &lt;'s)
*isHtmlEncoded = true;

15
Xml.h

@ -72,6 +72,9 @@ public:
char *getNode( int32_t n ) {
return m_nodes[n].m_node;
}
const char *getNode( int32_t n ) const {
return m_nodes[n].m_node;
}
int32_t getNodeLen( int32_t n ) {
return m_nodes[n].m_nodeLen;
@ -105,11 +108,14 @@ public:
bool skipLeadingSpaces = true ) const;
// like above routines but we search all nodes
int32_t getLong( char *tagName, int32_t defaultLong = 0 ) {
int32_t getLong( const char *tagName, int32_t defaultLong = 0 ) {
return getLong( 0, m_numNodes, tagName, defaultLong );
}
char *getString( const char *tagName, int32_t *len, bool skipLeadingSpaces = true ) const {
char *getString( const char *tagName, int32_t *len, bool skipLeadingSpaces = true ) {
return getString( 0, m_numNodes, tagName, len, skipLeadingSpaces );
}
const char *getString( const char *tagName, int32_t *len, bool skipLeadingSpaces = true ) const {
return getString( 0, m_numNodes, tagName, len, skipLeadingSpaces );
}
@ -137,7 +143,7 @@ public:
// . field can be stuff like "summary","description","keywords",...
// . use "http-equiv" for "name" for meta redirect tags
// . if "convertHtmlEntites" is true we change < to &lt; and > to &gt;
int32_t getMetaContent( char *buf, int32_t bufLen, char *field, int32_t fieldLen, char *name = "name",
int32_t getMetaContent( char *buf, int32_t bufLen, const char *field, int32_t fieldLen, const char *name = "name",
int32_t startNode = 0, int32_t *matchedNode = NULL );
// just get a pointer to it
@ -159,7 +165,8 @@ public:
int32_t isRSSFeed();
char *getRSSTitle( int32_t *titleLen, bool *isHtmlEncoded ) const;
char *getRSSTitle( int32_t *titleLen, bool *isHtmlEncoded );
const char *getRSSTitle( int32_t *titleLen, bool *isHtmlEncoded ) const;
char *getRSSDescription( int32_t *titleLen, bool *isHtmlEncoded );
// . used by getValueAsBool/Long/String()