コード例 #1
0
ファイル: svgtiny.cpp プロジェクト: 8banerjee/SocialBuildings
svgtiny_code svgtiny_parse_svg(svgInfo &info,Poco::XML::Element *svg,
		struct svgtiny_parse_state state, ofPtr<svgNode> currnode){
	float x, y, width, height;
	Poco::XML::Attr *view_box;
	Poco::XML::Element *child;

	svgtiny_parse_position_attributes(svg, state, &x, &y, &width, &height);
	svgtiny_parse_paint_attributes(svg, &state);
	svgtiny_parse_font_attributes(svg, &state);
    
    view_box = svg->getAttributeNode("viewBox");
    
	if (view_box) {
		//const char *s = (const char *) view_box->children->content;
        const char *s = (const char *) view_box->getValue().c_str();
		float min_x, min_y, vwidth, vheight;
		if (sscanf(s, "%f,%f,%f,%f",
				&min_x, &min_y, &vwidth, &vheight) == 4 ||
				sscanf(s, "%f %f %f %f",
				&min_x, &min_y, &vwidth, &vheight) == 4) {
			state.ctm.a = (float) state.viewport_width / vwidth;
			state.ctm.d = (float) state.viewport_height / vheight;
			state.ctm.e += -min_x * state.ctm.a;
			state.ctm.f += -min_y * state.ctm.d;
		}
	}

	svgtiny_parse_transform_attributes(svg, &state);


    // this is how this should work, but it doesn't
    //Poco::XML::NodeIterator it(svg, Poco::XML::NodeFilter::SHOW_ELEMENT | Poco::XML::NodeFilter::SHOW_TEXT);
    //Poco::XML::Node* pNode = it.nextNode();
    //while (pNode)
    
    

    
    
    // Note: this should be using the NodeIterator, but it doesn't seem to work as advertised when using
    // a Node as the root for the iterator constructor. Really weird.
    Poco::XML::ChildNodesList *cnl = ( Poco::XML::ChildNodesList *) svg->childNodes();
    

    svgtiny_code code = processChildren(info,currnode,cnl,state);
    
    if (code != svgtiny_OK){
        return code;
    }
      
	return svgtiny_OK;
}
コード例 #2
0
IOReturn IOPMPagingPlexus::setAggressiveness ( unsigned long type, unsigned long )
{
    OSDictionary *	dict;
    OSIterator *	iter;
    OSObject *		next;
    IOService *		candidate = 0;
    IOService *		pagingProvider;

    if( type != kPMMinutesToSleep)
        return IOPMNoErr;
    
    IOLockLock(ourLock);
    if ( systemBooting ) {
        systemBooting = false;
        IOLockUnlock(ourLock);
        dict = IOBSDNameMatching(rootdevice);
        if ( dict ) {
            iter = getMatchingServices(dict);
            if ( iter ) {
                while ( (next = iter->getNextObject()) ) {
                    if ( (candidate = OSDynamicCast(IOService,next)) ) {
                        break;
                    }
                }
                iter->release();
            }
        }
        if ( candidate ) {
            pagingProvider = findProvider(candidate);
            if ( pagingProvider ) {
                processSiblings(pagingProvider);
                pagingProvider->addPowerChild(this);
                getPMRootDomain()->removePowerChild(((IOPowerConnection *)getParentEntry(gIOPowerPlane)));
                processChildren();
            }
        }
    }
    else {
        IOLockUnlock(ourLock);
    }
    return IOPMNoErr;
}
コード例 #3
0
std::vector<RedditPost>
RedditPost::redditJsonPageToRedditPosts(std::string jsonForSinglePage, 
					std::string &nextPageUrlSuffix,
					size_t maxPosts,
					std::string metadata) {
  
  std::vector<RedditPost> posts; // empty vector
  std::istringstream iss(jsonForSinglePage);
  
  Json::Value jsonValue;
  iss >> jsonValue;
  
  Json::Value data = jsonValue["data"];
  (void) processChildren(data, posts, maxPosts,metadata);
  std::string after = data["after"].asString();
  nextPageUrlSuffix = "&after=" + after;
  //this is how reddit knows to go to page 2, 3, etc
  
  return posts;
}
コード例 #4
0
ファイル: revalidateUtils.cpp プロジェクト: alyst/zorba
void SchemaValidatorImpl::validateAfterUpdate(
    store::Item* item,
    zorba::store::PUL* pul,
    const QueryLoc& loc)
{
  ZORBA_ASSERT(item->isNode());

  TypeManager* typeManager = theSctx->get_typemanager();

  StaticContextConsts::validation_mode_t mode = theSctx->validation_mode();

  if (mode == StaticContextConsts::skip_validation)
    return;

  bool isLax = (mode == StaticContextConsts::lax_validation);

  Schema* schema = typeManager->getSchema();
  if ( !schema )
  {
    // no schema available no change to pul
    return;
  }

  EventSchemaValidator schemaValidator =
      EventSchemaValidator(typeManager,
                           schema->getGrammarPool(),
                           isLax,
                           theLoc);

  switch ( item->getNodeKind() )
  {
  case store::StoreConsts::documentNode:
  {
    //cout << "Validate after update document" << "\n"; cout.flush();

    schemaValidator.startDoc();

    store::NsBindings bindings;
    namespace_context nsCtx = namespace_context(theSctx, bindings);

    std::vector<store::Item_t> typedValues;
    processChildren(pul,
                    nsCtx,
                    typeManager,
                    schemaValidator,
                    item->getChildren(),
                    typedValues,
                    loc);
    
    schemaValidator.endDoc();
    
    //cout << "End Validate after update doc" << "\n"; cout.flush();
    return;
  }
  case store::StoreConsts::elementNode:
  {
    //cout << "Validate after update element" << "\n"; cout.flush();
      
    schemaValidator.startDoc();

    processElement(pul,
                   typeManager,
                   schemaValidator,
                   item,
                   loc);

    schemaValidator.endDoc();

    //cout << "End Validate after update elem" << "\n"; cout.flush();
    return;
  }
  default:
    throw XQUERY_EXCEPTION(
      err::XQDY0061,
      ERROR_PARAMS( ZED( NotDocOrElementNode ) ),
      ERROR_LOC( theLoc )
    );
  }
}
コード例 #5
0
ファイル: revalidateUtils.cpp プロジェクト: alyst/zorba
void SchemaValidatorImpl::processElement(
    store::PUL* pul,
    TypeManager* typeManager,
    EventSchemaValidator& schemaValidator,
    store::Item_t element,
    const QueryLoc& loc)
{
  ZORBA_ASSERT(element->isNode());
  ZORBA_ASSERT(element->getNodeKind() == store::StoreConsts::elementNode);

  store::Item_t nodeName = element->getNodeName();
  zstring baseUri;
  element->getBaseURI(baseUri);

  //cout << " vup    - processElement: " << nodeName->getLocalName()->c_str()
  //    << " @ " << nodeName->getNamespace()->c_str() << "\n"; cout.flush();

  schemaValidator.startElem(nodeName);

  // namespace declarations must go first
  processNamespaces( schemaValidator, element);

  // since the type of an element is determined only after the validator
  // receives all of it's attributes, and an attribute node needs it's
  // parent when created we need to go through the attributes twice: once
  // for validation and once for creation
  validateAttributes(schemaValidator, element->getAttributes());

  store::Item_t typeQName = schemaValidator.getTypeQName();
  store::Item_t substitutedElemQName = schemaValidator.getSubstitutedElemQName();

  //cout << " vup      - elemType old: "
  //    << element->getType()->getLocalName()->c_str() << " @ "
  //    << element->getType()->getNamespace()->c_str() << "\n"; cout.flush();
  //cout << " vup      - elemType new: " << typeQName->getLocalName()->c_str()
  //    << " @ " << typeQName->getNamespace()->c_str() << "\n"; cout.flush();

  bool isInSubstitutionElement = false;
  if (substitutedElemQName)
  {
    isInSubstitutionElement = true;
    //    cout << " vup        - substitutes: " << substitutedElemQName->g
    //  etLocalName()->c_str() << " @ " << substitutedElemQName->getNamespace()->
    // c_str() << "\n"; cout.flush();
  }

  bool isNewType = false;
  xqtref_t newType;
  store::Item_t elm;

  if ( !typeQName->equals(element->getType()) )
  {
    isNewType = true;
    newType = typeManager->create_named_type(typeQName, SequenceType::QUANT_ONE, loc);

    elm = element;
  }

  store::NsBindings bindings;
  element->getNamespaceBindings(bindings);
  namespace_context nsCtx = namespace_context(theSctx, bindings);

  processAttributes(pul, nsCtx, typeManager, schemaValidator, element, 
                    element->getAttributes(), loc);

  std::vector<store::Item_t> typedValues;
  int noOfChildren = processChildren(pul,
                                     nsCtx,
                                     typeManager, 
                                     schemaValidator,
                                     element->getChildren(),
                                     typedValues,
                                     loc);

  if ( isNewType )
  {
    bool tHasValue      = Validator::typeHasValue(newType);
    bool tHasTypedValue = Validator::typeHasTypedValue(typeManager, newType, loc);
    bool tHasEmptyValue = Validator::typeHasEmptyValue(newType);

    if ( noOfChildren==0 )
    {
      // workaround for elem of type xsd:string with no text child
      if ( newType->is_builtin() && 
          newType->getQName()->equals(GENV_TYPESYSTEM.STRING_TYPE_ONE->getQName()) )
      {
        /*store::Item_t result;
         zstring emptyStr = "";
         GENV_ITEMFACTORY->createString( result, emptyStr);
         typedValues.push_back(result);*/
        tHasEmptyValue = true;
        tHasTypedValue = false;
        tHasValue = false;
      }
      else if ( newType->type_kind()==XQType::USER_DEFINED_KIND )
      {
        const UserDefinedXQType udXQType = static_cast<const UserDefinedXQType&>(*newType);
        if ( udXQType.isSubTypeOf(typeManager, *GENV_TYPESYSTEM.STRING_TYPE_ONE) )
        {
          tHasEmptyValue = true;
          tHasTypedValue = false;
          tHasValue = false;
        }
      }
    }

    //cout << " vup        - addSetElementType: " << elm->getNodeName()->
    //  getLocalName()->str() << "   " << newType->get_qname()->getLocalName() 
    //  << " @ " << newType->get_qname()->getNamespace() << "\n"; cout.flush();
    //cout << " vup             - " << ( tHasTypedValue ? "hasTypedValue" : "" )
    //  << " values.size: " << typedValues.size() << (typedValues.size()>0 ? 
    // " [0]=" + typedValues[0]->getStringValue()->str() : "" ) << ( tHasValue ?
    // " hasValue" : "" ) << ( tHasEmptyValue ? " hasEmptyValue" : "" ) << "\n";
    //  cout.flush();

    if ( typedValues.size()==1 )
      pul->addSetElementType(&loc,
                             elm,
                             typeQName,
                             typedValues[0],
                             tHasValue,
                             tHasEmptyValue,
                             tHasTypedValue,
                             isInSubstitutionElement);
    else
      pul->addSetElementType(&loc,
                             elm,
                             typeQName,
                             (std::vector<store::Item_t>&)typedValues,
                             tHasValue,
                             tHasEmptyValue,
                             tHasTypedValue,
                             isInSubstitutionElement);
  }

  schemaValidator.endElem(nodeName);
}
コード例 #6
0
void EngineBase<TNode,TTurn>::OnNodePulse(TNode& node, TTurn& turn)
{
    processChildren(node, turn);
}
コード例 #7
0
void EngineBase<TNode,TTurn>::OnInputChange(TNode& node, TTurn& turn)
{
    processChildren(node, turn);
}