ItemOwn::ItemOwn(const char* name,
Decision decision,
const char* privilege)
- : __decision(DecisionItem(decision, privilege)), __name(name), __is_prefix(false) {
+ : __decision(DecisionItem(decision, privilege)), __is_prefix(false) {
+ setName(name);
+}
+
+void ItemOwn::setName(const char* name) {
+ if (name == nullptr) {
+ __name = "";
+ } else {
+ __name = name;
+ }
}
ItemType ItemOwn::getType() const {
}
const char* ItemOwn::toString(char* str) const {
- snprintf(str, MAX_LOG_LINE, "ItemOwn: service(%s), pref(%d)", __name, __is_prefix);
+ snprintf(str, MAX_LOG_LINE, "ItemOwn: service(%s), pref(%d)", __name.c_str(), __is_prefix);
return str;
}
const char* ItemOwn::getName() const {
- return __name;
+ if (__name == "") {
+ return nullptr;
+ }
+ return __name.c_str();
}
bool ItemOwn::isPrefix() const {
}
bool ItemOwn::isMatchAll() const {
- return __name == nullptr;
+ return __name == "";
}
const DecisionItem& ItemOwn::getDecision() const {
void ItemBuilder::addOwner(const char* owner) {
ItemOwn* o = getOwnItem();
- if (o->__name)
- delete o->__name;
- o->__name = duplicate(owner);
+ o->setName(owner);
}
void ItemBuilder::addName(const char* name) {