Beispiel #1
0
void Character::loadXML(pugi::xml_node node)
{
  inGameName = node.child_value("name");
  health = atoi(node.child_value("health"));
  maxHealth = health;
  damage = atoi(node.child_value("damage"));
  experience = atoi(node.child_value("experience"));
  attackspeed = atoi(node.child_value("attackspeed"));
  std::cout << inGameName << " " << health << " " << damage << std::endl;
}
void Init::parseDispersion(const pugi::xml_node &node)
{
    
    cout << "Dispersion:" << endl;
    string filename = node.child_value("filename");
    string filetype = node.child_value("filetype");
    
    SpinWaveDispersion Dispersion;
    Dispersion.setFilename(filename);
    
    SpinWaveDispersion::Options PrintOptions;
    string temp;
    bool value;
    
    temp = node.child("filetype").child_value("printposition");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintPosition;
    cout << "print position: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    temp = node.child("filetype").child_value("printfrequency");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintFrequency;
    cout << "print frequency: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    temp = node.child("filetype").child_value("printintensity");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintIntensity;
    cout << "print intensity: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    pugi::xml_node lines = node.child("lines");
    for (pugi::xml_node group = lines.child("group");group; group = group.next_sibling("group"))
    {
        double x0,y0,z0,x1,y1,z1,NumberPoints;
        
        NumberPoints = stringToDouble(group.child_value("numberpoints"));
        x0 = stringToDouble(group.child("firstpoint").child_value("x"));
        y0 = stringToDouble(group.child("firstpoint").child_value("y"));
        z0 = stringToDouble(group.child("firstpoint").child_value("z"));
        x1 = stringToDouble(group.child("lastpoint").child_value("x"));
        y1 = stringToDouble(group.child("lastpoint").child_value("y"));
        z1 = stringToDouble(group.child("lastpoint").child_value("z"));
        
        cout << x0 << " " << y0 << " " << z0 << " " << x1 << " " << y1 << "  " << z1 << endl;
        
        PointsAlongLine Line;
        Line.setFirstPoint(x0,y0,z0);
        Line.setFinalPoint(x1,y1,z1);
        Line.setNumberPoints(NumberPoints);
        Dispersion.setPoints(Line.getPoints());
    }
    
    Dispersion.setGenie(builder.createElement());
    Dispersion.save();
}
void GLShaderSource::addParameterFromXmlNode(pugi::xml_node xmlNode)
{
    auto nameTemplate = xmlNode.child_value("name");
    auto name = fmt::format("{}_{{}}_{}", mName, nameTemplate);

    auto parameterTypeTemplate = xmlNode.child_value("type");
    auto parameterType = PARAM_STR_TO_TYPE[parameterTypeTemplate];

    // TODO: Abort if no call node is available
    auto callTemplate = xmlNode.child_value("call");
    auto call = fmt::format(callTemplate, name);

    auto builtinTemplate = xmlNode.child_value("builtin");
    auto builtin = BUILTIN_STR_TO_TYPE[builtinTemplate];

    GLShaderObjectParameter param;
    param.name = name;
    param.parameterType = parameterType;
    param.call = call;
    param.builtinType = builtin;
    mParameters.push_back(param);
    
    spdlog::get("qde")->debug("ShaderSource {}: Found parameter {}", mName, param.name);
}
Beispiel #4
0
void XMLFile::PatchReplace(const pugi::xml_node& patch, pugi::xpath_node& original) const
{
    // If no attribute but node then its a node, otherwise its an attribute or null
    if (!original.attribute() && original.node())
    {
        pugi::xml_node parent = original.node().parent();

        parent.insert_copy_before(patch.first_child(), original.node());
        parent.remove_child(original.node());
    }
    else if (original.attribute())
    {
        original.attribute().set_value(patch.child_value());
    }
}
Beispiel #5
0
void XMLFile::AddAttribute(const pugi::xml_node& patch, const pugi::xpath_node& original) const
{
    pugi::xml_attribute attribute = patch.attribute("type");

    if (!patch.first_child() && patch.first_child().type() != pugi::node_pcdata)
    {
        URHO3D_LOGERRORF("XML Patch failed calling Add due to attempting to add non text to an attribute for %s.", attribute.value());
        return;
    }

    String name(attribute.value());
    name = name.Substring(1);

    pugi::xml_attribute newAttribute = original.node().append_attribute(name.CString());
    newAttribute.set_value(patch.child_value());
}
Beispiel #6
0
Math::Vec3 PugiHelper::ParseVec3( const pugi::xml_node& node )
{
	// Parse vector elements (in double)
	std::vector<double> v;
	std::stringstream ss(node.child_value());

	double t;
	while (ss >> t) v.push_back(t);
	if (v.size() != 3)
	{
		LM_LOG_WARN("Invalid number of elements in '" + std::string(node.name()) + "'");
		return Math::Vec3();
	}

	// Convert type and return
	return Math::Vec3(Math::Float(v[0]), Math::Float(v[1]), Math::Float(v[2]));
}
Beispiel #7
0
Math::Mat4 PugiHelper::ParseMat4( const pugi::xml_node& node )
{
	// Parse matrix elements (in double)
	std::vector<double> m;
	std::stringstream ss(node.child_value());

	double t;
	while (ss >> t) m.push_back(t);
	if (m.size() != 16)
	{
		LM_LOG_WARN("Invalid number of elements in '" + std::string(node.name()) + "'");
		return Math::Mat4::Identity();
	}

	// Convert to Float and create matrix
	std::vector<Math::Float> m2(16);
	std::transform(m.begin(), m.end(), m2.begin(), [](double v){ return Math::Float(v); });
	return Math::Mat4(&m2[0]);
}
Beispiel #8
0
	void XMLFileParser::AddChild(XMLContainer & parent, const pugi::xml_node & node)
	{
		std::shared_ptr<XMLContainer> child(new XMLContainer());
		AddAttributes(*(child.get()), node);
		child->SetName(star::string_cast<tstring>(node.name()));
		child->SetValue(star::string_cast<tstring>(node.child_value()));
		auto sibling = node.first_child();
		if(sibling != NULL)
		{
			do 
			{
				AddChild(*(child.get()), sibling);
				sibling = sibling.next_sibling();
			} while (sibling != NULL);
		}
		if(child->GetName() != EMPTY_STRING)
		{
			parent.insert(std::make_pair(star::string_cast<tstring>(node.name()), child));
		}
	}
void configuration_parser::name_parser(const pugi::xml_node& doc)
{
   results.back().name.push_back(doc.child_value());
}
void Init::parseTwoDimensionCut(const pugi::xml_node &node)
{
    
    cout << "Two Dimension Cut:" << endl;
    string filename = node.child_value("filename");
    string filetype = node.child_value("filetype");
    
    TwoDimensionCut Cut;
    Cut.setFilename(filename);
    
    cout << filename << endl;
    
    {
        pugi::xml_node group = node.child("setkpoints");
        double x0,y0,z0,x1,y1,z1,NumberPoints;
        string temp;
        
        NumberPoints = stringToDouble(group.child_value("numberpoints"));
        x0 = stringToDouble(group.child("firstpoint").child_value("x"));
        y0 = stringToDouble(group.child("firstpoint").child_value("y"));
        z0 = stringToDouble(group.child("firstpoint").child_value("z"));
        x1 = stringToDouble(group.child("lastpoint").child_value("x"));
        y1 = stringToDouble(group.child("lastpoint").child_value("y"));
        z1 = stringToDouble(group.child("lastpoint").child_value("z"));
        
        cout << x0 << " " << y0 << " " << z0 << " " << x1 << " " << y1 << "  " << z1 << endl;
        
        PointsAlongLine Line;
        Line.setFirstPoint(x0,y0,z0);
        Line.setFinalPoint(x1,y1,z1);
        Line.setNumberPoints(NumberPoints);
        Cut.setPoints(Line.getPoints());
        

    }
        
    {
        pugi::xml_node group = node.child("setenergypoints");
        double MinEnergy,MaxEnergy,NumberPoints;
        string temp;
        
        NumberPoints = stringToDouble(group.child_value("numberpoints"));
        MinEnergy = stringToDouble(group.child_value("firstpoint"));
        MaxEnergy = stringToDouble(group.child_value("lastpoint"));
        
        cout << MinEnergy << " " << MaxEnergy << " " << NumberPoints << endl;
        
        PointsAlongLine Line;

        pugi::xml_node type = node.child("type");
        
        pugi::xml_node Gaussian = type.child("OneDimensionGaussian");
        pugi::xml_node Lorentzian = type.child("OneDimensionLorentzian");
        pugi::xml_node PseudoVoigt = type.child("OneDimensionPseudoVoigt");
        
        OneDimensionalFactory factory;
        
        unique_ptr<OneDimensionalShapes> resinfo;
        
        if (Gaussian)
        {
            double fwhm,tolerance;
            fwhm = stringToDouble(Gaussian.child_value("fwhm"));
            tolerance = stringToDouble(Gaussian.child_value("tol"));
            
            resinfo = factory.getGaussian(fwhm,tolerance);
            cout << "Gaussian resolution function set" << endl;
        }
        else if(Lorentzian)
        {
            double fwhm,tolerance;
            fwhm = stringToDouble(Lorentzian.child_value("fwhm"));
            tolerance = stringToDouble(Lorentzian.child_value("tol"));

            resinfo = factory.getLorentzian(fwhm,tolerance);
            
            cout << "Lorentzian resolution function set" << endl;
        }
        else if(PseudoVoigt)
        {
            double eta,fwhm,tolerance;
            eta = stringToDouble(PseudoVoigt.child_value("eta"));
            fwhm = stringToDouble(PseudoVoigt.child_value("fwhm"));
            tolerance = stringToDouble(PseudoVoigt.child_value("tol"));
            
            resinfo = factory.getPseudoVoigt(eta,fwhm,tolerance);
            
            cout << "Pseudo-Voigt resolution function set" << endl;
        }
        else
        {
            cout << "RESOLUTION FUNCTION NOT SET!!!" << endl;
        }
        
        SpinWave SW = builder.createElement();
        unique_ptr<SpinWavePlot> res(new EnergyResolutionFunction(move(resinfo), SW, Energies(MinEnergy, MaxEnergy, NumberPoints)));
        Cut.setPlotObject(move(res));
        Cut.setEnergyPoints(MinEnergy,MaxEnergy,NumberPoints);
    }
    Cut.save();


}
Beispiel #11
0
			float xf = (float)pos_x;
			float yf = (float)pos_y;

			positions.push_back( xf );
			positions.push_back( yf );
		}
		else
		{
			break;
		}
	}

	pugi::xml_node xml_verticesUV = doc.first_element_by_path( "TextureAtlas/sprite/verticesUV" );

	const char * verticesUV = xml_verticesUV.child_value();

	if( width < 0.f )
	{
		width = (float)w;
	}

	if( height < 0.f )
	{
		height = (float)h;
	}

	std::stringstream ss_verticesUV( verticesUV );

	std::vector<float> uvs;
Beispiel #12
0
Core::Core(const pugi::xml_node &input,
           const std::map<int, UP_Assembly_t> &assemblies)
    : nx_(input.attribute("nx").as_int(0)), ny_(input.attribute("ny").as_int(0))
{
    // Make sure that we read the a proper ID
    if ((nx_ < 1) | (ny_ < 1)) {
        throw EXCEPT("Invalid core dimensions.");
    }

    // Read in the boundary conditions
    bc_[(int)Surface::NORTH]  = bc_parse(input, "north");
    bc_[(int)Surface::SOUTH]  = bc_parse(input, "south");
    bc_[(int)Surface::EAST]   = bc_parse(input, "east");
    bc_[(int)Surface::WEST]   = bc_parse(input, "west");
    bc_[(int)Surface::TOP]    = bc_parse(input, "top");
    bc_[(int)Surface::BOTTOM] = bc_parse(input, "bottom");

    for (int i = 0; i < 6; i++) {
        if (bc_[i] == Boundary::INVALID) {
            throw EXCEPT("Not all boundary conditions properly specified.");
        }
    }

    // Read in the assembly IDs
    std::string asy_str = input.child_value();

    VecI asy_vec;
    try {
        asy_vec = explode_string<int>(asy_str);
    } catch (Exception e) {
        std::cerr << e.what() << std::endl;
        throw EXCEPT("Failed to read assembly IDs");
    }

    if (asy_vec.size() != nx_ * ny_) {
        throw EXCEPT("Wrong number of assemblies specified for core.");
    }

    // Store references to the assemblies in a 2D array. Make sure to flip
    // the y-index to get it into lower-left origin
    assemblies_.resize(nx_ * ny_);

    int iasy = 0;
    for (unsigned int iy = 0; iy < ny_; iy++) {
        unsigned int row = ny_ - iy - 1;
        for (unsigned int ix = 0; ix < nx_; ix++) {
            unsigned int col = ix;
            int asy_id       = asy_vec[iasy++];
            try {
                Assembly *asy_p              = assemblies.at(asy_id).get();
                assemblies_[row * nx_ + col] = asy_p;
            } catch (std::out_of_range) {
                throw EXCEPT("Failed to locate assembly in core "
                             "specification.");
            }
        }
    }

    // Check to make sure that the assemblies all fit together
    // We will rely on the Assemblies compatible() method. Since Assembly
    // compatibility is transitive, checking any one assembly against all others
    // should be sufficient to determine compatibility between all assemblies.
    for( const auto &asy: assemblies_) {
        if(!assemblies_.front()->compatible(*asy)) {
            throw EXCEPT("Assemblies in the core are not compatible.");
        }
    }

    // Get the total number of pins along each dimension
    npinx_ = 0;
    for (unsigned int i = 0; i < nx_; i++) {
        npinx_ += this->at(i, 0).nx();
    }
    npiny_ = 0;
    for (unsigned int i = 0; i < ny_; i++) {
        npiny_ += this->at(0, i).ny();
    }

    // Store the x and y boundaries of the assemblies
    real_t prev = 0.0;
    for (unsigned int ix = 0; ix < nx_; ix++) {
        hx_vec_.push_back(prev + this->at(ix, 0).hx());
        prev = hx_vec_[ix];
    }
    prev = 0.0;
    for (unsigned int iy = 0; iy < ny_; iy++) {
        hy_vec_.push_back(prev + this->at(0, iy).hy());
        prev = hy_vec_[iy];
    }
}
Beispiel #13
0
 const char* get_value() const {
     return m_node.child_value();
 }
void configuration_parser::linker_executable_parser(const pugi::xml_node& doc)
{
   results.back().linker_executable = doc.child_value();
}
Beispiel #15
0
wxString GetTextElement(pugi::xml_node node, const char* name)
{
	wxASSERT(node);

	return ConvLocal(node.child_value(name));
}
Beispiel #16
0
wxString GetTextElement(pugi::xml_node node)
{
	wxASSERT(node);

	return ConvLocal(node.child_value());
}
 void setResponseFields(CoreResponse* response, const pugi::xml_node& msg) const {
     response->setSuccessful(boost::lexical_cast<bool>(msg.child_value("successful")));
     response->setErrorCode(msg.child_value("errorCode"));
     response->setErrorMessage(msg.child_value("errorMessage"));
 }
std::wstring GetTextElement(pugi::xml_node node)
{
	wxASSERT(node);

	return fz::to_wstring_from_utf8(node.child_value());
}
void configuration_parser::linking_command_parser(const pugi::xml_node& doc)
{
   results.back().linking_command = doc.child_value();
}
void configuration_parser::output_directory_parser(const pugi::xml_node& doc)
{
   results.back().output_directory = doc.child_value();
}
XIBObjectFloat::XIBObjectFloat(pugi::xml_node node)
{
    _val = strtod(node.child_value(), NULL);
    _node = node;
}