]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kill useless [cn]string.h
authorSage Weil <sage.weil@dreamhost.com>
Mon, 6 Feb 2012 05:19:43 +0000 (21:19 -0800)
committerSage Weil <sage@newdream.net>
Mon, 6 Feb 2012 21:33:37 +0000 (13:33 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/Makefile.am
src/include/cstring.h [deleted file]
src/include/nstring.h [deleted file]

index dd956b97c02975f67e088b856ec3cd8e00019896..dea52589fdb84e626ebc056501c23a63210cceac 100644 (file)
@@ -1171,7 +1171,6 @@ noinst_HEADERS = \
        include/color.h\
        include/compat.h\
        include/crc32c.h\
-        include/cstring.h\
         include/encoding.h\
         include/err.h\
         include/error.h\
@@ -1186,7 +1185,6 @@ noinst_HEADERS = \
        include/linux_fiemap.h\
         include/lru.h\
        include/msgr.h\
-        include/nstring.h\
         include/object.h\
         include/page.h\
         include/rangeset.h\
diff --git a/src/include/cstring.h b/src/include/cstring.h
deleted file mode 100644 (file)
index d23bc88..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#ifndef CEPH_CSTRING_H
-#define CEPH_CSTRING_H
-
-/*
- * cstring - a simple string class
- *
- * the key difference between this and std::string is that the string
- * is stored with a null terminator, providing an efficient c_str()
- * method.
- */
-
-#include "buffer.h"
-#include "encoding.h"
-
-class cstring {
- private:
-  int _len;
-  char *_data;
-  
- public:
-  cstring() : _len(0), _data(0) {}
-  cstring(int l, const char *d=0) : _len(l) {
-    _data = new char[_len + 1];
-    if (d)
-      memcpy(_data, d, l);
-    _data[l] = 0;
-  }
-  cstring(const char *s) { 
-    if (s) {
-      _len = strlen(s);
-      _data = new char[_len + 1];
-      memcpy(_data, s, _len);
-      _data[_len] = 0;
-    } else {
-      _len = 0;
-      _data = 0;
-    }
-  }
-  cstring(const string &s) {
-    _len = s.length();
-    _data = new char[_len + 1];
-    memcpy(_data, s.data(), _len);
-    _data[_len] = 0;
-  }
-  cstring(const cstring &s) {
-    _len = s.length();
-    _data = new char[_len + 1];
-    memcpy(_data, s.data(), _len);
-    _data[_len] = 0;
-  }
-  ~cstring() {
-    if (_data) delete[] _data;
-  }
-
-  // accessors
-  int length() const { return _len; }
-  bool empty() const { return _len == 0; }
-  char *c_str() const { return _data; }
-  char *data() const { return _data; }
-
-  //const char *operator() const { return _data; }
-
-  // modifiers
-  const cstring& operator=(const char *s) {
-    if (_data) delete[] _data;
-    _len = strlen(s);
-    _data = new char[_len + 1];
-    memcpy(_data, s, _len);
-    _data[_len] = 0;
-    return *this;
-  }
-  const cstring& operator=(const string &s) {
-    if (_data) delete[] _data;
-    _len = s.length();
-    _data = new char[_len + 1];
-    memcpy(_data, s.data(), _len);
-    _data[_len] = 0;
-    return *this;
-  }
-  const cstring& operator=(const cstring &ns) {
-    if (_data) delete[] _data;
-    _len = ns.length();
-    _data = new char[_len + 1];
-    memcpy(_data, ns.data(), _len);
-    _data[_len] = 0;
-    return *this;
-  }
-  char &operator[](int n) {
-    assert(n <= _len);
-    return _data[n];
-  }
-  void swap(cstring &other) {
-    int tlen = _len;
-    char *tdata = _data;
-    _len = other._len;
-    _data = other._data;
-    other._len = tlen;
-    other._data = tdata;
-  }
-  void clear() {
-    _len = 0;
-    delete _data;
-    _data = 0;
-  }
-
-  // encoding
-  void encode(bufferlist &bl) const {
-    __u32 l = _len;
-    ::encode(l, bl);
-    bl.append(_data, _len);
-  }
-  void decode(bufferlist::iterator &bl) {
-    __u32 l;
-    ::decode(l, bl);
-    decode_nohead(l, bl);
-  }
-  void decode_nohead(int l, bufferlist::iterator& bl) {
-    if (_data) delete[] _data;
-    _len = l;
-    _data = new char[_len + 1];
-    bl.copy(_len, _data);
-    _data[_len] = 0;
-  }
-};
-WRITE_CLASS_ENCODER(cstring)
-
-inline void encode_nohead(const cstring& s, bufferlist& bl)
-{
-  bl.append(s.data(), s.length());
-}
-inline void decode_nohead(int len, cstring& s, bufferlist::iterator& p)
-{
-  s.decode_nohead(len, p);
-}
-
-
-#endif
diff --git a/src/include/nstring.h b/src/include/nstring.h
deleted file mode 100644 (file)
index 28d95ff..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef CEPH_NSTRING_D44FAD468A084A2D994D171C04DE05BD
-#define CEPH_NSTRING_D44FAD468A084A2D994D171C04DE05BD
-
-#if 0
-# include "tstring.h"
-typedef tstring nstring;
-#else
-# include "cstring.h"
-typedef cstring nstring;
-#endif
-
-#include "ceph_hash.h"
-
-static inline bool operator==(const nstring &l, const char *s) {
-  return strcmp(l.c_str(), s) == 0;
-}
-
-static inline bool operator==(const nstring &l, const nstring &r) {
-  return l.length() == r.length() && memcmp(l.data(), r.data(), l.length()) == 0;
-}
-static inline bool operator!=(const nstring &l, const nstring &r) {
-  return l.length() != r.length() || memcmp(l.data(), r.data(), l.length()) != 0;
-}
-static inline bool operator<(const nstring &l, const nstring &r) {
-  return strcmp(l.c_str(), r.c_str()) < 0;
-}
-static inline bool operator<=(const nstring &l, const nstring &r) {
-  return strcmp(l.c_str(), r.c_str()) <= 0;
-}
-static inline bool operator>(const nstring &l, const nstring &r) {
-  return strcmp(l.c_str(), r.c_str()) > 0;
-}
-static inline bool operator>=(const nstring &l, const nstring &r) {
-  return strcmp(l.c_str(), r.c_str()) >= 0;
-}
-
-static inline ostream& operator<<(ostream &out, const nstring &s) {
-  return out << s.c_str();
-}
-
-namespace __gnu_cxx {
-  template<> struct hash< nstring >
-  {
-    size_t operator()( const nstring& x ) const
-    {
-      //static hash<const char*> H;
-      //return H(x.c_str());
-      return ceph_str_hash_linux(x.c_str(), x.length());
-    }
-  };
-}
-
-#endif