advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
In the early days of the object-oriented revolution, code reuse was touted as one of the major benefits of this paradigm. Based on your experience, has this promise been fulfilled?
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 2.7/5 | Rate this item | 3 users have rated this item.
 

Using the Transform() Algorithm to Change a String's Case

The task of converting strings to uppercase is just like many other programming tasks: everyone needs it and everyone does it. The problem is with how they do it. Often it is done the hard wayreimplementing the wheel or introducing unnecessary performance penalties, maintenance problems, and other complexities. This month's solution demonstrates how the transform() algorithm is a faster, cleaner and more flexible method. 


advertisement
ommand line interpreters, HTTP requests, and SMS messages are only a few of the applications in which different letter cases merely cause noise. To overcome this problem, such applications usually convert all strings to uppercase before any further processing.



Sadly, most of these apps use C-style strings and ad-hoc, in-house conversion routines that more often than not suffer from bugs, illegibility, and performance overhead. The std::string class provides more than a hundred member functions and overloaded operators. Yet, none of these functions transforms a string to uppercase or lowercase letters.



Use the STL transform() algorithm to change a string's case easily.

  Next Page: Converting the Hard Way
Page 1: IntroductionPage 3: Design Improvements
Page 2: Converting the Hard Way 
Please rate this item (5=best)
 1  2  3  4  5
advertisement