labelsequence.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __LABELSEQUENCE_H
  15. #define __LABELSEQUENCE_H 1
  16. #include <dns/name.h>
  17. #include <util/buffer.h>
  18. namespace isc {
  19. namespace dns {
  20. class LabelSequence {
  21. public:
  22. LabelSequence(const Name& name);
  23. ~LabelSequence();
  24. const char* getData(size_t* len) const;
  25. bool equals(const LabelSequence& other, bool case_sensitive = false) const;
  26. void split(int i);
  27. size_t getLabelCount() const { return last_label_ - first_label_; }
  28. const Name& getName() const { return name_; }
  29. private:
  30. const Name& name_;
  31. size_t first_label_;
  32. size_t last_label_;
  33. size_t* offsets_;
  34. };
  35. } // end namespace dns
  36. } // end namespace isc
  37. #endif