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 substring function to sf::String #21

Closed
fpoisson opened this Issue Apr 3, 2011 · 7 comments

Comments

Projects
None yet
7 participants
@fpoisson

fpoisson commented Apr 3, 2011

Add substring function to sf::String

@ghost ghost assigned LaurentGomila Apr 10, 2011

@Mankarse

This comment has been minimized.

Show comment
Hide comment
@Mankarse

Mankarse Apr 16, 2011

This would be better expressed as a constructor taking iterator arguments. Then substring could be expressed as sf::String(string.Begin() + pos, string.Begin() + pos + n); (Or as a non-member function performing this with some extra checks, as desired). A constructor using iterators would also enable a whole class of other useful construction techniques.

Mankarse commented Apr 16, 2011

This would be better expressed as a constructor taking iterator arguments. Then substring could be expressed as sf::String(string.Begin() + pos, string.Begin() + pos + n); (Or as a non-member function performing this with some extra checks, as desired). A constructor using iterators would also enable a whole class of other useful construction techniques.

@abodelot

This comment has been minimized.

Show comment
Hide comment
@abodelot

abodelot Nov 17, 2011

Contributor

@Mankarse: It could be a feature too, but I believe a basic substring function would be easier to use.

In addition to OP's request, I suggest adding a Replace method for replacing occurrences in a sf::String object:
sf::String Replace(const sf::String& LookFor, const sf::String& ReplaceBy) const;

Link to discussion on the SMFL forum:
http://www.sfml-dev.org/forum/viewtopic.php?t=6303

Contributor

abodelot commented Nov 17, 2011

@Mankarse: It could be a feature too, but I believe a basic substring function would be easier to use.

In addition to OP's request, I suggest adding a Replace method for replacing occurrences in a sf::String object:
sf::String Replace(const sf::String& LookFor, const sf::String& ReplaceBy) const;

Link to discussion on the SMFL forum:
http://www.sfml-dev.org/forum/viewtopic.php?t=6303

@retep998

This comment has been minimized.

Show comment
Hide comment
@retep998

retep998 Nov 17, 2011

Why not simply replicate std::string functionality entirely with sf::String?
Too many times I've tried to use sf::String, only to realize I had to create all sorts of extra functions to compensate for its lack of features

retep998 commented Nov 17, 2011

Why not simply replicate std::string functionality entirely with sf::String?
Too many times I've tried to use sf::String, only to realize I had to create all sorts of extra functions to compensate for its lack of features

@nitrix

This comment has been minimized.

Show comment
Hide comment
@nitrix

nitrix Nov 26, 2011

Even tho it's named sf::String, it's actually a visual element. Thanks to Laurent, it makes drawing text a hundred times easier.

Why would you want sf::String emulates std::string capabilities when you already have it ready for use? Keep in mind sf::String handles ANSI chars, wide strings and all that fun stuff internally already, plus let you choose which one you want to work with - as a design feature.

If you ask me, sf::String is already top notch, if you want something even more "high-level", you can always build a wrapper over it. That's what I did with SDL years ago.

Cheers (:

nitrix commented Nov 26, 2011

Even tho it's named sf::String, it's actually a visual element. Thanks to Laurent, it makes drawing text a hundred times easier.

Why would you want sf::String emulates std::string capabilities when you already have it ready for use? Keep in mind sf::String handles ANSI chars, wide strings and all that fun stuff internally already, plus let you choose which one you want to work with - as a design feature.

If you ask me, sf::String is already top notch, if you want something even more "high-level", you can always build a wrapper over it. That's what I did with SDL years ago.

Cheers (:

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Nov 26, 2011

Member

Even tho it's named sf::String, it's actually a visual element

We are talking about the sf::String class of SFML 2, not SFML 1. The visual text class in SFML 2 is now sf::Text.

Member

LaurentGomila commented Nov 26, 2011

Even tho it's named sf::String, it's actually a visual element

We are talking about the sf::String class of SFML 2, not SFML 1. The visual text class in SFML 2 is now sf::Text.

@nitrix

This comment has been minimized.

Show comment
Hide comment
@nitrix

nitrix Nov 26, 2011

Oh yea my bad. Forget me.

nitrix commented Nov 26, 2011

Oh yea my bad. Forget me.

@Bromeon

This comment has been minimized.

Show comment
Hide comment
@Bromeon

Bromeon Feb 9, 2014

Member

Both substring and replace functionality has been implemented; for further information see pull request.

Member

Bromeon commented Feb 9, 2014

Both substring and replace functionality has been implemented; for further information see pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment