fipa_acl  1.4
userdef_param.cpp
Go to the documentation of this file.
1 
10 #include "userdef_param.h"
11 #include "acl_message.h"
12 #include <stdexcept>
13 
14 namespace fipa {
15 namespace acl {
16 
18  : mName()
19  , mValue()
20 {
21 }
22 
23 UserdefParam::UserdefParam(const std::string& name, const std::string& value)
24  : mName(name)
25  , mValue(value)
26 {
27 }
28 
30 {
31  if(this != &other)
32  {
33  mName = other.mName;
34  mValue = other.mValue;
35  }
36 
37  return *this;
38 }
39 
40 bool UserdefParam::operator==(const UserdefParam& other) const
41 {
42  return mName == other.mName && mValue == other.mValue;
43 }
44 
45 void UserdefParam::setName(const std::string& name)
46 {
47  if ( (name.find_first_of(illegalWordChars) != std::string::npos) || (illegalWordStart.find_first_of(name.c_str()[0]) != std::string::npos) )
48  {
49  throw std::runtime_error("Illegal name for userdefined-parameter");
50  }
51  mName = name;
52 }
53 
54 std::string UserdefParam::toString() const
55 {
56  return mName + ": " + mValue;
57 }
58 
59 }//end of acl namespace
60 }// end of fipa namespace
61 
bool operator==(const UserdefParam &other) const
const std::string illegalWordStart
Definition: acl_message.cpp:40
UserdefParam & operator=(const UserdefParam &other)
describes the general data structure of a message in conformity with the fipa specifications. The methods are pretty straight forward getter and setter methods. The set container is used for various colective fields, in order to avoid duplicates
void setName(const std::string &name)
the method checks whether the passed name string is a word or not(according to the fipa spec) ...
overloaded equality operator for UserdefParam class objects
Definition: userdef_param.h:25
std::string toString() const
const std::string illegalWordChars
Definition: acl_message.cpp:39
defines the UserdefParam class