BIND 10 #2369: InputSource helper class for MasterLexer

BIND 10 Development do-not-reply at isc.org
Sat Oct 27 06:30:43 UTC 2012


#2369: InputSource helper class for MasterLexer
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:  muks
  jinmei                             |                Status:  assigned
                       Type:  task   |             Milestone:
                   Priority:         |  Sprint-20121106
  medium                             |            Resolution:
                  Component:         |             Sensitive:  0
  libdns++                           |           Sub-Project:  DNS
                   Keywords:         |  Estimated Difficulty:  4
            Defect Severity:  N/A    |           Total Hours:  0
Feature Depending on Ticket:         |
  loadzone-ng                        |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------

Comment (by jinmei):

 On thinking a bit more details of the `MasterLexer` class (#2371),
 I realized we need to extend the responsibility of `InputSource` a
 bit more.

 If `MasterLexer` opens a file via the open(const char*) method, it
 will eventually need to close it.  But with the current interface
 `MasterLexer` needs to keep some handle (e.g. ifstream) for the file
 separately from `InputSource`.  It doesn't make much sense.  So, it's
 better to move this responsibility to `InputSource`.

 The revised constructors would look:

 {{{#!cpp
 // open the specified name of file and use it as the source.  Close it
 // in the destructor.
 InputSourcew::InputSour(const char* filename);

 // use the given stream as the source.  do not close it in the destructor.
 InputSourcew::InputSour(std::istream& input_stream);
 }}}
 In either case `InputSourcew` needs to generate and maintain the
 appropriate "name".

 Also, we're going to store `InputSource` objects in an STL container
 (most likely a vector), so it must be copyable.  It means we cannot
 make name_ member const.  It also means it's better to hide it as a
 private member and provide a safe accessor:

 {{{#!cpp
 class InputSource {
 public:
 //...
     const std::string& getName() const { return (name_); }
 private:
     std::string name_;
 };
 }}}

-- 
Ticket URL: <http://bind10.isc.org/ticket/2369#comment:3>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list