51 s <<
" Method implementation:\n"
54 " body: \"" << i.
get_body() <<
"\"\n";
92 s.throw_unexpected_attribute(attr.
name());
99 catch (std::exception & e) {
107 catch(std::exception& ex) {
121 catch(std::exception& ex) {
122 Oks::error_msg(
"OksMethod::OksMethod()") << ex.what() << std::endl;
154 if(
this == &m)
return true;
179 std::list<OksMethodImplementation *>::const_iterator i1 =
p_implementations->begin();
180 std::list<OksMethodImplementation *>::const_iterator i2 = m.p_implementations->begin();
183 if( !(*(*i1) == *(*i2)) )
return false;
192 s <<
"Method name: \"" << m.p_name <<
"\"\n"
193 " description: \"" << m.p_description <<
"\"\n";
195 if(m.p_implementations) {
196 s <<
" implementations:\n";
198 for(std::list<OksMethodImplementation *>::const_iterator i = m.p_implementations->begin(); i != m.p_implementations->end(); ++i)
202 s <<
" there are no implementation(s)\n";
251 s.throw_unexpected_attribute(attr.
name());
258 catch (std::exception & e) {
267 catch(std::exception& ex) {
276 const char * tag_start = s.get_tag_start();
280 else if(!strcmp(tag_start,
"method-implementation")) {
286 std::ostringstream text;
287 text <<
"Unexpected tag \'" << tag_start <<
"\' inside method \'" <<
p_name <<
"\'\n";
288 throw std::runtime_error( text.str().c_str() );
295 catch (std::exception & e) {
307 if(
p_name == new_name)
return;
320 catch(std::exception& ex) {
327 if(
p_class->find_direct_method(new_name) != 0) {
328 std::ostringstream text;
329 text <<
"Class \"" <<
p_class->get_name() <<
"\" already has direct method \"" << new_name <<
'\"';
336 p_class->lock_file(
"OksMethod::set_name");
363 if(language == (*i)->get_language())
return *i;
373 std::ostringstream text;
374 text <<
"Cannot add implementation on language \"" << language <<
"\" since it already exists.";
398 std::ostringstream text;
399 text <<
"Cannot remove implementation on language \"" << language <<
"\" since it does not exist.";
403 if(
p_class)
p_class->lock_file(
"OksMethod::remove_implementation");
433 if(
p_method->find_implementation(s) != 0) {
434 std::ostringstream text;
435 text <<
"cannot rename \"" <<
p_method->p_name <<
"\" method implementation to language \"" << s <<
"\" "
436 "since the method already has implementation with such language.";
443 catch(std::exception& ex) {
447 if(
p_method->p_class)
p_method->p_class->lock_file(
"OksMethodImplementation::set_language");
465 catch(std::exception& ex) {
@ 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])