fix warnings
unwrap some ifs
This commit is contained in:
+182
-178
@@ -266,73 +266,75 @@ LPTSTR _tagXMLNode::LoadAttributes( LPCTSTR pszAttrs , LPPARSEINFO pi /*= &piDef
|
|||||||
|
|
||||||
while( xml && *xml )
|
while( xml && *xml )
|
||||||
{
|
{
|
||||||
if( xml = _tcsskip( xml ) )
|
xml = _tcsskip( xml );
|
||||||
|
if( !xml )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// close tag
|
||||||
|
if( *xml == chXMLTagClose || *xml == chXMLTagPre )
|
||||||
|
// wel-formed tag
|
||||||
|
return xml;
|
||||||
|
|
||||||
|
// XML Attr Name
|
||||||
|
TCHAR* pEnd = _tcspbrk( xml, " =" );
|
||||||
|
if( pEnd == NULL )
|
||||||
{
|
{
|
||||||
// close tag
|
// error
|
||||||
if( *xml == chXMLTagClose || *xml == chXMLTagPre )
|
if( pi->erorr_occur == false )
|
||||||
// wel-formed tag
|
|
||||||
return xml;
|
|
||||||
|
|
||||||
// XML Attr Name
|
|
||||||
TCHAR* pEnd = _tcspbrk( xml, " =" );
|
|
||||||
if( pEnd == NULL )
|
|
||||||
{
|
{
|
||||||
// error
|
pi->erorr_occur = true;
|
||||||
if( pi->erorr_occur == false )
|
pi->error_pointer = xml;
|
||||||
{
|
pi->error_code = PIE_ATTR_NO_VALUE;
|
||||||
pi->erorr_occur = true;
|
pi->error_string.Format( ("<%s> attribute has error "), name );
|
||||||
pi->error_pointer = xml;
|
}
|
||||||
pi->error_code = PIE_ATTR_NO_VALUE;
|
return NULL;
|
||||||
pi->error_string.Format( ("<%s> attribute has error "), name );
|
}
|
||||||
}
|
|
||||||
return NULL;
|
LPXAttr attr = new XAttr;
|
||||||
|
attr->parent = this;
|
||||||
|
|
||||||
|
// XML Attr Name
|
||||||
|
_SetString( xml, pEnd, &attr->name );
|
||||||
|
|
||||||
|
// add new attribute
|
||||||
|
attrs.push_back( attr );
|
||||||
|
xml = pEnd;
|
||||||
|
|
||||||
|
// XML Attr Value
|
||||||
|
xml = _tcsskip( xml );
|
||||||
|
if( !xml )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//if( xml = _tcschr( xml, '=' ) )
|
||||||
|
if( *xml == '=' )
|
||||||
|
{
|
||||||
|
xml = _tcsskip( ++xml );
|
||||||
|
if( !xml )
|
||||||
|
continue;
|
||||||
|
// if " or '
|
||||||
|
// or none quote
|
||||||
|
int quote = *xml;
|
||||||
|
if( quote == '"' || quote == '\'' )
|
||||||
|
pEnd = _tcsechr( ++xml, quote, chXMLEscape );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//attr= value>
|
||||||
|
// none quote mode
|
||||||
|
//pEnd = _tcsechr( xml, ' ', '\\' );
|
||||||
|
pEnd = _tcsepbrk( xml, (" >"), chXMLEscape );
|
||||||
}
|
}
|
||||||
|
|
||||||
LPXAttr attr = new XAttr;
|
bool trim = pi->trim_value;
|
||||||
attr->parent = this;
|
TCHAR escape = pi->escape_value;
|
||||||
|
//_SetString( xml, pEnd, &attr->value, trim, chXMLEscape );
|
||||||
// XML Attr Name
|
_SetString( xml, pEnd, &attr->value, trim, escape );
|
||||||
_SetString( xml, pEnd, &attr->name );
|
|
||||||
|
|
||||||
// add new attribute
|
|
||||||
attrs.push_back( attr );
|
|
||||||
xml = pEnd;
|
xml = pEnd;
|
||||||
|
// ATTRVALUE
|
||||||
|
if( pi->entity_value && pi->entitys )
|
||||||
|
attr->value = pi->entitys->Ref2Entity(attr->value);
|
||||||
|
|
||||||
// XML Attr Value
|
if( quote == '"' || quote == '\'' )
|
||||||
if( xml = _tcsskip( xml ) )
|
xml++;
|
||||||
{
|
|
||||||
//if( xml = _tcschr( xml, '=' ) )
|
|
||||||
if( *xml == '=' )
|
|
||||||
{
|
|
||||||
if( xml = _tcsskip( ++xml ) )
|
|
||||||
{
|
|
||||||
// if " or '
|
|
||||||
// or none quote
|
|
||||||
int quote = *xml;
|
|
||||||
if( quote == '"' || quote == '\'' )
|
|
||||||
pEnd = _tcsechr( ++xml, quote, chXMLEscape );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//attr= value>
|
|
||||||
// none quote mode
|
|
||||||
//pEnd = _tcsechr( xml, ' ', '\\' );
|
|
||||||
pEnd = _tcsepbrk( xml, (" >"), chXMLEscape );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool trim = pi->trim_value;
|
|
||||||
TCHAR escape = pi->escape_value;
|
|
||||||
//_SetString( xml, pEnd, &attr->value, trim, chXMLEscape );
|
|
||||||
_SetString( xml, pEnd, &attr->value, trim, escape );
|
|
||||||
xml = pEnd;
|
|
||||||
// ATTRVALUE
|
|
||||||
if( pi->entity_value && pi->entitys )
|
|
||||||
attr->value = pi->entitys->Ref2Entity(attr->value);
|
|
||||||
|
|
||||||
if( quote == '"' || quote == '\'' )
|
|
||||||
xml++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,39 +378,95 @@ LPTSTR _tagXMLNode::Load( LPCTSTR pszXml, LPPARSEINFO pi /*= &piDefault*/ )
|
|||||||
_SetString( xml, pTagEnd, &name );
|
_SetString( xml, pTagEnd, &name );
|
||||||
xml = pTagEnd;
|
xml = pTagEnd;
|
||||||
// Generate XML Attributte List
|
// Generate XML Attributte List
|
||||||
if( xml = LoadAttributes( xml, pi ) )
|
xml = LoadAttributes( xml, pi );
|
||||||
|
if( xml == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// alone tag <TAG ... />
|
||||||
|
if( *xml == chXMLTagPre )
|
||||||
{
|
{
|
||||||
// alone tag <TAG ... />
|
xml++;
|
||||||
if( *xml == chXMLTagPre )
|
if( *xml == chXMLTagClose )
|
||||||
|
// wel-formed tag
|
||||||
|
return ++xml;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
xml++;
|
// error: <TAG ... / >
|
||||||
if( *xml == chXMLTagClose )
|
if( pi->erorr_occur == false )
|
||||||
// wel-formed tag
|
{
|
||||||
return ++xml;
|
pi->erorr_occur = true;
|
||||||
else
|
pi->error_pointer = xml;
|
||||||
|
pi->error_code = PIE_ALONE_NOT_CLOSED;
|
||||||
|
pi->error_string = ("Element must be closed.");
|
||||||
|
}
|
||||||
|
// not wel-formed tag
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// open/close tag <TAG ..> ... </TAG>
|
||||||
|
// ^- current pointer
|
||||||
|
{
|
||||||
|
// text value°¡ ¾øÀ¸¸�E³Öµµ·ÏÇÑ´Ù.
|
||||||
|
//if( this->value.IsEmpty() || this->value == ("") )
|
||||||
|
if( XIsEmptyString( value ) )
|
||||||
|
{
|
||||||
|
// Text Value
|
||||||
|
TCHAR* pEnd = _tcsechr( ++xml, chXMLTagOpen, chXMLEscape );
|
||||||
|
if( pEnd == NULL )
|
||||||
{
|
{
|
||||||
// error: <TAG ... / >
|
|
||||||
if( pi->erorr_occur == false )
|
if( pi->erorr_occur == false )
|
||||||
{
|
{
|
||||||
pi->erorr_occur = true;
|
pi->erorr_occur = true;
|
||||||
pi->error_pointer = xml;
|
pi->error_pointer = xml;
|
||||||
pi->error_code = PIE_ALONE_NOT_CLOSED;
|
pi->error_code = PIE_NOT_CLOSED;
|
||||||
pi->error_string = ("Element must be closed.");
|
pi->error_string.Format(("%s must be closed with </%s>"), name );
|
||||||
}
|
}
|
||||||
// not wel-formed tag
|
// error cos not exist CloseTag </TAG>
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool trim = pi->trim_value;
|
||||||
|
TCHAR escape = pi->escape_value;
|
||||||
|
//_SetString( xml, pEnd, &value, trim, chXMLEscape );
|
||||||
|
_SetString( xml, pEnd, &value, trim, escape );
|
||||||
|
|
||||||
|
xml = pEnd;
|
||||||
|
// TEXTVALUE reference
|
||||||
|
if( pi->entity_value && pi->entitys )
|
||||||
|
value = pi->entitys->Ref2Entity(value);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
// open/close tag <TAG ..> ... </TAG>
|
// generate child nodes
|
||||||
// ^- current pointer
|
while( xml && *xml )
|
||||||
{
|
{
|
||||||
// text value가 없으면 넣도록한다.
|
LPXNode node = new XNode;
|
||||||
//if( this->value.IsEmpty() || this->value == ("") )
|
node->parent = this;
|
||||||
if( XIsEmptyString( value ) )
|
|
||||||
|
xml = node->Load( xml,pi );
|
||||||
|
if( node->name.IsEmpty() == FALSE )
|
||||||
{
|
{
|
||||||
// Text Value
|
childs.push_back( node );
|
||||||
TCHAR* pEnd = _tcsechr( ++xml, chXMLTagOpen, chXMLEscape );
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete node;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open/close tag <TAG ..> ... </TAG>
|
||||||
|
// ^- current pointer
|
||||||
|
// CloseTag case
|
||||||
|
if( xml && *xml && *(xml+1) && *xml == chXMLTagOpen && *(xml+1) == chXMLTagPre )
|
||||||
|
{
|
||||||
|
// </Close>
|
||||||
|
xml+=2; // C
|
||||||
|
|
||||||
|
xml = _tcsskip( xml );
|
||||||
|
if( xml == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
CString closename;
|
||||||
|
TCHAR* pEnd = _tcspbrk( xml, " >" );
|
||||||
if( pEnd == NULL )
|
if( pEnd == NULL )
|
||||||
{
|
{
|
||||||
if( pi->erorr_occur == false )
|
if( pi->erorr_occur == false )
|
||||||
@@ -416,119 +474,65 @@ LPTSTR _tagXMLNode::Load( LPCTSTR pszXml, LPPARSEINFO pi /*= &piDefault*/ )
|
|||||||
pi->erorr_occur = true;
|
pi->erorr_occur = true;
|
||||||
pi->error_pointer = xml;
|
pi->error_pointer = xml;
|
||||||
pi->error_code = PIE_NOT_CLOSED;
|
pi->error_code = PIE_NOT_CLOSED;
|
||||||
pi->error_string.Format(("%s must be closed with </%s>"), name );
|
pi->error_string.Format(("it must be closed with </%s>"), name );
|
||||||
}
|
}
|
||||||
// error cos not exist CloseTag </TAG>
|
// error
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
_SetString( xml, pEnd, &closename );
|
||||||
bool trim = pi->trim_value;
|
if( closename == this->name )
|
||||||
TCHAR escape = pi->escape_value;
|
|
||||||
//_SetString( xml, pEnd, &value, trim, chXMLEscape );
|
|
||||||
_SetString( xml, pEnd, &value, trim, escape );
|
|
||||||
|
|
||||||
xml = pEnd;
|
|
||||||
// TEXTVALUE reference
|
|
||||||
if( pi->entity_value && pi->entitys )
|
|
||||||
value = pi->entitys->Ref2Entity(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate child nodes
|
|
||||||
while( xml && *xml )
|
|
||||||
{
|
|
||||||
LPXNode node = new XNode;
|
|
||||||
node->parent = this;
|
|
||||||
|
|
||||||
xml = node->Load( xml,pi );
|
|
||||||
if( node->name.IsEmpty() == FALSE )
|
|
||||||
{
|
{
|
||||||
childs.push_back( node );
|
// wel-formed open/close
|
||||||
|
xml = pEnd+1;
|
||||||
|
// return '>' or ' ' after pointer
|
||||||
|
return xml;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete node;
|
xml = pEnd+1;
|
||||||
}
|
// not welformed open/close
|
||||||
|
if( pi->erorr_occur == false )
|
||||||
// open/close tag <TAG ..> ... </TAG>
|
|
||||||
// ^- current pointer
|
|
||||||
// CloseTag case
|
|
||||||
if( xml && *xml && *(xml+1) && *xml == chXMLTagOpen && *(xml+1) == chXMLTagPre )
|
|
||||||
{
|
|
||||||
// </Close>
|
|
||||||
xml+=2; // C
|
|
||||||
|
|
||||||
if( xml = _tcsskip( xml ) )
|
|
||||||
{
|
{
|
||||||
CString closename;
|
pi->erorr_occur = true;
|
||||||
TCHAR* pEnd = _tcspbrk( xml, " >" );
|
pi->error_pointer = xml;
|
||||||
if( pEnd == NULL )
|
pi->error_code = PIE_NOT_NESTED;
|
||||||
{
|
pi->error_string.Format(("'<%s> ... </%s>' is not wel-formed."), name, closename );
|
||||||
if( pi->erorr_occur == false )
|
|
||||||
{
|
|
||||||
pi->erorr_occur = true;
|
|
||||||
pi->error_pointer = xml;
|
|
||||||
pi->error_code = PIE_NOT_CLOSED;
|
|
||||||
pi->error_string.Format(("it must be closed with </%s>"), name );
|
|
||||||
}
|
|
||||||
// error
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
_SetString( xml, pEnd, &closename );
|
|
||||||
if( closename == this->name )
|
|
||||||
{
|
|
||||||
// wel-formed open/close
|
|
||||||
xml = pEnd+1;
|
|
||||||
// return '>' or ' ' after pointer
|
|
||||||
return xml;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xml = pEnd+1;
|
|
||||||
// not welformed open/close
|
|
||||||
if( pi->erorr_occur == false )
|
|
||||||
{
|
|
||||||
pi->erorr_occur = true;
|
|
||||||
pi->error_pointer = xml;
|
|
||||||
pi->error_code = PIE_NOT_NESTED;
|
|
||||||
pi->error_string.Format(("'<%s> ... </%s>' is not wel-formed."), name, closename );
|
|
||||||
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
else // Alone child Tag Loaded
|
}
|
||||||
// else 해야하는지 말아야하는지 의심간다.
|
else // Alone child Tag Loaded
|
||||||
|
// else ÇØ¾ßÇÏ´ÂÁ�E¸»¾Æ¾ßÇÏ´ÂÁ�EÀǽɰ£´Ù.
|
||||||
|
{
|
||||||
|
|
||||||
|
//if( xml && this->value.IsEmpty() && *xml !=chXMLTagOpen )
|
||||||
|
if( xml && XIsEmptyString( value ) && *xml !=chXMLTagOpen )
|
||||||
{
|
{
|
||||||
|
// Text Value
|
||||||
//if( xml && this->value.IsEmpty() && *xml !=chXMLTagOpen )
|
TCHAR* pEnd = _tcsechr( xml, chXMLTagOpen, chXMLEscape );
|
||||||
if( xml && XIsEmptyString( value ) && *xml !=chXMLTagOpen )
|
if( pEnd == NULL )
|
||||||
{
|
{
|
||||||
// Text Value
|
// error cos not exist CloseTag </TAG>
|
||||||
TCHAR* pEnd = _tcsechr( xml, chXMLTagOpen, chXMLEscape );
|
if( pi->erorr_occur == false )
|
||||||
if( pEnd == NULL )
|
|
||||||
{
|
{
|
||||||
// error cos not exist CloseTag </TAG>
|
pi->erorr_occur = true;
|
||||||
if( pi->erorr_occur == false )
|
pi->error_pointer = xml;
|
||||||
{
|
pi->error_code = PIE_NOT_CLOSED;
|
||||||
pi->erorr_occur = true;
|
pi->error_string.Format(("it must be closed with </%s>"), name );
|
||||||
pi->error_pointer = xml;
|
|
||||||
pi->error_code = PIE_NOT_CLOSED;
|
|
||||||
pi->error_string.Format(("it must be closed with </%s>"), name );
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
bool trim = pi->trim_value;
|
|
||||||
TCHAR escape = pi->escape_value;
|
|
||||||
//_SetString( xml, pEnd, &value, trim, chXMLEscape );
|
|
||||||
_SetString( xml, pEnd, &value, trim, escape );
|
|
||||||
|
|
||||||
xml = pEnd;
|
|
||||||
//TEXTVALUE
|
|
||||||
if( pi->entity_value && pi->entitys )
|
|
||||||
value = pi->entitys->Ref2Entity(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool trim = pi->trim_value;
|
||||||
|
TCHAR escape = pi->escape_value;
|
||||||
|
//_SetString( xml, pEnd, &value, trim, chXMLEscape );
|
||||||
|
_SetString( xml, pEnd, &value, trim, escape );
|
||||||
|
|
||||||
|
xml = pEnd;
|
||||||
|
//TEXTVALUE
|
||||||
|
if( pi->entity_value && pi->entitys )
|
||||||
|
value = pi->entitys->Ref2Entity(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user