--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * string (header)
+ * - C++'s String type
+ */
+#ifndef _LIBCXX_ALGORITHM_
+#define _LIBCXX_ALGORITHM_
+
+namespace std {
+
+// Maximum
+template <class T>
+const T& max(const T& a, const T& b)
+{
+ return (a<b) ? b : a;
+}
+
+template <class T, class Compare>
+const T& max(const T& a, const T& b, Compare comp)
+{
+ return comp(a, b) ? b : a;
+}
+
+template <class T>
+const T& min(const T& a, const T& b)
+{
+ return (a<b) ? a : b;
+}
+
+template <class T, class Compare>
+const T& min(const T& a, const T& b, Compare comp)
+{
+ return comp(a, b) ? a : b;
+}
+
+}; // namespace std
+
+#endif
+
+// vim: ft=cpp
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * string (header)
+ * - C++'s String type
+ */
+#ifndef _LIBCXX_ALLOCATOR_
+#define _LIBCXX_ALLOCATOR_
+
+#include "cstddef"
+
+namespace std {
+
+template <class T> class allocator
+{
+public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef T& reference;
+ typedef const T* const_pointer;
+ typedef const T& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ template <class Type>
+ struct rebind
+ {
+ typedef allocator<Type> other;
+ };
+
+ allocator() throw() {
+ }
+ allocator(const allocator& alloc) throw() {
+ }
+ template <class U>
+ allocator(const allocator<U>& alloc) throw() {
+ }
+ ~allocator() throw() {
+ }
+
+ pointer address(reference x) const {
+ return &x;
+ }
+ const_pointer address(const_reference x) const {
+ return &x;
+ }
+ pointer allocate(size_type n, const void* hint=0) {
+ ::operator new (n * sizeof(value_type));
+ }
+ void deallocate(pointer p, size_type n) {
+ ::operator delete(p);
+ }
+};
+
+};
+
+#endif
+
+// vim: ft=cpp
+
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * cstddef (header)
+ * - C++ wrapper around stddef.h
+ */
+#ifndef _LIBCXX_CSTDDEF_
+#define _LIBCXX_CSTDDEF_
+
+extern "C" {
+#include <stddef.h>
+};
+
+#endif
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * cstdint (header)
+ * - C++ wrapper around stdint.h
+ */
+#ifndef _LIBCXX_CSTDINT_
+#define _LIBCXX_CSTDINT_
+
+extern "C" {
+#include <stdint.h>
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * exception (header)
+ * - C++'s base exception type
+ */
+#ifndef _LIBCXX_EXCEPTION_
+#define _LIBCXX_EXCEPTION_
+
+#define noexcept throw()
+
+namespace std {
+
+class exception
+{
+public:
+ exception() noexcept;
+ exception(const exception& e) noexcept;
+ exception& operator= (const exception& e) noexcept;
+ virtual ~exception() noexcept;
+ virtual const char* what() const noexcept;
+};
+
+}; // namespace std
+
+#endif
+// vim: ft=cpp
+
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * list (header)
+ * - List container
+ */
+#ifndef _LIBCXX_LIST_
+#define _LIBCXX_LIST_
+
+#include <cstddef>
+
+namespace std {
+
+namespace _bits {
+template <class T> class list_iterator;
+template <class T> class list_item;
+}
+
+template <class T>
+class list
+{
+ friend class ::std::_bits::list_iterator<T>;
+
+ typedef ::std::_bits::list_item<T> item_type;
+ item_type *m_start;
+ item_type *m_end;
+public:
+ typedef T value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef _bits::list_iterator<value_type> iterator;
+ typedef _bits::list_iterator<const value_type> const_iterator;
+
+ list():
+ m_start(0), m_end(0)
+ {
+ }
+ list(size_t n, const value_type& val = value_type());
+ list(const list& x);
+ ~list() {
+ clear();
+ }
+
+ list& operator =(const list& x);
+
+ iterator begin() {
+ return iterator(m_start);
+ }
+ const_iterator begin() const {
+ return const_iterator(m_start);
+ }
+
+ iterator end() {
+ return iterator(0);
+ }
+ const_iterator end() const {
+ return const_iterator(0);
+ }
+
+ bool empty() const {
+ return !m_start;
+ }
+ size_t size() const;
+ size_t max_size() const;
+
+ T& front();
+ const T& front() const;
+ T& back();
+ const T& back() const;
+
+ void clear() {
+ while( m_start ) {
+ item_type* item = m_start;
+ m_start = m_start->next;
+ delete item;
+ }
+ }
+};
+
+
+namespace _bits {
+
+template <class T>
+struct list_item
+{
+ list_item<T> *next;
+ list_item<T> *prev;
+ T value;
+};
+
+template <class T>
+class list_iterator//:
+ //public bidirectional_iterator_tag;
+{
+ friend class list<T>;
+
+ list_item<T> *cur;
+public:
+ bool operator == (const list_iterator& other) const {
+ return cur == other.cur;
+ }
+ bool operator != (const list_iterator& other) const {
+ return cur != other.cur;
+ }
+
+ T& operator * () {
+ return cur->value;
+ }
+ T& operator -> () {
+ return cur->value;
+ }
+ list_iterator& operator ++ () {
+ cur = cur->next;
+ }
+ list_iterator& operator -- () {
+ cur = cur->prev;
+ }
+
+private:
+ list_iterator(list_item<T> *item):
+ cur(item)
+ {
+ }
+};
+
+}; // namespace _bits
+
+}; // namespace std
+
+#endif
+
+// vim: ft=cpp
+
--- /dev/null
+
+#ifndef _LIBCXX_MEMORY_
+#define _LIBCXX_MEMORY_
+
+namespace std {
+
+template <>
+class allocator<void>
+{
+public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
+ template <class U> struct rebind { typedef allocator<U> other; };
+};
+
+}
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * string (header)
+ * - C++'s String type
+ */
+#ifndef _LIBCXX_STDEXCEPT_
+#define _LIBCXX_STDEXCEPT_
+
+#include "exception"
+
+namespace std {
+
+class logic_error:
+ public exception
+{
+public:
+ explicit logic_error(const basic_string<char>& what_arg);
+};
+
+class runtime_error:
+ public exception
+{
+public:
+ explicit runtime_error(const basic_string<char>& what_arg);
+};
+
+class out_of_range:
+ public logic_error
+{
+public:
+ explicit out_of_range(const string& what_arg);
+};
+
+} // namespace std
+
+#endif
+
+// vim: ft=cpp
+
--- /dev/null
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * string (header)
+ * - C++'s String type
+ */
+#ifndef _LIBCXX_STRING_
+#define _LIBCXX_STRING_
+
+#include <allocator>
+
+namespace std {
+
+template <class charT>
+struct char_traits
+{
+};
+
+template <>
+struct char_traits<char>
+{
+ typedef char char_type;
+ typedef int int_type;
+ //typedef streamoff off_type;
+ //typedef streampos pos_type;
+ //typedef mbstate_t state_type;
+
+ static bool eq(const char_type& c, const char_type& d) {
+ return c == d;
+ }
+ static bool lt(const char_type& c, const char_type& d) {
+ return c < d;
+ }
+ static size_t length(const char_type* s) {
+ size_t ret = 0;
+ while(*s++) ret ++;
+ return ret;
+ }
+};
+
+template <>
+struct char_traits<wchar_t>
+{
+ typedef wchar_t char_type;
+ typedef int int_type;
+ //typedef streamoff off_type;
+ //typedef streampos pos_type;
+ //typedef mbstate_t state_type;
+
+ static size_t length(const char_type* s) {
+ size_t ret = 0;
+ while(*s++) ret ++;
+ return ret;
+ }
+ static bool eq(const char_type& c, const char_type& d) {
+ return c == d;
+ }
+ static bool lt(const char_type& c, const char_type& d) {
+ return c < d;
+ }
+};
+
+template < class charT, class traits=char_traits<charT>, class Alloc=allocator<charT> >
+class basic_string;
+
+typedef basic_string<char> string;
+
+}; // namespace std
+
+#include <stdexcept>
+
+namespace std {
+
+template < class charT, class traits, class Alloc >
+class basic_string
+{
+public:
+ typedef traits traits_type;
+ typedef Alloc allocator_type;
+ typedef charT value_type;
+ typedef typename allocator_type::reference reference;
+ typedef typename allocator_type::const_reference const_reference;
+ typedef size_t size_type;
+
+ basic_string(const allocator_type& alloc = allocator_type()):
+ m_allocator(alloc),
+ m_capacity(0),
+ m_length(0),
+ m_data(0)
+ {
+ }
+ basic_string(const basic_string& str):
+ basic_string(str, allocator_type())
+ {
+ }
+ basic_string(const basic_string& str, const allocator_type& alloc):
+ basic_string(str, 0, str.length(), alloc)
+ {
+ }
+ basic_string(const basic_string& str, size_type pos, size_type len = npos, const allocator_type& alloc = allocator_type()):
+ basic_string(alloc)
+ {
+ if( pos < str.length() )
+ {
+ if( len > str.length() - pos )
+ len = str.length() - pos;
+ reserve(len);
+ for( size_type i = 0; i < len; i ++ )
+ m_data[i] = str.m_data[pos+i];
+ m_length = len;
+ }
+ }
+ basic_string(const charT *s, const allocator_type& alloc = allocator_type()):
+ basic_string(s, traits::length(s), alloc)
+ {
+ }
+ basic_string(const charT *s, size_type n, const allocator_type& alloc = allocator_type()):
+ basic_string(alloc)
+ {
+ if( n > 0 )
+ {
+ reserve(n);
+ for( size_type i = 0; i < n; i ++ )
+ m_data[i] = s[i];
+ m_length = n;
+ }
+ }
+ basic_string(size_type n, charT c, const allocator_type& alloc = allocator_type()):
+ basic_string(alloc)
+ {
+ if( n > 0 )
+ {
+ reserve(n);
+ for( size_type i = 0; i < n; i ++ )
+ m_data[i] = c;
+ m_length = n;
+ }
+ }
+
+ // iterators
+
+ // capacity
+ size_type size() const {
+ return m_size;
+ }
+ size_type length() const {
+ return size();
+ }
+ size_type max_size() const {
+ return -1;
+ }
+ void resize(size_type size, charT c = 0) {
+ reserve(size);
+ if( m_size < size ) {
+ for( size_type ofs = m_size; ofs < size; ofs ++ )
+ m_data[ofs] = c;
+ }
+ m_size = size;
+ m_data[m_size] = 0;
+ }
+ size_type capacity() const {
+ return m_capacity;
+ }
+ void reserve(size_type size) {
+ size = (size+1 + 31) & ~31;
+ if( size > m_capacity ) {
+ auto new_area = m_allocator.allocate(size);
+ for( size_type i = 0; i < m_length; i ++ )
+ new_area[i] = m_data[i];
+ m_allocator.deallocate(m_data, m_capacity);
+ m_data = new_area;
+ m_capacity = size;
+ }
+ }
+ void clear() {
+ m_size = 0;
+ }
+ bool empty() const {
+ return length() == 0;
+ }
+
+ // Access
+ reference operator[] (size_type pos) {
+ return m_data[pos];
+ }
+ const_reference operator[] (size_type pos) const {
+ return m_data[pos];
+ }
+ reference at(size_type pos) {
+ if(pos >= m_size) throw ::std::out_of_range("basic_string - at");
+ return m_data[pos];
+ }
+ const_reference at(size_type pos) const {
+ if(pos >= m_size) throw ::std::out_of_range("basic_string - at");
+ return m_data[pos];
+ }
+
+ // Modifiers
+ basic_string& operator +=(const basic_string& str);
+ basic_string& operator +=(const charT* s);
+ basic_string& operator +=(charT c);
+
+ static const size_type npos = -1;
+private:
+ allocator_type m_allocator;
+ size_type m_capacity;
+ size_type m_size;
+ size_type m_length;
+ typename allocator_type::pointer m_data;
+};
+
+};
+
+#include <stdexcept>
+
+#endif
+
+// vim: ft=cpp