let the param of place.div be a string(#298)

This commit is contained in:
Jinhao 2018-06-07 03:33:39 +08:00
parent 24f9aa58a7
commit 0290e49fbe
2 changed files with 8 additions and 8 deletions

View File

@ -1,7 +1,7 @@
/* /*
* An Implementation of Place for Layout * An Implementation of Place for Layout
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -119,7 +119,7 @@ namespace nana
void splitter_renderer(std::function<void(window, paint::graphics&, mouse_action)> fn); void splitter_renderer(std::function<void(window, paint::graphics&, mouse_action)> fn);
void div(const char* s); ///< Divides the attached widget into fields. void div(std::string div_text); ///< Divides the attached widget into fields.
const std::string& div() const noexcept; ///< Returns div-text that depends on fields status. const std::string& div() const noexcept; ///< Returns div-text that depends on fields status.
void modify(const char* field_name, const char* div_text); ///< Modifies a specified field. void modify(const char* field_name, const char* div_text); ///< Modifies a specified field.

View File

@ -64,8 +64,8 @@ namespace nana
eof, error eof, error
}; };
tokenizer(const char* p) noexcept tokenizer(const char* div_text) noexcept
: divstr_(p), sp_(p) : divstr_(div_text), sp_(div_text)
{} {}
const std::string& idstr() const noexcept const std::string& idstr() const noexcept
@ -3180,9 +3180,9 @@ namespace nana
sp->set_renderer(impl_->split_renderer, true); sp->set_renderer(impl_->split_renderer, true);
} }
void place::div(const char* s) void place::div(std::string div_text)
{ {
place_parts::tokenizer tknizer(s); place_parts::tokenizer tknizer(div_text.c_str());
impl_->disconnect(); impl_->disconnect();
auto div = impl_->scan_div(tknizer); auto div = impl_->scan_div(tknizer);
try try
@ -3190,7 +3190,7 @@ namespace nana
impl_->connect(div.get()); //throws if there is a redefined name of field. impl_->connect(div.get()); //throws if there is a redefined name of field.
impl_->root_division.reset(); //clear atachments div-fields impl_->root_division.reset(); //clear atachments div-fields
impl_->root_division.swap(div); impl_->root_division.swap(div);
impl_->div_text.assign(s); impl_->div_text.swap(div_text);
} }
catch (...) catch (...)
{ {
@ -3321,7 +3321,7 @@ namespace nana
return *p; return *p;
} }
void update_div(std::string& div, const char* field, const char* attr, update_operation operation) static void update_div(std::string& div, const char* field, const char* attr, update_operation operation)
{ {
const auto fieldname_pos = find_idstr(div, field); const auto fieldname_pos = find_idstr(div, field);
if (div.npos == fieldname_pos) if (div.npos == fieldname_pos)