[nemiver/asm-support: 3/8] New Address type.



commit bb2a08d765caad50f3f52b205b19a7e7eefabd22
Author: Dodji Seketeli <dodji redhat com>
Date:   Sun Jan 10 14:40:14 2010 +0100

    New Address type.
    
    	* src/common/Makefile.am: Add nmv-address.[h|cc] to build system
    	* src/common/nmv-address.[cc|h]: New files.

 src/common/Makefile.am    |    2 +
 src/common/nmv-address.cc |   63 +++++++++++++++++++++++++++++++++++++++++++++
 src/common/nmv-address.h  |   49 +++++++++++++++++++++++++++++++++++
 3 files changed, 114 insertions(+), 0 deletions(-)
---
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 67594a8..562aeb7 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -5,6 +5,7 @@ headers= \
 nmv-api-macros.h \
 nmv-namespace.h \
 nmv-ustring.h \
+nmv-address.h \
 nmv-str-utils.h \
 nmv-libxml-utils.h \
 nmv-safe-ptr-utils.h \
@@ -39,6 +40,7 @@ nmv-proc-mgr.h
 
 libnemivercommon_la_SOURCES= $(headers) \
 nmv-ustring.cc \
+nmv-address.cc \
 nmv-str-utils.cc \
 nmv-object.cc \
 nmv-libxml-utils.cc \
diff --git a/src/common/nmv-address.cc b/src/common/nmv-address.cc
new file mode 100644
index 0000000..059de7d
--- /dev/null
+++ b/src/common/nmv-address.cc
@@ -0,0 +1,63 @@
+//Author: Dodji Seketeli
+/*
+ *This file is part of the Nemiver project
+ *
+ *Nemiver is free software; you can redistribute
+ *it and/or modify it under the terms of
+ *the GNU General Public License as published by the
+ *Free Software Foundation; either version 2,
+ *or (at your option) any later version.
+ *
+ *Nemiver is distributed in the hope that it will
+ *be useful, but WITHOUT ANY WARRANTY;
+ *without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *See the GNU General Public License for more details.
+ *
+ *You should have received a copy of the
+ *GNU General Public License along with Nemiver;
+ *see the file COPYING.
+ *If not, write to the Free Software Foundation,
+ *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *See COPYRIGHT file copyright information.
+ */
+#include "nmv-address.h"
+
+NEMIVER_BEGIN_NAMESPACE (nemiver)
+NEMIVER_BEGIN_NAMESPACE (common)
+
+Address::Address ()
+{
+}
+
+Address::Address (const std::string &a) :
+    m_addr (a)
+{
+}
+
+Address::operator const std::string& () const
+{
+    return m_addr;
+}
+
+int
+Address::size () const
+{
+    if (m_addr.empty ())
+        return 0;
+    int suffix_len = 0;
+    if (m_addr[0] == '0' && m_addr[1] == 'x')
+        suffix_len = 2;
+    return m_addr.size () - suffix_len;
+}
+
+Address&
+Address::operator= (const std::string &a_addr)
+{
+    m_addr = a_addr;
+    return *this;
+}
+
+NEMIVER_END_NAMESPACE (common)
+NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/common/nmv-address.h b/src/common/nmv-address.h
new file mode 100644
index 0000000..56ad91a
--- /dev/null
+++ b/src/common/nmv-address.h
@@ -0,0 +1,49 @@
+//Author: Dodji Seketeli
+/*
+ *This file is part of the Nemiver project
+ *
+ *Nemiver is free software; you can redistribute
+ *it and/or modify it under the terms of
+ *the GNU General Public License as published by the
+ *Free Software Foundation; either version 2,
+ *or (at your option) any later version.
+ *
+ *Nemiver is distributed in the hope that it will
+ *be useful, but WITHOUT ANY WARRANTY;
+ *without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *See the GNU General Public License for more details.
+ *
+ *You should have received a copy of the
+ *GNU General Public License along with Nemiver;
+ *see the file COPYING.
+ *If not, write to the Free Software Foundation,
+ *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *See COPYRIGHT file copyright information.
+ */
+#ifndef __NEMIVER_ADDRESS_H__
+#define __NEMIVER_ADDRESS_H__
+#include <string>
+#include "nmv-namespace.h"
+#include "nmv-api-macros.h"
+
+NEMIVER_BEGIN_NAMESPACE (nemiver)
+NEMIVER_BEGIN_NAMESPACE (common)
+
+class NEMIVER_API Address
+{
+    std::string m_addr;
+public:
+    Address ();
+    Address (const std::string &a_addr);
+    Address (const Address &);
+    operator const std::string& () const;
+    int size () const;
+    Address& operator= (const std::string &);
+};// end class Address
+
+NEMIVER_END_NAMESPACE (common)
+NEMIVER_END_NAMESPACE (nemiver)
+
+#endif // __NEMIVER_ADDRESS_H__



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]