53 #define NCBI_USE_ERRCODE_X Serial_Parsers
96 if (
Lexer().HaveComments()) {
113 module->SetSourceLine(
Lexer().CurrentLine());
124 catch (exception& e) {
129 #if defined(NCBI_DTDPARSER_TRACE)
140 modules->AddModule(module);
149 bool conditional_ignore =
false;
150 int conditional_level = 0;
172 conditional_ignore =
true;
178 if (conditional_level == 0) {
179 ParseError(
"Incorrect format: unexpected end of conditional section",
189 if (conditional_ignore) {
192 conditional_ignore =
false;
224 catch (exception& e) {
234 list<string>::const_iterator
i;
262 if (
Lexer().TokenStarted()) {
329 ParseError(
"incorrect format",
"element category");
368 for (skip =
false; ;) {
383 if(id_name.empty()) {
397 switch (symbol =
NextToken().GetSymbol()) {
401 id_name +=
"__emb#__";
417 if(id_name.empty()) {
443 ParseError(
"Unexpected element contents",
"");
445 const list<string>& content = node.
GetContent();
447 if (find(content.begin(), content.end(), id_name) != content.end()) {
452 list<string>::const_iterator
i;
454 for (
i = content.begin();
i != content.end(); ++
i) {
470 if (occ_candidate != occ_elem) {
475 if (occ_candidate != occ_elem) {
491 if (separator ==
',' || separator ==
'|') {
492 node.
SetType(separator ==
',' ?
500 if (separator ==
',' || separator ==
'|') {
501 node.
SetType(separator ==
',' ?
522 switch (symbol =
NextToken().GetSymbol()) {
548 new_var =
"AnyContent";
551 list<string>::const_iterator
i;
555 for (
i = refs.begin();
i != refs.end(); ++
i) {
558 refname =
r->second.GetName();
560 if (refname.empty()) {
563 if (!refname.empty()) {
564 string::size_type name = refname.find(
':');
565 name = (name != string::npos && (name+1) < refname.size()) ? (name+1) : 0;
566 new_var += (char)
toupper((
unsigned char) refname[name]);
568 if (new_var.size() > 8) {
588 for (list<string>::const_iterator
i= refs.begin();
i != refs.end(); ++
i) {
595 find(refs.begin(),refs.end(),testName) == refs.end() &&
596 find(fixed.begin(),fixed.end(),testName) == fixed.end();
598 const list<string>& refrefs = refNode.
GetContent();
599 list<string>::const_iterator
r= refrefs.begin();
600 for (; allowed &&
r != refrefs.end(); ++
r) {
602 allowed =
t != testName;
606 fixed.push_back(testName);
688 string msg(
"Undefined entity: ");
698 if (!
file.Exists()) {
699 ParseError(
"file not found", fullname.c_str());
703 ParseError(
"cannot access file",fullname.c_str());
707 lexer_name = fullname;
775 const string& id_name)
900 i->second.GetName().empty() &&
913 i->second.HasAttributes());
915 if (generate && !
i->second.IsEmbedded())
917 if (name_space !=
"*" &&
918 i->second.GetNamespaceName() != name_space) {
921 string qname =
i->second.GetName() +
i->second.GetNamespaceName();
941 bool fromInside,
bool ignoreAttrib)
954 bool fromInside,
bool ignoreAttrib)
961 if (refs.size() == 1) {
962 string refName = refs.front();
992 bool ref_to_parent =
false;
997 ref_to_parent = ref =
1003 keep_global = (cont && uniseq && (attrib ||
1007 keep_global = keep_global || ref;
1059 base =
b->second.GetName();
1062 base =
b->second.GetTypeName();
1068 type->SetIsAlias(
true);
1069 type->SetIsTypeAlias(
true);
1124 ParseError(
"Unknown WSDL element type",
"element");
1141 type->SetNillable();
1151 string refname(node.
GetName());
1152 refname.insert(0,
"E");
1155 container->SetSourceLine(
type->GetSourceLine());
1156 member->SetOptional();
1158 member->SetNoPrefix();
1159 container->AddMember(member);
1165 if (!embtype.empty()) {
1180 string(
"Element: ") + node.
GetName() +
1184 ": failed to define default value");
1230 tmp.SetNillable(
false);
1232 if (!ignoreAttrib) {
1237 type->SetNillable();
1239 member->SetNillable();
1240 member->SetNoPrefix();
1241 container->AddMember(member);
1251 if (!ignoreAttrib) {
1254 const list<string>& refs = node.
GetContent();
1255 for (list<string>::const_iterator
i= refs.begin();
i != refs.end(); ++
i) {
1259 smember->SetNotag();
1260 smember->SetNoPrefix();
1261 container->AddMember(smember);
1265 if (refNode.
GetName().empty()) {
1278 bool stdtype =
type->IsStdType();
1281 bool optional =
false, uniseq =
false, uniseq2 =
false, refseq =
false;
1290 if (uniseq || (optional && refseq)) {
1292 string refname(refNode.
GetName());
1293 if (uniseq2 || (optional && refseq)) {
1294 refname.insert(0,
"E");
1298 type_container->SetSourceLine(
type->GetSourceLine());
1300 member->SetOptional();
1303 member->SetNoPrefix();
1304 type_container->AddMember(member);
1307 else if (uniseq2 && setnil) {
1318 type.reset(uniType);
1325 member->SetOptional();
1331 member->SetDefault(
Value(refNode));
1334 member->SetNillable();
1336 member->SetNoPrefix();
1343 container->AddMember(member);
1362 int line =
type->GetSourceLine();
1364 type->SetSourceLine( line );
1370 member->SetOptional();
1374 member->SetDefault(
Value(node));
1378 member->SetNillable();
1380 member->SetNoPrefix();
1382 member->SetSimpleType();
1384 container->AddMember(member);
1397 member->SetNoPrefix();
1398 member->SetAttlist();
1400 container->AddMember(member);
1408 bool has_nsq =
false;
1409 for (list<DTDAttribute>::const_iterator
i= att.begin();
1410 i != att.end(); ++
i) {
1413 string defValue(
i->GetValue());
1414 if (!defValue.empty()) {
1418 member->SetOptional();
1420 member->SetNoPrefix();
1421 member->Comments() =
i->GetComments();
1425 container->AddMember(member);
1429 container->SetNsQualified(
true);
1441 ParseError(
"Unknown attribute",
"attribute");
1444 ParseError(
"Unknown attribute",
"attribute");
1487 const string& defvalue)
1492 ParseError(
"Unknown attribute",
"attribute");
1495 ParseError(
"Unknown attribute",
"attribute");
1537 list<string>::const_iterator
i;
1538 for (
i = attEnums.begin();
i != attEnums.end(); ++
i, ++v) {
1552 const list<string>& enums = node.
GetContent();
1553 list<string>::const_iterator
i;
1554 for (
i = enums.begin();
i != enums.end(); ++
i, ++v) {
1565 if (comments->
Empty()) {
1575 #if defined(NCBI_DTDPARSER_TRACE)
1576 void DTDParser::PrintDocumentTree(
void)
1580 cout <<
" === Elements ===" << endl;
1590 PrintDocumentNode(
i->first,
i->second);
1593 bool started =
false;
1598 cout <<
" === Embedded elements ===" << endl;
1601 PrintDocumentNode(
i->first,
i->second);
1613 cout <<
" === REFERENCED simpletype elements ===" << endl;
1616 PrintDocumentNode(
i->first,
i->second);
1629 cout <<
" === UNREFERENCED simpletype elements ===" << endl;
1632 PrintDocumentNode(
i->first,
i->second);
1638 void DTDParser::PrintEntities(
void)
1641 cout <<
" === Entities ===" << endl;
1644 cout <<
i->first <<
" = \"" <<
i->second.GetData() <<
"\"" << endl << endl;
1649 void DTDParser::PrintDocumentNode(
const string& name,
const DTDElement& node)
1651 cout << name <<
": ";
1693 cout <<
", default=";
1699 cout <<
"form: " << (node.
IsQualified() ?
"qualified" :
"unqualified") << endl;
1703 cout <<
" === Comments ===" << endl;
1707 cout <<
" === AttribComments ===" << endl;
1711 PrintNodeAttributes(node);
1713 const list<string>& refs = node.
GetContent();
1714 if (!refs.empty()) {
1715 cout <<
" === Contents ===" << endl;
1716 for (list<string>::const_iterator ir= refs.begin();
1717 ir != refs.end(); ++ir) {
1736 void DTDParser::PrintNodeAttributes(
const DTDElement& node)
1739 cout <<
" === Attributes ===" << endl;
1740 for (list<DTDAttribute>::const_iterator
i= att.begin();
1741 i != att.end(); ++
i) {
1742 PrintAttribute( *
i);
1774 if (!enumV.empty()) {
1776 for (list<string>::const_iterator ie= enumV.begin();
1777 ie != enumV.end(); ++ie) {
1778 if (ie != enumV.begin()) {
1794 cout <<
"\"" << attrib.
GetValue() <<
"\"";
1797 cout <<
"form:" << (attrib.
IsQualified() ?
"qualified" :
"unqualified") << endl;
1803 cout <<
" === Comments ===" << endl;
void SetParser(AbstractParser *parser)
void FlushCommentsTo(CComments &comments)
const AbstractToken & NextToken(void) const
void ConsumeSymbol(char symbol)
AbstractLexer & Lexer(void)
void SetLexer(AbstractLexer *lexer)
virtual void ParseError(const char *error, const char *expected, const AbstractToken &token)
void CopyComments(CComments &comments)
virtual string GetLocation(void)
string GetText(void) const
void AddDefinition(const string &name, const AutoPtr< CDataType > &type)
void SetSourceLine(int line)
void SetSourceLine(int line)
TValue & AddValue(const string &name, TEnumValueType value)
virtual bool IsInteger(void) const
void SetNoPrefix(bool noprefix)
void SetNonEmpty(bool nonEmpty)
void SetWsdlType(EType type)
int GetEnumValueId(const string &value) const
const string & GetNamespaceName(void) const
const string & GetValue(void) const
EType GetType(void) const
const CComments & GetComments(void) const
void AddEnumValue(const string &value, int line, int id=0)
bool IsQualified(void) const
void SetValueType(EValueType valueType)
int GetEnumValueSourceLine(const string &value) const
const list< string > & GetEnumValues(void) const
void SetValue(const string &value)
const string & GetName(void) const
int GetSourceLine(void) const
void SetSourceLine(int line)
CComments & Comments(void)
EValueType GetValueType(void) const
void SetName(const string &name)
const string & GetTypeName(void) const
void AddContent(const string &ref_name)
bool IsGlobalGroup(void) const
void SetTypeIfUnknown(EType type)
bool IsEmbedded(void) const
const CComments & GetAttribComments(void) const
const list< CMemberFacet > & GetRestrictions(void) const
void SetSourceLine(int line)
void SetOccurrence(const string &ref_name, EOccurrence occ)
list< DTDAttribute > & GetNonconstAttributes(void)
const string & GetDefault(void) const
@ eWsdlUnsupportedEndpoint
bool IsNillable(void) const
bool IsGlobalType(void) const
EOccurrence GetOccurrence(const string &ref_name) const
CComments & AttribComments(void)
bool IsQualified(void) const
CComments & Comments(void)
void SetNamed(bool named=true)
bool HasAttributes(void) const
const CComments & GetComments(void) const
const list< DTDAttribute > & GetAttributes(void) const
const string & GetName(void) const
const string & GetNamespaceName(void) const
int GetSourceLine(void) const
const list< string > & GetContent(void) const
bool RemoveContent(const string &ref_name)
void AddAttribute(DTDAttribute &attrib)
bool IsReferenced(void) const
string CreateEmbeddedName(int depth) const
void SetEmbedded(bool set=true)
EType GetType(void) const
void SetData(const string &data)
void SetName(const string &name)
void ParseAttributesContent(DTDElement &node)
CDataValue * x_AttribValue(const DTDAttribute &att, const string &value)
CDataType * TypesBlock(CDataMemberContainerType *containerType, const DTDElement &node, bool ignoreAttrib=false)
void GenerateDataTree(CDataTypeModule &module, const string &name_space)
void ConsumeAttributeContent(DTDElement &node, const string &id_name)
AutoPtr< CDataValue > x_Value(const DTDElement &node)
CDataType * CompositeNode(const DTDElement &node, DTDElement::EOccurrence occ)
void BeginElementContent(void)
CDataType * NillableBlock(const DTDElement &node, bool ignoreAttrib=false)
void AddAttributes(AutoPtr< CDataMemberContainerType > &container, const DTDElement &node)
string CreateEmbeddedName(const DTDElement &node, int depth) const
virtual void EndCommentBlock(void) override
void BeginEntityContent(void)
map< string, DTDEntity > m_MapEntity
void BeginAttributesContent(void)
void FixEmbeddedNames(DTDElement &node)
CDataType * AttribBlock(const DTDElement &node)
AutoPtr< CFileModules > Modules(const string &fileName)
string GetNextTokenText(void)
AutoPtr< CDataValue > Value(const DTDElement &node)
virtual void BeginDocumentTree(void)
map< string, DTDElement > m_MapElement
CDataType * x_AttribType(const DTDAttribute &att)
void SkipConditionalSection(void)
void ParseEnumeratedList(DTDAttribute &attrib)
AutoPtr< CDataType > Type(const DTDElement &node, DTDElement::EOccurrence occ, bool fromInside, bool ignoreAttrib=false)
virtual bool PopEntityLexer(void)
list< string > m_StackLexerName
CDataType * x_Type(const DTDElement &node, DTDElement::EOccurrence occ, bool fromInside, bool ignoreAttrib=false)
virtual void BuildDataTree(AutoPtr< CFileModules > &modules, AutoPtr< CDataTypeModule > &module)
virtual void BuildDocumentTree(CDataTypeModule &module)
void EndElementContent(DTDElement &node)
virtual AbstractLexer * CreateEntityLexer(CNcbiIstream &in, const string &name, bool autoDelete=true)
stack< AbstractLexer * > m_StackLexer
void ModuleType(CDataTypeModule &module, const DTDElement &node)
virtual string GetLocation(void) override
CDataType * EnumeratedBlock(const DTDAttribute &att, CEnumDataType *enumType)
void SetCommentsIfEmpty(CComments *comments)
void Module(AutoPtr< CFileModules > &modules, const string &name)
void ParseEntityContent(const string &name)
virtual DTDEntity * PushEntityLexer(const string &name)
void ParseElementContent(const string &name, bool embedded)
DTDParser(DTDLexer &lexer)
stack< string > m_StackPath
static const string & s_SpecialName
void ConsumeElementContent(DTDElement &node)
TToken GetNextToken(void)
list< string > m_ElementEmbTypes
set< string > m_GeneratedTypes
void AddElementContent(DTDElement &node, string &id_name, char separator=0)
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
static unsigned char depth[2 *(256+1+29)+1]
element_type * release(void)
Release will release ownership of pointer to caller.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
#define NCBI_RETHROW_SAME(prev_exception, message)
Generic macro to re-throw the same exception.
void Warning(CExceptionArgs_Base &args)
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
string GetDir(EIfEmptyPath mode=eIfEmptyPath_Current) const
Get the directory component for this directory entry.
string GetBase(void) const
Get the base entry name without extension.
static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)
Assemble a path from basic components.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static bool StringToBool(const CTempString str)
Convert string to bool.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static Int8 StringToInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Int8.
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
@ fDecimalPosix
StringToDouble*(): For decimal point, use C locale.
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
CDataValueTmpl< bool > CBoolDataValue
CDataValueTmpl< string > CStringDataValue
CDataValueTmpl< Int8 > CIntDataValue
CDataValueTmpl< double > CDoubleDataValue