Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::String append function  (Read 22527 times)

0 Members and 1 Guest are viewing this topic.

pekl

  • Newbie
  • *
  • Posts: 5
    • View Profile
sf::String append function
« on: August 13, 2008, 10:24:37 am »
In addition to the setText functions, it would be nice to have an append function. Even better would be if it could handle different data types such as integers and floats.

for example, if you would like to display scores in a game.

setText("score: ");
appendInt(4);

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::String append function
« Reply #1 on: August 13, 2008, 10:47:33 am »
Like it is said in the tutorial, sf::String is a purely graphical class and has nothing to do with string manipulation. Just use std::string, std::ostringstream or whatever you prefer to format your text.
Laurent Gomila - SFML developer

hacky

  • Newbie
  • *
  • Posts: 26
    • View Profile
sf::String append function
« Reply #2 on: August 13, 2008, 09:10:04 pm »
sprintf?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::String append function
« Reply #3 on: August 13, 2008, 10:59:00 pm »
Quote from: "hacky"
sprintf?

Not in C++.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
sf::String append function
« Reply #4 on: August 14, 2008, 06:18:40 pm »
Just use std::stringstream and its operator<< to append values of any elementar type.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: