Exemplo n.º 1
0
void
Serialized::CreateObjects(const wxXmlNode& root)
{
	wxString uid;
	if (root.GetPropVal(wxT("uid"), &uid))
	{
		if (m_Objects.find(uid) == m_Objects.end())
		{
			wxString classname = root.GetName();
			std::map<wxString, Creator>::iterator it = m_Creators.find(classname);
			if (it == m_Creators.end())
			{
				THROW(TXT("Class \"%s\" not found."), root.GetName().c_str());
			}
			Serialized *obj = (it->second)(root);
			m_Objects.insert(std::pair<wxString, Serialized *>(uid, obj));
		}
	}
	wxXmlNode *child = root.GetChildren();
	while (child != NULL)
	{
		CreateObjects(*child);
		child = child->GetNext();
	}
}
Exemplo n.º 2
0
	wxString
	GetStringAttribute(const wxXmlNode& node, const wxString& name, const wxString& def)
	{
		wxString value;
		if (!node.GetPropVal(name, &value))
		{
			if (def == wxEmptyString)
			{
				THROW("Couldn't find attribute \"%s\" in element <%s>.", name.c_str(), node.GetName().c_str());
			}
			value = def;
		}
		return value;
	}
Exemplo n.º 3
0
	void
	DeleteChild(wxXmlNode& node, wxXmlNodeType type)
	{
		wxXmlNode *child = node.GetChildren();
		while (child != NULL)
		{
			if (child->GetType() == type)
			{
				node.RemoveChild(child);
				DESTROY(child);
				return;
			}
			child = child->GetNext();
		}
	}
Exemplo n.º 4
0
void
MethodLua::Deserialize(const wxXmlNode& root)
{
	m_source = root.GetNodeContent();
	LuaUtil::LoadBuffer(g_L, m_source.c_str(), m_source.Len(), "method");
	m_lua_ref = luaL_ref(g_L, LUA_REGISTRYINDEX);
	Method::Deserialize(root);
}
Exemplo n.º 5
0
void
MethodVarParse::Deserialize(const wxXmlNode& root)
{
	m_pattern = root.GetNodeContent();
	m_source = Compile(m_pattern);
	wxXmlNode *child = root.GetChildren();
	while (child != NULL)
	{
		if (child->GetType() == wxXML_TEXT_NODE || child->GetType() == wxXML_CDATA_SECTION_NODE)
		{
			break;
		}
		child = child->GetNext();
	}
	child->SetContent(m_source);
	MethodLua::Deserialize(root);
	child->SetContent(m_pattern);
}
Exemplo n.º 6
0
	void
	DeleteChild(wxXmlNode& node, const wxString& name)
	{
		wxXmlNode *child = FindChild(node, name);
		if (child != NULL)
		{
			node.RemoveChild(child);
			DESTROY(child);
		}
	}
Exemplo n.º 7
0
	int
	GetIntAttribute(const wxXmlNode& node, const wxString& name, const wxString& def)
	{
		wxString value = GetStringAttribute(node, name, def);
		long l;
		if (!value.ToLong(&l, 0))
		{
			THROW("Attribute \"%s\" in element <%s> is not an integer.", name.c_str(), node.GetName().c_str());
		}
		return l;
	}
Exemplo n.º 8
0
void
MethodLua::Deserialize(const wxXmlNode& root)
{
	m_source = root.GetNodeContent();

    std::string temp;
    Helium::ConvertString( (const wxChar*)m_source.c_str(), temp );
    LuaUtilities::LoadBuffer(g_FragmentShaderLuaState, temp.c_str(), temp.length(), "method");
	m_lua_ref = luaL_ref(g_FragmentShaderLuaState, LUA_REGISTRYINDEX);
	Method::Deserialize(root);
}
Exemplo n.º 9
0
void
MethodList::Deserialize(const wxXmlNode& root)
{
	m_choices.clear();
	wxStringTokenizer tkz(root.GetNodeContent(), wxT(","));
	while (tkz.HasMoreTokens())
	{
		wxString token = tkz.GetNextToken();
		m_choices.insert(token.Trim().Trim(false));
	}
	Method::Deserialize(root);
}
Exemplo n.º 10
0
void
MethodRegex::Deserialize(const wxXmlNode& root)
{
	m_patterns.clear();
	wxStringTokenizer tkz(root.GetNodeContent(), wxT("|"));
	while (tkz.HasMoreTokens())
	{
		wxString token = tkz.GetNextToken();
		m_patterns.push_back(token.Trim().Trim(false));
	}
	Method::Deserialize(root);
	Compile();
}
Exemplo n.º 11
0
void XmlStackWalker::OnStackFrame(const wxStackFrame& frame)
{
    m_isOk = true;

    wxXmlNode *nodeFrame = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("frame"));
    m_nodeStack->AddChild(nodeFrame);

    NumProperty(nodeFrame, wxT("level"), frame.GetLevel());
    wxString func = frame.GetName();
    if ( !func.empty() )
    {
        nodeFrame->AddAttribute(wxT("function"), func);
        HexProperty(nodeFrame, wxT("offset"), frame.GetOffset());
    }

    if ( frame.HasSourceLocation() )
    {
        nodeFrame->AddAttribute(wxT("file"), frame.GetFileName());
        NumProperty(nodeFrame, wxT("line"), frame.GetLine());
    }

    const size_t nParams = frame.GetParamCount();
    if ( nParams )
    {
        wxXmlNode *nodeParams = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("parameters"));
        nodeFrame->AddChild(nodeParams);

        for ( size_t n = 0; n < nParams; n++ )
        {
            wxXmlNode *
                nodeParam = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("parameter"));
            nodeParams->AddChild(nodeParam);

            NumProperty(nodeParam, wxT("number"), n);

            wxString type, name, value;
            if ( !frame.GetParam(n, &type, &name, &value) )
                continue;

            if ( !type.empty() )
                TextElement(nodeParam, wxT("type"), type);

            if ( !name.empty() )
                TextElement(nodeParam, wxT("name"), name);

            if ( !value.empty() )
                TextElement(nodeParam, wxT("value"), value);
        }
    }
}
Exemplo n.º 12
0
	void
	DeleteAttribute(wxXmlNode& node, const wxString& name)
	{
		wxXmlProperty *prop = node.GetProperties();
		wxXmlProperty *prev = NULL;
		while (prop != NULL)
		{
			if (prop->GetName() == name)
			{
				if (prev == NULL)
				{
					node.SetProperties(prop->GetNext());
				}
				else
				{
					prev->SetNext(prop->GetNext());
				}
				DESTROY(prop);
				return;
			}
			prop = prop->GetNext();
		}
	}
Exemplo n.º 13
0
void
Group::DeserializeChildren(const wxXmlNode& root)
{
	wxXmlNode *child = root.GetChildren();
	while (child != NULL)
	{
		wxString uid = XML::GetStringAttribute(*child, wxT("uid"));
		Serialized *obj = Serialized::GetObjectByUID(uid);
		obj->Deserialize(*child);
		Shape *shape = static_cast<Shape *>(obj);
		shape->SetParent(this);
		m_children.Add(shape);
		child = child->GetNext();
	}
}
Exemplo n.º 14
0
	bool
	GetBoolAttribute(const wxXmlNode& node, const wxString& name, const wxString& def)
	{
		wxString value = GetStringAttribute(node, name, def);
		if (value == wxT("true"))
		{
			return true;
		}
		else if (value == wxT("false"))
		{
			return false;
		}
		else
		{
			THROW("Attribute \"%s\" in element <%s> is not a boolean.", name.c_str(), node.GetName().c_str());
		}
	}
Exemplo n.º 15
0
void
ShaderObject::DeserializeMethods(const wxXmlNode& root)
{
	wxXmlNode *child = root.GetChildren();
	while (child != NULL)
	{
		if (child->GetName() == wxT("method"))
		{
			wxString name = XML::GetStringAttribute(*child, wxT("name"));
			wxString target = XML::GetStringAttribute(*child, wxT("target"));
			wxString type = XML::GetStringAttribute(*child, wxT("type"));
			Method *method = DeserializeMethod(*child);
			AddMethod(name, target, method);
		}
		child = child->GetNext();
	}
}
Exemplo n.º 16
0
 /// \brief Attempt to parse and dispatch the given event.
 ///
 virtual seec::Maybe<seec::Error> handle_impl(wxXmlNode &Event)
 {
   // First parse all attributes into the Values tuple.
   wxString ValueString;
   
   for (auto &Attr : Attributes) {
     if (!Event.GetAttribute(Attr->get_name(), &ValueString))
       return error_attribute(Attr->get_name());
     
     if (!Attr->from_string(Trace, ValueString.ToStdString()))
       return error_attribute(Attr->get_name());
   }
   
   dispatch_from_tuple(IndexSeqTy{});
   
   return seec::Maybe<seec::Error>();
 }
Exemplo n.º 17
0
void TwitterUser::ParseXmlNode(const wxXmlNode& node)
{
	wxXmlNode *child = node.GetChildren();
	while (child) {
		const wxString& tagName = child->GetName();
		wxString value = child->GetNodeContent();
		if (tagName == _T("id")) {
			id = strtoull(value.mb_str(), NULL, 10);
			// value.ToULongLong(&id); (GCC doesn't like this)
		}
		else if (tagName == _T("name")) {
			name = value;
		}
		else if (tagName == _T("screen_name")) {
			screen_name = value;
		}
		else if (tagName == _T("description")) {
			description = value;
		}
		else if (tagName == _T("location")) {
			location = value;
		}
		else if (tagName == _T("profile_image_url")) {
			profile_image_url = value;
		}
		else if (tagName == _T("url")) {
			url = value;
		}
		else if (tagName == _T("protected")) {
			protected_ = value == _T("true") ? true : false;
		}
		else if (tagName == _T("followers_count")) {
			value.ToULong(&followers_count);
		}

		child = child->GetNext();
	}
}
Exemplo n.º 18
0
void
MethodFixed::Deserialize(const wxXmlNode& root)
{
	m_what = root.GetNodeContent();
	Method::Deserialize(root);
}
Exemplo n.º 19
0
SelectionVOI::SelectionVOI( const wxXmlNode selObjNode, const wxString &rootPath )
: SelectionObject( selObjNode ),
  m_voiSize( 0 ),
  m_generationThreshold( 0.0f ),
  m_thresType( THRESHOLD_INVALID ),
  m_pIsoSurface( NULL ),
  m_sourceAnatIndex( 0 )
{
    m_objectType = VOI_TYPE;
    
    wxXmlNode *pChildNode = selObjNode.GetChildren();
    
    while( pChildNode != NULL )
    {
        wxString nodeName = pChildNode->GetName();
        wxString propVal;
        
        if( nodeName == wxT("voi_properties") )
        {
            double temp;
            pChildNode->GetAttribute( wxT("gen_threshold"), &propVal );
            propVal.ToDouble(&temp);
            m_generationThreshold = temp;
            
            pChildNode->GetAttribute( wxT("thres_op_type"), &propVal );
            m_thresType = Helper::getThresholdingTypeFromString( propVal );
            
            wxXmlNode *pAnatNode = pChildNode->GetChildren();
            if( pAnatNode->GetName() == wxT("generation_anatomy") )
            {
                wxString anatPath = pAnatNode->GetNodeContent();

                // Get full path, since this is how it is stored in the dataset.
                wxFileName fullAnatPath( rootPath + wxFileName::GetPathSeparator() + anatPath );
                               
                // Find the anatomy related to this file.
                vector< Anatomy* > anats = DatasetManager::getInstance()->getAnatomies();
                for( vector< Anatomy* >::iterator anatIt( anats.begin() ); anatIt != anats.end(); ++anatIt )
                {
                    if( (*anatIt)->getPath() == fullAnatPath.GetFullPath() )
                    {
                        m_sourceAnatIndex = (*anatIt)->getDatasetIndex();
                        break;
                    }
                }
                
                if( !m_sourceAnatIndex.isOk() )
                {
                    wxString err( wxT("Anatomy: ") );
                    err << anatPath << wxT(" does not exist when creating VOI called: ") << getName() << wxT(".");
                    throw  err;
                }
                
                Anatomy *pCurAnat = dynamic_cast< Anatomy* >( DatasetManager::getInstance()->getDataset( m_sourceAnatIndex ) );
                buildSurface( pCurAnat );
            }
        }
        
        pChildNode = pChildNode->GetNext();
    }
}
Exemplo n.º 20
0
void
MethodSameAs::Deserialize(const wxXmlNode& root)
{
	m_id = root.GetNodeContent();
	Method::Deserialize(root);
}