Basic support of the ios_base, the root of all streams.

Added skeleton for ostream and the iosfwd header files.
iomanip is referenced in the comment but not included in this CL.
diff --git a/include/ios_base.h b/include/ios_base.h
new file mode 100644
index 0000000..858bb96
--- /dev/null
+++ b/include/ios_base.h
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_ASTL_IOS_BASE__
+#define ANDROID_ASTL_IOS_BASE__
+
+#include <ios_pos_types.h>
+
+namespace std {
+
+/**
+ * Root of the streams inheritance.
+ * The STL defines ios_base as a template with 2 params char types and
+ * traits. We support only char and no traits.
+ */
+
+class ios_base
+{
+  public:
+    typedef int io_state;
+    typedef int open_mode;
+    typedef int seek_dir;
+    typedef std::streampos streampos;
+    typedef std::streamoff streamoff;
+
+
+  protected:
+    ios_base();
+
+  public:
+    virtual ~ios_base();
+
+    /**
+     * @return The precision (number of digits after the decimal
+     * point) to generate on certain output conversions. 6 by default.
+     */
+    streamsize precision() const { return mPrecision; }
+
+    /**
+     *  @param precision The new precision value. Values < 0 are ignored.
+     *  @return The previous value of precision(). 0 by default;
+     */
+    streamsize precision(streamsize precision);
+
+    /**
+     * @return The minimum field width to generate on output
+     * operations.
+     */
+    streamsize width() const { return mWidth; }
+
+    /**
+     *  @param width The new width value. Values < 0 are ignored.
+     *  @return The previous value of width().
+     */
+    streamsize width(streamsize width);
+
+private:
+    streamsize mPrecision;
+    streamsize mWidth;
+};
+
+}  // namespace std
+
+#endif
diff --git a/include/iosfwd b/include/iosfwd
new file mode 100644
index 0000000..6074084
--- /dev/null
+++ b/include/iosfwd
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_ASTL_IOSFWD__
+#define ANDROID_ASTL_IOSFWD__
+
+/**
+ * Forward declaration of the I/O stream classes.
+ */
+namespace std {
+
+class ios_base;
+class ostream;
+
+}  // namespace std
+
+#endif
diff --git a/include/ostream b/include/ostream
new file mode 100644
index 0000000..ef31b34
--- /dev/null
+++ b/include/ostream
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_ASTL_OSTREAM__
+#define ANDROID_ASTL_OSTREAM__
+
+#include <ios_base.h>
+#include <ios_pos_types.h>
+
+namespace std {
+
+/**
+ * Basic implementation of ostream. The STL standard defines a
+ * basic_ostream template that gets specialized for char and
+ * wchar. Since Android supports only char, we don't use a template
+ * here.
+ */
+
+class ostream: public ios_base
+{
+  public:
+    typedef char           char_type;
+    typedef int            int_type;
+    typedef streampos      pos_type;
+    typedef streamoff      off_type;
+
+  protected:
+    ostream();
+
+  public:
+    virtual ~ostream();
+
+    /**
+     * Interface for manipulators (e.g std::endl, std::hex in
+     * expression like "std::cout << std::endl"). See iomanip header.
+     */
+    ostream& operator<<(ostream& (*manip)(ostream&)) { return manip(*this); }
+    ostream& operator<<(ios_base& (*manip)(ios_base&)) {
+        manip(*this);
+        return *this;
+    }
+};
+
+}  // namespace std
+
+#endif
diff --git a/src/Android.mk b/src/Android.mk
index e25dd8e..e555dab 100644
--- a/src/Android.mk
+++ b/src/Android.mk
@@ -19,7 +19,9 @@
 LOCAL_PATH := $(call my-dir)
 
 astl_common_src_files := \
+    ios_base.cpp \
     ios_pos_types.cpp \
+    ostream.cpp \
     string.cpp
 
 # Build the target lib
diff --git a/src/ios_base.cpp b/src/ios_base.cpp
new file mode 100644
index 0000000..4fe7921
--- /dev/null
+++ b/src/ios_base.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ios_base.h>
+
+namespace std {
+// Implementation of the ios_base, common stuff for all the streams.
+
+ios_base::ios_base()
+    : mPrecision(6), mWidth(0) {}
+
+ios_base::~ios_base() {}
+
+streamsize ios_base::precision(streamsize precision) {
+    const streamsize prev = mPrecision;
+    if (precision >= 0) {  // Not sure what a negative precision would mean.
+        mPrecision = precision;
+    }
+    return prev;
+}
+
+streamsize ios_base::width(streamsize width) {
+    const streamsize prev = mWidth;
+    if (width >= 0) {  // Not sure what a negative width would mean.
+        mWidth = width;
+    }
+    return prev;
+}
+
+}  // namespace std
diff --git a/src/ostream.cpp b/src/ostream.cpp
new file mode 100644
index 0000000..63d3b0a
--- /dev/null
+++ b/src/ostream.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ostream>
+
+namespace std {
+// Implementation of the std::ostream class.
+
+ostream::ostream() {}
+
+ostream::~ostream() {}
+
+}  // namespace std
diff --git a/tests/Android.mk b/tests/Android.mk
index 11a76c6..b1efe6b 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -63,6 +63,7 @@
 sources := \
     test_algorithm.cpp \
     test_functional.cpp \
+    test_ios_base.cpp \
     test_ios_pos_types.cpp \
     test_limits.cpp \
     test_set.cpp \
diff --git a/tests/test_ios_base.cpp b/tests/test_ios_base.cpp
new file mode 100644
index 0000000..4e87419
--- /dev/null
+++ b/tests/test_ios_base.cpp
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "../include/ios_base.h"
+#ifndef ANDROID_ASTL_IOS_BASE__
+#error "Wrong header included!!"
+#endif
+#include "common.h"
+
+namespace android {
+class ios: public std::ios_base {
+  public:
+};
+
+bool testDefaultPrecision() {
+    ios s;
+    EXPECT_TRUE(s.precision() == 6);
+    return true;
+}
+
+bool testSetPrecision() {
+    ios s;
+    EXPECT_TRUE(s.precision(10) == 6);
+    EXPECT_TRUE(s.precision() == 10);
+    EXPECT_TRUE(s.precision(-1) == 10); // no-op
+    EXPECT_TRUE(s.precision() == 10);
+    return true;
+}
+
+bool testDefaultWidth() {
+    ios s;
+    EXPECT_TRUE(s.width() == 0);
+    return true;
+}
+
+bool testSetWidth() {
+    ios s;
+    EXPECT_TRUE(s.width(10) == 0);
+    EXPECT_TRUE(s.width() == 10);
+    EXPECT_TRUE(s.width(-1) == 10); // no-op
+    EXPECT_TRUE(s.width() == 10);
+    return true;
+}
+
+}  // namespace android
+
+int main(int argc, char **argv){
+    FAIL_UNLESS(testDefaultPrecision);
+    FAIL_UNLESS(testSetPrecision);
+    FAIL_UNLESS(testDefaultWidth);
+    FAIL_UNLESS(testSetWidth);
+    return kPassed;
+}