Example #1
0
std::shared_ptr<Parser> Parser::fromStream(std::istream& stream_, std::string const& filename)
{
	ParserImpl* impl = new ParserImpl();
	impl->fromStream(stream_, filename);
	std::shared_ptr<Parser> parser(new Parser(impl));
	return parser;
}
Example #2
0
std::shared_ptr<Parser> Parser::fromString(std::string const& src, std::string const& filename, int line)
{
	ParserImpl* impl = new ParserImpl();
	impl->fromString(src, filename, line);
	std::shared_ptr<Parser> parser(new Parser(impl));
	return parser;
}
Example #3
0
std::shared_ptr<Parser> Parser::fromFile(std::string const& filename)
{
	ParserImpl* pimpl = new ParserImpl();
	pimpl->fromFile(filename);
	std::shared_ptr<Parser> parser(new Parser(pimpl));
	return parser;
}
Example #4
0
Parser *Parser::Create(const std::string Filename,
                       const MemoryBuffer *MB,
                       ExprBuilder *Builder) {
  ParserImpl *P = new ParserImpl(Filename, MB, Builder);
  P->Initialize();
  return P;
}
Example #5
0
Parser *createParser(const char *argv) {
  ParserImpl *parser = new ParserImpl();
  if (!parser->open(argv)) {
    setGlobalError(parser->what());
    delete parser;
    return 0;
  }
  return parser;
}
Example #6
0
//==============================================================================
// ElementType::validateMissingAttributes
//
// Test if all required attributes have been specified and add attributes
// that have a default value
//
//==============================================================================
void ElementType::validateMissingAttributes(AttributeSet& attSet, bool bValidate, ParserImpl& parser) const
{
	AttributeTypeMap::const_iterator iter;
	for(iter=m_attributeTypeMap.begin(); iter!=m_attributeTypeMap.end(); ++iter)
	{
		const AutoPtr<AttributeType>& rpAttrType = (*iter).second;
		if(rpAttrType->getDefaultType() == AttributeType::REQUIRED)
		{
			if(bValidate && !attSet.getAttribute(rpAttrType->getName().getRawName()))
			{
				const String& errMsg = MessageFormatter::Format(
					System::GetSysMessage(sXML, EXML_ATTRREQUIRED,
					"required attribute '{0}' has not been supplied for element '{1}'"),
					rpAttrType->getName().getRawName(),
					getName().getRawName());

				parser.errorDetected(Parser::Error, errMsg, EXML_ATTRREQUIRED);
			}
		}
		else if(rpAttrType->getDefaultType() != AttributeType::IMPLIED)
		{
			// XML 1.0 says that attributes with default value
			// that are not present should be created
			if(!attSet.getAttribute(rpAttrType->getName().getRawName()))
			{
				AutoPtr<Attribute> rpAttr = new Attribute(rpAttrType->getName(), rpAttrType->getDefaultValue(), rpAttrType->getTypeAsString());
				
				attSet.addAttribute(rpAttr.get());

				//
				// If we have had to add a defaulted attribute, and if the attribute
				// definition is external, and the document claims to be standalone
				// then we have a vandity constraint error
				//
				if(bValidate && parser.isStandaloneDocument() && rpAttrType->isExternallyDeclared())
				{
					const String& errMsg = MessageFormatter::Format(
						System::GetSysMessage(sXML, EXML_ATTRDEFAULTNOTSA,
						"externally declared attribute '{0}' for element '{1}' has a default value of '{2}' which must be specified in a standalone document"),
						rpAttrType->getName().getRawName(),
						getName().getRawName(),
						rpAttrType->getDefaultValue());

					parser.errorDetected(Parser::Error, errMsg, EXML_ATTRDEFAULTNOTSA);
				}
			}
		}
	}
}
Example #7
0
//==============================================================================
// ElementType::validate
//
// Perform post DTD validation, i.e. validation checks that must be performed
// when the entire DTD has been processed.
//==============================================================================
void ElementType::validate(ParserImpl& parser) const
{
	AttributeTypeMap::const_iterator iter;
	for(iter=m_attributeTypeMap.begin(); iter!=m_attributeTypeMap.end(); ++iter)
	{
		const AutoPtr<AttributeType>& rpAttr = (*iter).second;
		rpAttr->validate(parser);
	}

	//
	// A couple of warning/compatability checks follow
	//
	if(parser.m_features.m_bDoWarningChecks)
	{
		if(m_eContentType == EMPTY && hasNotationAttribute())
		{
			// Validity Constraint: (For compatability) No Notation on Empty Element

			const String& errMsg = MessageFormatter::Format(
				System::GetSysMessage(sXML, EXML_EMPTYELEMNOTN,
				"attribute '{0}' of type NOTATION must not be declared on element '{1}' which has been declared EMPTY"),
				getNotationAttributeName(),
				m_name.getRawName());

			parser.errorDetected(Parser::Error, errMsg, EXML_EMPTYELEMNOTN);
		}

		// XML 1.0, 3.3 says we can (at user option) issue a warning 
		// if the element has not been declared
		if(!m_bDefined)
		{
			const String& errMsg = MessageFormatter::Format(
				System::GetSysMessage(sXML, EXML_ELEMUNDEFATTLIST,
				"attribute list declared for undefined element '{0}'"),
				m_name.getRawName());

			parser.errorDetected(Parser::Warning, errMsg, EXML_ELEMUNDEFATTLIST);
		}
	}
}
Example #8
0
static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface)
{
    HRESULT hr;
    PullPin *This = impl_PullPin_from_IPin(iface);

    TRACE("()\n");

    EnterCriticalSection(&This->thread_lock);
    EnterCriticalSection(This->pin.pCritSec);
    {
        if (This->pin.pConnectedTo)
        {
            FILTER_STATE state;
            ParserImpl *Parser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);

            LeaveCriticalSection(This->pin.pCritSec);
            hr = IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
            EnterCriticalSection(This->pin.pCritSec);

            if (SUCCEEDED(hr) && (state == State_Stopped) && SUCCEEDED(Parser->fnDisconnect(Parser)))
            {
                LeaveCriticalSection(This->pin.pCritSec);
                PullPin_Disconnect(iface);
                EnterCriticalSection(This->pin.pCritSec);
                hr = Parser_RemoveOutputPins(impl_from_IBaseFilter(This->pin.pinInfo.pFilter));
            }
            else
                hr = VFW_E_NOT_STOPPED;
        }
        else
            hr = S_FALSE;
    }
    LeaveCriticalSection(This->pin.pCritSec);
    LeaveCriticalSection(&This->thread_lock);

    return hr;
}
Example #9
0
Parser *Parser::Create(const std::string Filename, const MemoryBuffer *MB,
                       ExprBuilder *Builder, bool ClearArrayAfterQuery) {
  ParserImpl *P = new ParserImpl(Filename, MB, Builder, ClearArrayAfterQuery);
  P->Initialize();
  return P;
}