25 p_language (language),
26 p_prototype (prototype),
46 s <<
" Method implementation:\n"
49 " body: \"" << i.
get_body() <<
"\"\n";
87 s.throw_unexpected_attribute(attr.
name());
94 catch (std::exception & e) {
102 catch(std::exception& ex) {
111 p_implementations (nullptr)
116 catch(std::exception& ex) {
117 Oks::error_msg(
"OksMethod::OksMethod()") << ex.what() << std::endl;
124 p_description (desc),
125 p_implementations (nullptr)
149 if(
this == &m)
return true;
174 std::list<OksMethodImplementation *>::const_iterator i1 =
p_implementations->begin();
175 std::list<OksMethodImplementation *>::const_iterator i2 = m.p_implementations->begin();
178 if( !(*(*i1) == *(*i2)) )
return false;
187 s <<
"Method name: \"" << m.p_name <<
"\"\n"
188 " description: \"" << m.p_description <<
"\"\n";
190 if(m.p_implementations) {
191 s <<
" implementations:\n";
193 for(std::list<OksMethodImplementation *>::const_iterator i = m.p_implementations->begin(); i != m.p_implementations->end(); ++i)
197 s <<
" there are no implementation(s)\n";
231 p_implementations (0)
246 s.throw_unexpected_attribute(attr.
name());
253 catch (std::exception & e) {
262 catch(std::exception& ex) {
271 const char * tag_start = s.get_tag_start();
275 else if(!strcmp(tag_start,
"method-implementation")) {
281 std::ostringstream text;
282 text <<
"Unexpected tag \'" << tag_start <<
"\' inside method \'" <<
p_name <<
"\'\n";
283 throw std::runtime_error( text.str().c_str() );
290 catch (std::exception & e) {
302 if(
p_name == new_name)
return;
315 catch(std::exception& ex) {
323 std::ostringstream text;
324 text <<
"Class \"" <<
p_class->
get_name() <<
"\" already has direct method \"" << new_name <<
'\"';
358 if(language == (*i)->get_language())
return *i;
368 std::ostringstream text;
369 text <<
"Cannot add implementation on language \"" << language <<
"\" since it already exists.";
393 std::ostringstream text;
394 text <<
"Cannot remove implementation on language \"" << language <<
"\" since it does not exist.";
429 std::ostringstream text;
430 text <<
"cannot rename \"" <<
p_method->
p_name <<
"\" method implementation to language \"" << s <<
"\" "
431 "since the method already has implementation with such language.";
438 catch(std::exception& ex) {
460 catch(std::exception& ex) {
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
void registrate_class_change(ChangeType, const void *, bool=true)
const std::string & get_name() const noexcept
void lock_file(const char *)
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
@ ChangeMethodDescription
@ ChangeMethodImplementation
OKS method implementation class.
const std::string & get_body() const noexcept
OksMethodImplementation(const std::string &language, const std::string &prototype, const std::string &body, OksMethod *p=nullptr)
OKS method implementation constructor.
const std::string & get_language() const noexcept
void set_prototype(const std::string &prototype)
Set method implementation prototype.
const std::string & get_prototype() const noexcept
void set_language(const std::string &language)
Set method implementation language.
bool operator==(const class OksMethodImplementation &) const
static const char prototype_xml_attr[]
void save(OksXmlOutputStream &) const
static const char language_xml_attr[]
void set_body(const std::string &body)
Set method implementation body.
static const char body_xml_attr[]
static const char method_impl_xml_tag[]
void set_name(const std::string &name)
Set method name.
static const char name_xml_attr[]
static const char description_xml_attr[]
static const char method_xml_tag[]
void set_description(const std::string &description)
Set method description.
void add_implementation(const std::string &language, const std::string &prototype, const std::string &body)
Add method implementation.
void remove_implementation(const std::string &language)
Remove method implementation.
bool operator==(const class OksMethod &) const
friend class OksMethodImplementation
OksMethodImplementation * find_implementation(const std::string &language) const
Find method implementation.
std::list< OksMethodImplementation * > * p_implementations
void save(OksXmlOutputStream &) const
std::string p_description
OksMethod(const std::string &name, OksClass *p=nullptr)
OKS method constructor.
static std::ostream & error_msg(const char *)
virtual const char * what() const noexcept
bool cmp_str8(const char *s1, const char s2[9])
bool cmp_str1(const char *s1, const char s2[2])
bool cmp_str4(const char *s1, const char s2[5])
bool cmp_str9(const char *s1, const char s2[10])
void validate_not_empty(const std::string &value, const char *name)
std::ostream & operator<<(std::ostream &s, const oks::exception &ex)
bool cmp_str11(const char *s1, const char s2[12])
bool cmp_str7(const char *s1, const char s2[8])