Sivelkiria Operating System repository

Commit bebf4742 authored by Alexey's avatar Alexey
Browse files

add typeParser

parent e2f7fbc8
namespace SivDK { namespace Interface {
template <
class arg_type= Primitive.Int32 .0, class res_type= Primitive.Int64 .0>
/*
*arg_type -
type for arguments
Default:Primitive.Int32.0
*res_type -
type for result
Default:Primitive.Int64.0
*/
class ExampleCalculator_0 : public virtual SivDK::Object {
protected:
ExampleCalculator_0( SivDK::interface_handle handle );
ExampleCalculator_0();
public:
virtual ~ExampleCalculator_0()= default;
template <
class arg_type= Primitive.Int32 .0, class res_type= Primitive.Int64 .0>
/*
*arg_type -
type for arguments
Default:Primitive.Int32.0
*res_type -
type for result
Default:Primitive.Int64.0
*/
class ExampleCalculator_0_1 : public virtual ExampleCalculator_0 {
protected:
ExampleCalculator_0_1( SivDK::interface_handle handle );
ExampleCalculator_0_1();
public:
virtual ~ExampleCalculator_0_1()= default;
/*
it can sum something
return_type:
it's a sum of a and b
*/
virtual res_type sum( const arg_type a, const arg_type b )= 0;
/*
it can add
return_type:
*/
virtual Primitive.Void .0 add( arg_type &dst, const arg_type src )= 0;
}
}
}} // namespace SivDK::Interface
#include "typeParser.hpp"
using namespace Sivelkiria::sdkBuilder;
typeParser::typeParser( const std::string &filename ) {
doc.LoadFile( filename.c_str() );
tinyxml2::XMLElement *ptr= doc.FirstChildElement();
if ( ptr != nullptr ) {
const char *name= ptr->FirstChildElement( "name" )->GetText();
if ( name != nullptr ) this->name= std::string( name );
const char *major= ptr->FirstChildElement( "version-major" )->GetText();
if ( major != nullptr ) this->major= std::stoi( std::string( major ) );
const char *bitness= ptr->FirstChildElement( "bitness" )->GetText();
if ( bitness != nullptr )
this->bitness= std::stoi( std::string( bitness ) );
const char *isInt= ptr->FirstChildElement( "integer" )->GetText();
if ( isInt != nullptr ) {
if ( std::string( isInt ) == "true" ) this->isInt= true;
else if ( std::string( isInt ) == "false" )
this->isInt= false;
else
; // error
}
const char *isSigned= ptr->FirstChildElement( "signed" )->GetText();
if ( isSigned != nullptr ) {
if ( std::string( isSigned ) == "true" ) this->isSigned= true;
else if ( std::string( isSigned ) == "false" )
this->isSigned= false;
else
; // error
}
const char *description= ptr->FirstChildElement( "description" )->GetText();
if ( description != nullptr ) {
this->description= std::string( description );
}
}
}
\ No newline at end of file
#pragma once
#include "../../3rdparty/tinyxml2/tinyxml2.h"
#include <string>
namespace Sivelkiria { namespace sdkBuilder {
/*\brief class for parse sdk type from xml
*\date 05.2020
*/
class typeParser {
public:
std::string name;
uint32_t major;
uint32_t bitness;
bool isInt;
bool isSigned;
std::string description;
/*\brief constructor of sdk type from xml
*\date 05.2020
*\param [in] filename
*\return typeParser
*/
explicit typeParser( const std::string &filename );
private:
tinyxml2::XMLDocument doc;
};
}} // namespace Sivelkiria::sdkBuilder
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment