Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overloads with size_t type argument #537

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

stefanroellin
Copy link
Contributor

  • bool xml_attribute::set_name(const char_t* rhs, size_t sz)
  • xml_attribute xml_node::append_attribute(const char_t* name_, size_t sz)
  • xml_node xml_node::append_child(const char_t* name_, size_t sz)
  • xml_attribute xml_node::attribute(const char_t* name_, size_t sz) const
  • xml_node xml_node::child(const char_t* name_, size_t sz) const
  • bool xml_node::set_name(const char_t* rhs, size_t sz)

@zeux
Copy link
Owner

zeux commented Mar 3, 2023

What's the motivation for these? The change that added size_t support for value setup felt reasonable because value is rarely a compile-time literal, and it makes it easier to work with string_view-like inputs. Here I'm not sure that the use is going to be as frequent, and it's a substantial increase of the API surface especially if all other functions that deal with names are included.

@stefanroellin
Copy link
Contributor Author

I work a lot with std::string_view. Since the current interface mostly works with zero-terminated strings, it is not possible to use a std::string_view, since it is not necessarily zero-terminated. Adding the above overloads allows me to use std::string_view.
A solution like implemented in pull request #457 would make this patch obsolete and would suit my needs.

@zeux
Copy link
Owner

zeux commented Aug 24, 2023

I would be willing to merge a subset of this that only introduces set_name. The other additions can be replicated externally without allocations - it’s not always ideal, in particular append_attribute would need to be called with “” followed by set_name - but it’s clean and orthogonal.

Let me know if you’d like to rebase the PR with that subset.

@zeux
Copy link
Owner

zeux commented Aug 24, 2023

Oh also ideally these should be added to docs/manual.adoc although I can do this myself; I can also reduce the PR to a mergeable state myself in a few days if that’s ok.

@zeux zeux mentioned this pull request Aug 25, 2023
8 tasks
@stefanroellin
Copy link
Contributor Author

I can rebase the branch and add some documentation. Just to be sure: you will accept a pull request with the following two enhancements:

  • bool xml_attribute::set_name(const char_t* rhs, size_t sz)
  • bool xml_node::set_name(const char_t* rhs, size_t sz)

@zeux
Copy link
Owner

zeux commented Aug 25, 2023

Yup exactly. Thanks!

* bool xml_attribute::set_name(const char_t* rhs, size_t sz)
* bool xml_node::set_name(const char_t* rhs, size_t sz)
@stefanroellin
Copy link
Contributor Author

Branch rebased such that only the two methods

  • bool xml_attribute::set_name(const char_t* rhs, size_t sz)
  • bool xml_node::set_name(const char_t* rhs, size_t sz)

are included. Also added the methods to the documentation.

@zeux zeux merged commit 08a5048 into zeux:master Aug 26, 2023
21 checks passed
@zeux
Copy link
Owner

zeux commented Aug 26, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants