EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: strings
From: Kay-Uwe Kasemir <[email protected]>
To: [email protected]
Date: Tue, 27 Sep 2005 13:37:44 -0400
On Sep 27, 2005, at 13:04 , Andrew Johnson wrote:
Use 'assign' instead of 'operator =',
'isEqual' instead of 'operator ==',
'getElement' instead of 'operator []', ...
After replacing all operators, I think your suggestion is great.
I already implement assign() and equals(). The operator= operator== and operator+= methods are non-virtual inline wrappers that call those virtual functions, and are provided for user convenience only.
I agree that it's initially more convenient to be able to
use the operators.
But in the long run, it causes the C++ and e.g. Java sources
differ, and in C++ I also find it difficult to understand what's
called when everything has cast and assignment operators.
Of course that's my personal problem and would never
happen to anybody else.

operator[] is not currently implemented in that fashion, but I am willing to do that too (although I don't like your name so I will probably change it).
Yes, feel free to change it. Some suggestions:

1) More explicitly named, with limited error handling
enum indexedElementAccessResultEnum
{ ok, index_too_large, string_temporarily_unavailable, string_never_available };

class indexedElementAccessResult
{
public:
    indexedElementAccessResult ( indexedElementAccessResultEnum );
    virtual ~indexedElementAccessResult ();
const indexedElementAccessResult & operator = ( indexedElementAccessResultEnum rhs );
    indexedElementAccessResultEnum getResult () const;
    bool isOK() const;
private:
    indexedElementAccessResult ();
    indexedElementAccessResultEnum result;
};

indexedElementAccessResult indexedElementAccess(size_t index, char &result) const;

2) Naive, now with shorter names:
 // will return '\0' for invalid idx
 char get(size_t idx);

-Kay


Replies:
Re: strings Andrew Johnson
References:
RE: data access structures, strings Jeff Hill
Re: data access structures, strings Kay-Uwe Kasemir
Re: data access structures, strings Andrew Johnson
Re: data access structures, strings Kay-Uwe Kasemir
Re: data access structures, strings Andrew Johnson

Navigate by Date:
Prev: Re: data access structures, strings Andrew Johnson
Next: Re: data access structures, strings Marty Kraimer
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: data access structures, strings Andrew Johnson
Next: Re: strings Andrew Johnson
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·