Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » operator<<= in tree control reference example
operator<<= in tree control reference example [message #30497] Wed, 05 January 2011 10:55 Go to previous message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
In the tree control reference example there is this code
   void LoadTree(int parent, const String& path, Progress& pi)
   {
      pi.SetText(DeFormat(path));
      for(FindFile ff(AppendFileName(path, "*.*")); ff; ff.Next()) {
         if(pi.StepCanceled())
            return;
         String n = ff.GetName();
         if(n != "." && n != "..") {
            edit.Add();
            edit.Top() <<= n;


Why does the last line use operator<<= instead of operator= ?

If there's no reason then it should be changed to operator= because it took me a while to track down the fact that it seems to go through Ctrl::operator<<= which goes through the SetData virtual function into EditField::SetData. For a newcomer or even not for a newcomer, it's not easy to find what that operator<<= does - it doesn't make any sense to use it in an example.

Also, why does the above code do an unnecessary call to the Top() function - couldn't it just be edit.Add() = n;

And lastly (off topic but related to the edit.Add function call), does U++ assume that memory allocation with new never fails - how does U++ handle failure?

Graeme
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: recent MinMax Refresh fix not GCC compilable
Next Topic: New Select form in DocEdit or LineEdit
Goto Forum:
  


Current Time: Fri Apr 26 22:25:55 CEST 2024

Total time taken to generate the page: 0.02652 seconds