Ejemplo n.º 1
0
bool SampleGeoref::deserialize(SessionItemDeserializer& deserializer)
{
   if (deserializer.getBlockSizes().empty() == true)
   {
      // The plug-in was serialized before execute() was called
      return true;
   }

   XmlReader reader(NULL, false);
   DOMElement* pRootElement = deserializer.deserialize(reader, "SampleGeoref");
   if (pRootElement)
   {
      std::string windowId = A(pRootElement->getAttribute(X("rasterId")));
      mpRaster = dynamic_cast<RasterElement*>(Service<SessionManager>()->getSessionItem(windowId));
      if (mpRaster != NULL)
      {
         mXSize = atoi(A(pRootElement->getAttribute(X("xSize"))));
         mYSize = atoi(A(pRootElement->getAttribute(X("ySize"))));
         mXScale = atof(A(pRootElement->getAttribute(X("xScale"))));
         mYScale = atof(A(pRootElement->getAttribute(X("yScale"))));
         mExtrapolate = StringUtilities::fromXmlString<bool>(
            A(pRootElement->getAttribute(X("extrapolationAccurate"))));
         return true;
      }
   }
   return false;
}
Ejemplo n.º 2
0
bool FileDescriptorImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL)
   {
      return false;
   }

   DOMElement* pElement = static_cast<DOMElement*>(pDocument);

   // Filename
   bool error;
   FactoryResource<Filename> pFilename(StringUtilities::fromXmlString<Filename*>(
      A(pElement->getAttribute(X("filename"))), &error));
   if (pFilename.get() == NULL)
   {
      return false;
   }
   mFilename = *(pFilename.get());
   // Dataset location
   if (!error)
   {
      mDatasetLocation = A(pElement->getAttribute(X("datasetLocation")));
      mEndian = StringUtilities::fromXmlString<EndianType>(A(pElement->getAttribute(X("endian"))), &error);
   }

   notify(SIGNAL_NAME(Subject, Modified));
   return !error;
}
Ejemplo n.º 3
0
bool PointSetImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL || !PlotObjectImp::fromXml(pDocument, version))
   {
      return false;
   }

   DOMElement* pElem = static_cast<DOMElement*>(pDocument);
   mSymbols = StringUtilities::fromXmlString<bool>(A(pElem->getAttribute(X("symbols"))));
   mLine = StringUtilities::fromXmlString<bool>(A(pElem->getAttribute(X("line"))));
   ColorType color = StringUtilities::fromXmlString<ColorType>(A(pElem->getAttribute(X("lineColor"))));
   mLineColor = COLORTYPE_TO_QCOLOR(color);
   mLineWidth = StringUtilities::fromXmlString<int>(A(pElem->getAttribute(X("lineWidth"))));
   mLineStyle = StringUtilities::fromXmlString<LineStyle>(A(pElem->getAttribute(X("lineStyle"))));

   for (DOMNode* pChld = pElem->getFirstChild(); pChld != NULL; pChld = pChld->getNextSibling())
   {
      if (XMLString::equals(pChld->getNodeName(), X("Point")))
      {
         PointImp* pPoint = dynamic_cast<PointImp*>(addPoint());
         if (pPoint == NULL || !pPoint->fromXml(pChld, version))
         {
            return false;
         }
      }
   }

   return true;
}
Ejemplo n.º 4
0
bool GcpGeoreference::deserialize(SessionItemDeserializer &deserializer)
{
   XmlReader::StringStreamAssigner<int> toInt;
   XmlReader::StringStreamAssigner<unsigned short> toUShort;
   XmlReader reader(NULL, false);
   DOMElement* pRootElement = deserializer.deserialize(reader, "GcpGeoreference");
   if (pRootElement)
   {
      string rasterId = A(pRootElement->getAttribute(X("rasterId")));
      mpRaster = dynamic_cast<RasterElement*>(Service<SessionManager>()->getSessionItem(rasterId));
      if (mpRaster == NULL)
      {
         return false;
      }
      mOrder = toInt(A(pRootElement->getAttribute(X("order"))));
      mReverseOrder = toUShort(A(pRootElement->getAttribute(X("reverseOrder"))));
      mNumRows = toInt(A(pRootElement->getAttribute(X("numRows"))));
      mNumColumns = toInt(A(pRootElement->getAttribute(X("numCols"))));
      readContainerElements(pRootElement, "latCoefficients", mLatCoefficients, COEFFS_FOR_ORDER(MAX_ORDER));
      readContainerElements(pRootElement, "lonCoefficients", mLonCoefficients, COEFFS_FOR_ORDER(MAX_ORDER));
      readContainerElements(pRootElement, "xCoefficients", mXCoefficients, COEFFS_FOR_ORDER(MAX_ORDER));
      readContainerElements(pRootElement, "yCoefficients", mYCoefficients, COEFFS_FOR_ORDER(MAX_ORDER));
      return true;
   }
   return false;
}
Ejemplo n.º 5
0
bool TiePointLayerImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (!LayerImp::fromXml(pDocument, version))
   {
      return false;
   }

   vector<TiePoint> oldPoints;

   TiePointList* pTiePointList = dynamic_cast<TiePointList*>(getDataElement());
   if (pTiePointList != NULL)
   {
      oldPoints = pTiePointList->getTiePoints();
   }

   DOMElement* pElmnt = static_cast<DOMElement*>(pDocument);

   setSymbolSize(StringUtilities::fromXmlString<int>(A(pElmnt->getAttribute(X("symbolSize")))));
   setColor(COLORTYPE_TO_QCOLOR(StringUtilities::fromXmlString<ColorType>(A(pElmnt->getAttribute(X("symbolColor"))))));
   enableLabels(StringUtilities::fromXmlString<bool>(A(pElmnt->getAttribute(X("labelIsEnabled")))));
   setIsMission(StringUtilities::fromXmlString<bool>(A(pElmnt->getAttribute(X("isMission")))));

   View* pView = getView();
   if ((pView != NULL) && (pTiePointList != NULL))
   {
      vector<TiePoint> newPoints = pTiePointList->getTiePoints();
      pView->addUndoAction(new SetTiePoints(pTiePointList, oldPoints, newPoints));
   }

   return true;
}
Ejemplo n.º 6
0
bool DataElementImp::deserialize(SessionItemDeserializer &deserializer)
{
   XmlReader reader(NULL, false);
   DOMDocument* pDoc = deserializer.deserialize(reader);
   if (pDoc == NULL)
   {
      return false;
   }
   DOMElement* pRoot = pDoc->getDocumentElement();
   VERIFY(pRoot != NULL);
   if (pRoot->hasAttribute(X("parentId")))
   {
      DataElement* pParent =
         dynamic_cast<DataElement*>(Service<SessionManager>()->getSessionItem(A(pRoot->getAttribute(X("parentId")))));
      if (pParent == NULL)
      {
         return false;
      }

      Service<ModelServices>()->setElementParent(dynamic_cast<DataElement*>(this), pParent);
   }
   Service<ModelServices>()->setElementName(dynamic_cast<DataElement*>(this), A(pRoot->getAttribute(X("name"))));
   unsigned int formatVersion = 0;
   stringstream str(A(pRoot->getAttribute(X("version"))));
   str >> formatVersion;
   return SessionItemImp::fromXml(pRoot, formatVersion) && fromXml(pRoot, formatVersion);
}
Ejemplo n.º 7
0
/**
 * Create PerfPart element
 */
PerfPart::PerfPart( PMLDocument *doc, DOMElement *element ){
    m_doc = doc;
    m_element = element;

    DOMDocument *domdoc = m_element->getOwnerDocument();

    const XMLCh *partID = m_element->getAttribute( XS("part") );

    DOMElement *root = m_element->getOwnerDocument()->getDocumentElement();
    DOMNodeList *parts = root->getElementsByTagName(XS("part"));

    for( unsigned int i=0; i<parts->getLength(); i++ ){

        DOMElement *e = (DOMElement*)parts->item(i);

        cout << " perf  " << XS( m_element->getAttribute(XS("id")))
                << " score " << XS( e->getAttribute(XS("part")) )
                << endl;

        if( !strcmp(XS( m_element->getAttribute(XS("id")) ),  XS( e->getAttribute(XS("part")) ))   ){
            m_scorePart = new ScorePart( m_doc, e );
        }
    }
  
    DOMNodeList *nl = m_element->getElementsByTagName(XS(PNote::Tag));
    for( int i=0; i<nl->getLength(); i++ ){
        m_notes.push_back( new PNote( m_doc, (DOMElement*)nl->item(i) ) );
    
    }
  
}
Ejemplo n.º 8
0
int Problem::GetDerivOrder()
{
  // first check to see if we already know the derivative order
  if(!hasDerivOrder_)
    {
      // if not, look in the XML and see if we can find out.
      DOMElement* subroutineXML = GetSubroutineXML();
      string second =
	XMLString::transcode(subroutineXML->getAttribute(XMLString::transcode("Second")));
      string first =
	XMLString::transcode(subroutineXML->getAttribute(XMLString::transcode("First")));
      if(second == "true")
	{
	  derivOrder_ = 2;
	}else if(first == "true")
	  {
	    derivOrder_ = 1;
	  }else{
	    derivOrder_ = 0;
	  }
      hasDerivOrder_ = true;
    }

  return derivOrder_;
}
Ejemplo n.º 9
0
bool FrameLabelObjectImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL || Service<SessionManager>()->isSessionLoading() == false)
   {
      return false;
   }

   if (!TextObjectImp::fromXml(pDocument, version))
   {
      return false;
   }

   DOMElement* pElement = static_cast<DOMElement*> (pDocument);
   if (pElement != NULL)
   {
      // Set the autoMode setting (which will also call setLocked)
      setAutoMode(StringUtilities::fromXmlString<bool>(A(pElement->getAttribute(X("autoMode")))));

      // If the object is not currently locked, load all frames
      if (getLocked() == false)
      {
         for (DOMNode* pChild = pDocument->getFirstChild(); 
            pChild != NULL; pChild = pChild->getNextSibling())
         {
            if (XMLString::equals(pChild->getNodeName(), X("Animations")))
            {
               vector<Animation*> animations;
               for (DOMNode* pGrandchild = pChild->getFirstChild();
                  pGrandchild != NULL;
                  pGrandchild = pGrandchild->getNextSibling())
               {
                  if (XMLString::equals(pGrandchild->getNodeName(), X("Animation")))
                  {
                     pElement = dynamic_cast<DOMElement*>(pGrandchild);
                     if (pElement != NULL)
                     {
                        string id(A(pElement->getAttribute(X("id"))));
                        if (id.empty() != true)
                        {
                           Animation* pAnim = dynamic_cast<Animation*>(Service<SessionManager>()->getSessionItem(id));
                           if (pAnim != NULL)
                           {
                              animations.push_back(pAnim);
                           }
                        }
                     }
                  }
               }

               setAnimations(animations);
            }
         }
      }
   }

   return true;
}
Ejemplo n.º 10
0
void NewtonProblem::SetParameters(OptimizeClass* objfcn)
{
  Problem::SetParameters(objfcn);

  DOMElement* searchXML = GetParameterXML();
  VariableList* variables = GetVariables();

  string gradMult, searchSize, maxBack;

  OptNewtonLike * objfcnNewt = (OptNewtonLike *) objfcn;

  if(searchType_ == trustPDS)
  {
    objfcnNewt->setSearchStrategy(TrustPDS);

    gradMult =
      XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult")));
    if (gradMult != "")
      objfcnNewt->setGradMult(atof(gradMult.c_str()));

    searchSize =
      XMLString::transcode(searchXML->getAttribute(XMLString::transcode("searchSize")));
    if (searchSize != "")
      objfcnNewt->setSearchSize(atoi(searchSize.c_str()));
  }
  else if (searchType_ == lineSearch)
  {
    objfcnNewt->setSearchStrategy(LineSearch);

    maxBack =
      XMLString::transcode(searchXML->getAttribute(XMLString::transcode("maxBTIter")));
    if (maxBack != "")
      objfcnNewt->setMaxBacktrackIter(atoi(maxBack.c_str()));
  }
  else if (searchType_ == trustRegion)
  {
    if ((variables->upperExists()) || (variables->lowerExists()))
    {
      cout << "Newton with Trust Region does not support bounds." << endl;
      cout << "Using Line Search instead." << endl;
      objfcnNewt->setSearchStrategy(LineSearch);
    }
    else
    {
      objfcnNewt->setSearchStrategy(TrustRegion);
      gradMult =
	XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult")));
      if (gradMult != "")
	objfcnNewt->setGradMult(atof(gradMult.c_str()));
    }
  }
  else
  {
    cerr << "Unrecognized search strategy type" << endl;
    exit(1);
  }
}
Ejemplo n.º 11
0
USERFCN2 Problem::GetUserFunction2()
{
  // load in the library function and cast appropriately before returning
  DOMElement* subroutineXML = GetSubroutineXML();
  string fEval =
    XMLString::transcode(subroutineXML->getAttribute(XMLString::transcode("FEval")));
  string libName =
    XMLString::transcode(subroutineXML->getAttribute(XMLString::transcode("LibName")));
  void* function = GetFunction(libName, fEval);
  return (USERFCN2) function;
}
Ejemplo n.º 12
0
INITFCN Problem::GetInitFunction()
{
  // load in the library function and cast appropriately before returning
  DOMElement* subroutineXML = GetSubroutineXML();
  string init =
    XMLString::transcode(subroutineXML->getAttribute(XMLString::transcode("Init")));
  string libName =
    XMLString::transcode(subroutineXML->getAttribute(XMLString::transcode("LibName")));
  void* function = GetFunction(libName, init);
  return (INITFCN) function;
}
bool RangeProfilePlotManager::deserialize(SessionItemDeserializer& deserializer)
{
   XmlReader reader(NULL, false);
   DOMElement* pRootElement = deserializer.deserialize(reader, "RangeProfilePlotManager");
   if (pRootElement)
   {
      std::string viewId = A(pRootElement->getAttribute(X("viewId")));
      mpView = dynamic_cast<PlotView*>(Service<SessionManager>()->getSessionItem(viewId));

      mpPlot = Service<DesktopServices>()->createPlotWidget(getName(), CARTESIAN_PLOT);
      VERIFY(mpPlot);
      Serializable* pPlotSer = dynamic_cast<Serializable*>(mpPlot); // The imp side is serializable
      VERIFY(pPlotSer);
      if (!pPlotSer->fromXml(findChildNode(pRootElement, "plot"), reader.VERSION))
      {
         return false;
      }

      mpView = mpPlot->getPlot();
      VERIFY(mpView);
      Serializable* pPlotViewSer = dynamic_cast<Serializable*>(mpView); // The imp side is serializable
      VERIFY(pPlotViewSer);
      if (!pPlotViewSer->fromXml(findChildNode(pRootElement, "plotView"), reader.VERSION))
      {
         return false;
      }

      std::list<PlotObject*> objects;
      mpView->getObjects(POINT_SET, objects);
      FOR_EACH_DOMNODE(pRootElement, pChild)
      {
         if (XMLString::equals(pChild->getNodeName(), X("signature")))
         {
            DOMElement* pChldElmnt = static_cast<DOMElement*>(pChild);
            std::string sigId = A(pChldElmnt->getAttribute(X("sigId")));
            std::string pointSetName = A(pChldElmnt->getAttribute(X("pointSetName")));
            Signature* pSignature = static_cast<Signature*>(Service<SessionManager>()->getSessionItem(sigId));
            if (pSignature == NULL)
            {
               return false;
            }
            mSigPointSets[pSignature] = pointSetName;
            pSignature->attach(SIGNAL_NAME(Subject, Deleted), Slot(this, &RangeProfilePlotManager::signatureDeleted));
            pSignature->getDataDescriptor()->attach(SIGNAL_NAME(DataDescriptor, Renamed),
               Slot(this, &RangeProfilePlotManager::signatureRenamed));
         }
      }
      deserializer.nextBlock();
      return DockWindowShell::deserialize(deserializer);
   }
   return false;
}
Ejemplo n.º 14
0
bool SampleGeoref::deserialize(SessionItemDeserializer &deserializer)
{
    XmlReader reader(NULL, false);
    DOMElement* pRootElement = deserializer.deserialize(reader, "SampleGeoref");
    if (pRootElement)
    {
        std::string windowId = A(pRootElement->getAttribute(X("rasterId")));
        mpRaster = dynamic_cast<RasterElement*>(Service<SessionManager>()->getSessionItem(windowId));
        if (mpRaster != NULL)
        {
            mXSize = atoi(A(pRootElement->getAttribute(X("xSize"))));
            mYSize = atoi(A(pRootElement->getAttribute(X("ySize"))));
            mXScale = atof(A(pRootElement->getAttribute(X("xScale"))));
            mYScale = atof(A(pRootElement->getAttribute(X("yScale"))));
            mFrames = atof(A(pRootElement->getAttribute(X("frames"))));
            mExtrapolate = StringUtilities::fromXmlString<bool>(
                               A(pRootElement->getAttribute(X("extrapolationAccurate"))));
            mCurrentFrame = atoi(A(pRootElement->getAttribute(X("currentFrame"))));
            mRotate = atoi(A(pRootElement->getAttribute(X("rotate"))));
            std::string animId = A(pRootElement->getAttribute(X("animationId")));
            if (animId.empty() == false)
            {
                Animation* pAnim = dynamic_cast<Animation*>(Service<SessionManager>()->getSessionItem(animId));
                if (pAnim)
                {
                    mpAnimation.reset(pAnim);
                }
            }
            return true;
        }
    }
    return false;
}
Ejemplo n.º 15
0
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* readFontElement(const char* pName,
                                                           XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* pParent,
                                                           Font& font)
{
   DOMElement* pElement = dynamic_cast<DOMElement*>(findChildNode(pParent, pName));
   if (pElement)
   {
      font.setFace(A(pElement->getAttribute(X("face"))));
      font.setPointSize(StringUtilities::fromXmlString<int>(A(pElement->getAttribute(X("point_size")))));
      font.setBold(StringUtilities::fromXmlString<bool>(A(pElement->getAttribute(X("bold")))));
      font.setItalic(StringUtilities::fromXmlString<bool>(A(pElement->getAttribute(X("italic")))));
      font.setUnderline(StringUtilities::fromXmlString<bool>(A(pElement->getAttribute(X("underline")))));
   }
   return pElement;
}
Ejemplo n.º 16
0
bool TextImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL || !PlotObjectImp::fromXml(pDocument, version))
   {
      return false;
   }
   DOMElement* pElem = static_cast<DOMElement*>(pDocument);
   ColorType color = StringUtilities::fromXmlString<ColorType>(A(pElem->getAttribute(X("color"))));
   mColor = COLORTYPE_TO_QCOLOR(color);
   mFont.fromString(A(pElem->getAttribute(X("font"))));
   mText = A(pElem->getAttribute(X("text")));
   mLocation = StringUtilities::fromXmlString<LocationType>(A(pElem->getAttribute(X("location"))));

   return true;
}
Ejemplo n.º 17
0
bool TextObjectImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL)
   {
      return false;
   }

   bool bSuccess = RectangleObjectImp::fromXml(pDocument, version);
   if (bSuccess == true)
   {
      DOMElement* pElement = static_cast<DOMElement*>(pDocument);
      if (pElement != NULL)
      {
         string editable(A(pElement->getAttribute(X("textEditable"))));
         if (editable.empty() == false)
         {
            mTextEditable = StringUtilities::fromXmlString<bool>(editable);
         }
      }
   }

   mUpdateTexture = true;
   mUpdateBoundingBox = false;

   return bSuccess;
}
Ejemplo n.º 18
0
int SNote::getMeasure(){

    DOMElement *measure = (DOMElement*)m_element->getParentNode();
    return atoi( 
                XS( measure->getAttribute(XS("number")) )
               );
}
Ejemplo n.º 19
0
bool ArrowImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL || !PlotObjectImp::fromXml(pDocument, version))
   {
      return false;
   }
   DOMElement* pElem = static_cast<DOMElement*>(pDocument);
   mStyle = StringUtilities::fromXmlString<ArrowStyle>(A(pElem->getAttribute(X("arrowStyle"))));
   for (DOMNode* pChld = pDocument->getFirstChild(); pChld != NULL; pChld = pChld->getNextSibling())
   {
      if (XMLString::equals(pChld->getNodeName(), X("Line")))
      {
         if (!mLine.fromXml(pChld, version))
         {
            return false;
         }
      }
      else if (XMLString::equals(pChld->getNodeName(), X("ArrowHead")))
      {
         if (!mArrowHead.fromXml(pChld, version))
         {
            return false;
         }
      }
   }

   return true;
}
Ejemplo n.º 20
0
EppAuthInfo * EppAuthInfo::fromXML( const DOMNode& root )
{
	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
//		if( name.equals("pw") )
		if( name.equals("pw") || name.equals("contact:pw") || name.equals("domain:pw") || name.equals("svcsub:pw")
			|| name.equals("xriAU:pw") || name.equals("xriINU:pw") || name.equals("xriINA:pw") || name.equals("xriISV:pw") /* Uncomment for CodeString || name.equals("xriCS:pw")*/ )
		{
			DOMElement * elm = (DOMElement *) node;
			DOMString roid = elm->getAttribute(XS("roid"));
			DOMString value = EppUtil::getText(*node);
			return new EppAuthInfo(XS(TYPE_PW), value, roid);
		}
//		else if( name.equals("ext") )
		else if( name.equals("ext") || name.equals("contact:ext") || name.equals("domain:ext") || name.equals("svcsub:ext")
			|| name.equals("xriAU:ext") || name.equals("xriINU:ext") || name.equals("xriINA:ext") || name.equals("xriISV:ext") )
		{
			return new EppAuthInfo(XS(TYPE_EXT), NULLXS);
		}
	}
	return null;
}
Ejemplo n.º 21
0
list<string> InputHandler::getPostProcessorNameList()
{
	list<string> names;
	
	//get the postprocessor node 
	DOMElement *elem = dynamic_cast<DOMElement*>(getElementByTagName(TAG_postprocessor.xmlStr()));
	//check whether there is one
	if(!elem)
	{
		crusde_info("No postprocessors found.");
		return names;
	}
	//if so, grab all plugins it owns.
	DOMNodeList *plugins = elem->getElementsByTagName(TAG_plugin.xmlStr());
	unsigned int i(0);
	
	//if there are plugins ... 
	while(plugins && i < plugins->getLength() )
	{
		if( plugins->item(i)->getNodeType() == DOMNode::ELEMENT_NODE)
		{			
			/* upcast child to element node */
			DOMElement *elem = dynamic_cast<DOMElement*>( plugins->item(i) );
			StrXML name(elem->getAttribute(ATTR_name.xmlStr()));
			//... add names to list for later lookup.
			names.push_back(name.cppStr());
		}
		++i;		
	}
	
	//return filled list
	return names;
}
Ejemplo n.º 22
0
bool PointImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL || !PlotObjectImp::fromXml(pDocument, version))
   {
      return false;
   }

   DOMElement* pElem = static_cast<DOMElement*>(pDocument);
   mSymbol = StringUtilities::fromXmlString<Point::PointSymbolType>(A(pElem->getAttribute(X("symbolType"))));
   mSymbolSize = StringUtilities::fromXmlString<int>(A(pElem->getAttribute(X("symbolSize"))));
   ColorType color = StringUtilities::fromXmlString<ColorType>(A(pElem->getAttribute(X("color"))));
   mColor = COLORTYPE_TO_QCOLOR(color);
   mLocation = StringUtilities::fromXmlString<LocationType>(A(pElem->getAttribute(X("location"))));

   return true;
}
Ejemplo n.º 23
0
bool ViewWindowImp::fromXml(DOMNode* pDocument, unsigned int version)
{
   if (pDocument == NULL)
   {
      return false;
   }

   if (!WindowImp::fromXml(pDocument, version))
   {
      return false;
   }

   DOMElement* pElement = static_cast<DOMElement*>(pDocument);
   if (pElement->hasAttribute(X("viewId")))
   {
      View* pOldView = mpView;
      setView(dynamic_cast<View*>(SessionManagerImp::instance()->getSessionItem(
         A(pElement->getAttribute(X("viewId"))))));
      Service<DesktopServices>()->deleteView(pOldView);
   }
   else
   {
      setView(NULL);
   }

   return true;
}
Ejemplo n.º 24
0
static void parseSequence(DOMElement *parent, DOMElement *sequence, Class *cl, bool choice = false) {
    //we expect to see a whole bunch of <element>s here
    //if choice is true then this is a choice sequence - every element is optional
    CHECK(parent);
    CHECK(sequence);

    vector<DOMElement*> children = getChildElementsByTagName(sequence, "element");

    //support <sequence> in <choice> by simply recursing
    //simply put this means the <sequence> tags are ignored
    vector<DOMElement*> subSequences = getChildElementsByTagName(sequence, "sequence");

    if(subSequences.size() > 0 && !choice)
        throw runtime_error("Found <sequence> element in another <sequence> element");

    children.insert(children.end(), subSequences.begin(), subSequences.end());
    
    for(size_t x = 0; x < children.size(); x++) {
        DOMElement *child = children[x];
            
        int minOccurs = 1;
        int maxOccurs = 1;

        XercesString typeStr("type");
        XercesString minOccursStr("minOccurs");
        XercesString maxOccursStr("maxOccurs");
        string name = fixIdentifier(XercesString(child->getAttribute(XercesString("name"))));

        if(child->hasAttribute(minOccursStr)) {
            stringstream ss;
            ss << XercesString(child->getAttribute(minOccursStr));
            ss >> minOccurs;
        }

        if(child->hasAttribute(maxOccursStr)) {
            XercesString str(child->getAttribute(maxOccursStr));

            if(str == "unbounded")
                maxOccurs = UNBOUNDED;
            else {
                stringstream ss;
                ss << str;
                ss >> maxOccurs;
            }
        }
vector<ImportDescriptor*> SignatureSetImporter::createImportDescriptors(DOMTreeWalker* pTree, vector<string> &datasetPath)
{
   vector<ImportDescriptor*> descriptors;
   FactoryResource<DynamicObject> pMetadata;
   VERIFYRV(pMetadata.get() != NULL, descriptors);

   string datasetName = StringUtilities::toDisplayString(mDatasetNumber++);
   for (DOMNode* pChld = pTree->firstChild(); pChld != NULL; pChld = pTree->nextSibling())
   {
      if (XMLString::equals(pChld->getNodeName(), X("metadata")))
      {
         DOMElement* pElmnt = static_cast<DOMElement*>(pChld);
         string name = A(pElmnt->getAttribute(X("name")));
         string val = A(pElmnt->getAttribute(X("value")));
         pMetadata->setAttribute(name, val);
         if (name == "Name")
         {
            datasetName = val;
         }
      }
      else if (XMLString::equals(pChld->getNodeName(), X("signature_set")))
      {
         datasetPath.push_back(datasetName);
         vector<ImportDescriptor*> sub = createImportDescriptors(pTree, datasetPath);
         datasetPath.pop_back();
         descriptors.insert(descriptors.end(), sub.begin(), sub.end());
         pTree->parentNode();
      }
   }
   ImportDescriptorResource pImportDescriptor(datasetName, "SignatureSet", datasetPath);
   VERIFYRV(pImportDescriptor.get() != NULL, descriptors);
   DataDescriptor* pDataDescriptor = pImportDescriptor->getDataDescriptor();
   VERIFYRV(pDataDescriptor != NULL, descriptors);
   FactoryResource<SignatureFileDescriptor> pFileDescriptor;
   VERIFYRV(pFileDescriptor.get() != NULL, descriptors);
   pFileDescriptor->setFilename(mFilename);
   datasetPath.push_back(datasetName);
   string loc = "/" + StringUtilities::join(datasetPath, "/");
   datasetPath.pop_back();
   pFileDescriptor->setDatasetLocation(loc);
   pDataDescriptor->setFileDescriptor(pFileDescriptor.get());
   pDataDescriptor->setMetadata(pMetadata.get());
   descriptors.push_back(pImportDescriptor.release());
   return descriptors;
}
Ejemplo n.º 26
0
double ParameterGrp::GetFloat(const char* Name, double dPreset) const
{
    // check if Element in group
    DOMElement *pcElem = FindElement(_pGroupNode,"FCFloat",Name);
    // if not return preset
    if (!pcElem) return dPreset;
    // if yes check the value and return
    return atof (StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str());
}
Ejemplo n.º 27
0
unsigned long ParameterGrp::GetUnsigned(const char* Name, unsigned long lPreset) const
{
    // check if Element in group
    DOMElement *pcElem = FindElement(_pGroupNode,"FCUInt",Name);
    // if not return preset
    if (!pcElem) return lPreset;
    // if yes check the value and return
    return strtoul (StrX(pcElem->getAttribute(XStr("Value").unicodeForm())).c_str(),0,10);
}
Ejemplo n.º 28
0
void DeltaApplyEngine::TextNode_Update( XID_t nodeXID, DOMNode *operationNode ) {
	vddprintf(("        update xid=%d\n",(int)nodeXID));
	DOMNode* upNode = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (upNode==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	
	DOMNodeList *opNodes = operationNode->getChildNodes();
	vddprintf(("opNodes->length() = %d\n", opNodes->getLength()));
	XyStrDeltaApply *xytext = new XyStrDeltaApply(xiddoc, upNode, 1);
	xytext->setApplyAnnotations(applyAnnotations);
	for (int i = opNodes->getLength() - 1; i >= 0; i--) {
		DOMElement *op = (DOMElement *) opNodes->item(i);
		char *optype = XMLString::transcode(op->getLocalName());
		XMLCh pos_attr[4];
		XMLCh len_attr[4];
		XMLString::transcode("pos", pos_attr, 3);
		XMLString::transcode("len", len_attr, 3);
		vddprintf(("item %d = %s\n", i, optype));
		// Replace operation
		if (strcmp(optype, "tr") == 0) {
			char *pos = XMLString::transcode(op->getAttribute(pos_attr));
			char *len = XMLString::transcode(op->getAttribute(len_attr));
			xytext->replace(atoi(pos), atoi(len), op->getTextContent());
			XMLString::release(&pos);
			XMLString::release(&len);
		}
		// Delete operation
		else if (strcmp(optype, "td") == 0) {
			char *pos = XMLString::transcode(op->getAttribute(pos_attr));
			char *len = XMLString::transcode(op->getAttribute(len_attr));
			xytext->remove(atoi(pos), atoi(len));
			XMLString::release(&pos);
			XMLString::release(&len);
		}
		// Insert operation
		else if (strcmp(optype, "ti") == 0) {
			char *pos = XMLString::transcode(op->getAttribute(pos_attr));
			xytext->insert(atoi(pos), op->getTextContent());
			XMLString::release(&pos);
		}
		XMLString::release(&optype);
	}
	xytext->complete();
	delete xytext;
}
Ejemplo n.º 29
0
	void *NclPresentationControlParser::parseRuleBase(
		    DOMElement *parentElement, void *objGrandParent) {

		wclog << "parseRuleBase" << endl;
		void *parentObject;
		DOMNodeList *elementNodeList;
		DOMElement *element;
		DOMNode *node;
		string elementTagName;
		void *elementObject;

		parentObject = createRuleBase(parentElement, objGrandParent);
		if (parentObject == NULL) {
			return NULL;
		}

		elementNodeList = parentElement->getChildNodes();
		for (int i = 0; i < (int)elementNodeList->getLength(); i++) {
			node = elementNodeList->item(i);
			if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
				element = (DOMElement*)node;
				elementTagName = XMLString::transcode(element->getTagName());
				wclog << ">>" << elementTagName.c_str() << ": ";
				wclog << XMLString::transcode(element->getAttribute(XMLString::transcode("id"))) << endl;

				if (XMLString::compareIString(elementTagName.c_str(),
					    "importBase") == 0) {

					elementObject = getImportParser()->parseImportBase(
						    element, parentObject);

					if (elementObject != NULL) {
						addImportBaseToRuleBase(parentObject, elementObject);
					}

				} else if(XMLString::compareIString(elementTagName.c_str(),
					    "rule") == 0) {

					elementObject = parseRule(element, parentObject);
					if (elementObject != NULL) {
						addRuleToRuleBase(parentObject, elementObject);
					}

				} else if(XMLString::compareIString(elementTagName.c_str(),
					    "compositeRule")==0) {

					elementObject = parseCompositeRule(element, parentObject);
					if (elementObject != NULL) {
						addCompositeRuleToRuleBase(parentObject, elementObject);
					}
				}
			}
		}

		return parentObject;
	}
Ejemplo n.º 30
0
const char *SkinElementsMgr::getBitmapFilename(const char *id, int *x, int *y, int *subw, int *subh,int *d, const char **rootpath, XmlReaderParams **params) {
  if(m_doc) {   
    DOMElement * node = m_doc->getElementById(id);
    if (node ) {
      const char *rx = node->getAttribute("x");
      const char *ry = node->getAttribute("y");
      const char *rw = node->getAttribute("w");
      const char *rh = node->getAttribute("h");
      if ( rx && ry && rw && rh ) {
        if(x) *x = atoi(rx);
        if(y) *y = atoi(ry);
        if(subw) *subw = atoi(rw);
        if(subh) *subh = atoi(rh);
      }
      if( rootpath ) *rootpath = m_skinPath;
      //TODO: pass the XmlParams around too
      return node->getAttribute("file");
    }
  }
  return NULL;
}