Updated the channel edit and create functions
This commit is contained in:
parent
2cc8a42ce7
commit
5b74992beb
@ -192,9 +192,11 @@ std::shared_ptr<BasicChannel> BasicChannelTree::findChannel(ChannelId channelId,
|
||||
|
||||
|
||||
std::shared_ptr<BasicChannel> BasicChannelTree::findChannel(const std::string &name, const shared_ptr<BasicChannel> &layer) {
|
||||
for (auto elm : this->channels())
|
||||
if (elm->name() == name && elm->parent() == layer)
|
||||
for (auto elm : this->channels()) {
|
||||
if (elm->name() == name && elm->parent() == layer) {
|
||||
return elm;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,8 @@ const std::vector<ErrorType> ts::avariableErrors = {
|
||||
{0x0310, "channel_is_deleted" , "target channel is deleted" },
|
||||
{0x0311, "channel_name_invalid" , "channel name is invalid" },
|
||||
{0x0312, "channel_limit_reached" , "the virtualserver channel limit has been reached" },
|
||||
define_error_description(channel_family_not_visible, "the channel family isn't visible by default"),
|
||||
define_error_description(channel_default_require_visible, "the channel family contains the default channel"),
|
||||
|
||||
{0x0400, "server_invalid_id" , "invalid serverID" },
|
||||
{0x0401, "server_running" , "server is running" },
|
||||
|
@ -76,6 +76,9 @@ namespace ts {
|
||||
channel_is_deleted = 0x310,
|
||||
channel_name_invalid = 0x311,
|
||||
channel_limit_reached = 0x312,
|
||||
|
||||
channel_family_not_visible = 0x320,
|
||||
channel_default_require_visible = 0x321,
|
||||
|
||||
server_invalid_id = 0x400,
|
||||
server_running = 0x401,
|
||||
|
@ -127,7 +127,7 @@ property_list = std::array<PropertyDescription, impl::property_count()>{
|
||||
PropertyDescription{CHANNEL_MAXCLIENTS, "channel_maxclients", "-1", TYPE_SIGNED_NUMBER, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_MAXFAMILYCLIENTS, "channel_maxfamilyclients", "-1", TYPE_SIGNED_NUMBER, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_ORDER, "channel_order", "0", TYPE_UNSIGNED_NUMBER, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_FLAG_PERMANENT, "channel_flag_permanent", "1", TYPE_BOOL, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_FLAG_PERMANENT, "channel_flag_permanent", "0", TYPE_BOOL, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_FLAG_SEMI_PERMANENT, "channel_flag_semi_permanent", "0", TYPE_BOOL, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_FLAG_DEFAULT, "channel_flag_default", "0", TYPE_BOOL, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
PropertyDescription{CHANNEL_FLAG_PASSWORD, "channel_flag_password", "0", TYPE_BOOL, FLAG_CHANNEL_VIEW | FLAG_SS | FLAG_USER_EDITABLE}, //Available for all channels that are "in view", always up-to-date
|
||||
|
@ -97,6 +97,19 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void expect_value_as(const std::string_view& key) const {
|
||||
static_assert(converter<T>::supported, "Target type isn't supported!");
|
||||
static_assert(!converter<T>::supported || converter<T>::from_string_view, "Target type dosn't support parsing");
|
||||
|
||||
auto value = this->value(key);
|
||||
try {
|
||||
converter<T>::from_string_view(value);
|
||||
} catch (std::exception& ex) {
|
||||
throw command_value_cast_failed{this->key_command_character_index(key), std::string{key}, value, typeid(T)};
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] inline size_t command_character_index() const { return this->abs_index; }
|
||||
[[nodiscard]] inline size_t key_command_character_index(const std::string_view& key) const {
|
||||
size_t begin{0};
|
||||
|
Loading…
x
Reference in New Issue
Block a user