Sivelkiria Operating System repository

Commit 6d13a5e8 authored by Alexey's avatar Alexey
Browse files

add doxygen description to sdkbuilder.hpp

parent c4a4262d
......@@ -19,11 +19,10 @@ sdkbuilder::sdkbuilder(
generate_interface_body( _interface_parser, class_name );
if ( _interface_parser->minor != "0" )
class_name+= "_" + _interface_parser->minor;
std::string file_name= build_dir + class_name + ".hpp";
construct(
_interface_parser->description_template_names,
_interface_parser->templates, _interface_parser->has_template,
"class", class_name, body, file_name );
"class", class_name, body);
delete _interface_parser;
} else if ( it->first == "Structure" ) {
_struct_parser= new struct_parser( it->second.c_str() );
......@@ -33,11 +32,9 @@ sdkbuilder::sdkbuilder(
std::string body= generate_struct_body( _struct_parser, struct_name );
if ( _interface_parser->minor != "0" )
struct_name+= "_" + _struct_parser->minor;
std::string file_name= build_dir + struct_name + ".hpp";
construct(
_struct_parser->description_template_names, _struct_parser->templates,
_struct_parser->has_template, "struct", struct_name, body,
file_name );
_struct_parser->has_template, "struct", struct_name, body);
delete _struct_parser;
}
}
......@@ -47,8 +44,7 @@ void sdkbuilder::construct(
const std::vector<std::string> &descr_templ,
const std::vector<std::pair<std::string, std::string>> &templ,
const bool &has_template, const std::string type_obj,
const std::string normal_name, const std::string &body,
const std::string file_name ) {
const std::string name, const std::string &body) {
std::string _templ;
std::string description_template;
if ( has_template ) {
......@@ -67,18 +63,17 @@ void sdkbuilder::construct(
_templ.back()= ' '; //вставляем вместо последней запятой
_templ+= ">\n" + description_template;
}
construct_hpp( file_name, _templ, type_obj, body, normal_name );
construct_hpp(_templ, type_obj, body, name );
}
void sdkbuilder::construct_hpp(
const std::string file_name, const std::string _template,
const std::string type_obj, const std::string &body,
const std::string &name ) {
std::ofstream hpp_file( file_name );
const std::string _template, const std::string type_obj,
const std::string &body,const std::string &name ) {
std::ofstream hpp_file( build_dir + name + ".hpp" );
hpp_file << "namespace SivDK{\n" << "namespace ";
if(type_obj == "class")
hpp_file << "Interfaces";
else if (type_obj == "struct");
else if (type_obj == "struct")
hpp_file << "Structures";
else
hpp_file << "Error";
......@@ -123,22 +118,6 @@ std::string sdkbuilder::generate_interface_body(
return body;
}
void sdkbuilder::write_args(
std::string &body, std::vector<method>::const_iterator &it ) {
for ( std::vector<std::pair<_arg, std::pair<std::string, std::string> *>>::
const_iterator gt= it->args.begin();
gt != it->args.end(); ++gt ) {
body+= " ";
if ( gt->first.mode == "in" )
body+= "const "; //но это не защитит-напр const int *p - данные можно
//менять
body+= gt->first.type + " ";
if ( gt->first.mode != "in" ) body+= "&";
body+= gt->first.name + ",";
}
body= body.substr( 0, body.size() - 2 ); //удаляем последнюю запятую
}
std::string sdkbuilder::generate_struct_body(
const struct_parser *_struct_parser, const std::string normal_name ) {
std::string code;
......@@ -159,3 +138,19 @@ std::string sdkbuilder::generate_struct_body(
}
return code;
}
void sdkbuilder::write_args(
std::string &body, std::vector<method>::const_iterator &it ) {
for ( std::vector<std::pair<_arg, std::pair<std::string, std::string> *>>::
const_iterator gt= it->args.begin();
gt != it->args.end(); ++gt ) {
body+= " ";
if ( gt->first.mode == "in" )
body+= "const "; //но это не защитит-напр const int *p - данные можно
//менять
body+= gt->first.type + " ";
if ( gt->first.mode != "in" ) body+= "&";
body+= gt->first.name + ",";
}
body= body.substr( 0, body.size() - 2 ); //удаляем последнюю запятую
}
......@@ -5,28 +5,68 @@
#include "libs/struct_parser.hpp"
#include <fstream>
/*\brief class for generate sdk
*\details it's generator sdk from xml
*\date 05.2020
*/
class sdkbuilder {
std::string build_dir= "./";
/*\brief write sdk
*\details wrtite sdk to build_dir folder
*\date 05.2020
*\param [in] descr_templ all descriptions of templates
*\param [in] templ all templates with default values
*\param [in] has_template flag indicate "is there a template?"
*\param [in] type_obj struct or class
*\param [in] normal_name name with him major and sometimes minor
*\param [in] body body of object
*\return void
*/
void construct(
const std::vector<std::string> &descr_templ,
const std::vector<std::pair<std::string, std::string>> &templ,
const bool &has_template, const std::string type_obj,
const std::string normal_name, const std::string &body,
const std::string filename );
const std::string name, const std::string &body);
/*\brief write hpp file
*\details write to build_dir/objname.hpp
*\param [in] _template template code
*\param [in] type_obj struct or class
*\param [in] body body of object
*\param [in] name name of object
*\return void
*/
void construct_hpp(
const std::string filename, const std::string _template,
const std::string type_obj, const std::string &body,
const std::string &normal_name );
const std::string _template, const std::string type_obj,
const std::string &body, const std::string &name );
/*\brief generate interface body
*\param [in] _interface_parser interface_parser object
*\param [in] normal_name name with him major and sometimes minor
*\return void
*/
std::string generate_interface_body(
const interface_parser *_interface_parser,
const std::string normal_name );
/*\brief generate structure body
*\param [in] _struct_parser struct_parser object
*\param [in] normal_name name with him major and sometimes minor
*\return void
*/
std::string generate_struct_body(
const struct_parser *_struct_parser, const std::string normal_name );
/*\brief write args to file
*\details write to file type1 arg1, type2 arg2,...
*\param [out] file reference to filestream object
*\param [in] it iterator for this method for foreach args
*\return void
*/
void write_args( std::string &file, std::vector<method>::const_iterator &it );
public:
/*\brief constructor
*\param [in] interfaces_filenames pairs (type, filename), where type - Interface or Structure
*\param [in] out_path folder for result files
*\return sdkbuilder
*/
sdkbuilder(
const std::vector<std::pair<std::string, std::string>>
&interfaces_filenames,
......
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