00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00032
00033 #ifndef GROOVX_IO_ATTRIBCOUNT_CC_UTC20051112011609_DEFINED
00034 #define GROOVX_IO_ATTRIBCOUNT_CC_UTC20051112011609_DEFINED
00035
00036 #include "io/attribcount.h"
00037
00038 #include "io/writer.h"
00039
00040 #include "nub/ref.h"
00041
00042 #include "rutz/trace.h"
00043
00044 namespace
00045 {
00046 using namespace nub;
00047
00048 class counting_writer : public io::writer
00049 {
00050 public:
00051 counting_writer() : m_count(0) {}
00052
00053 virtual void write_char(const char*, char) { ++m_count; }
00054 virtual void write_int(const char*, int) { ++m_count; }
00055 virtual void write_bool(const char*, bool) { ++m_count; }
00056 virtual void write_double(const char*, double) { ++m_count; }
00057 virtual void write_cstring(const char*, const char*) { ++m_count; }
00058 virtual void write_value_obj(const char*, const rutz::value&) { ++m_count; }
00059
00060 virtual void write_byte_array(const char*,
00061 const unsigned char*,
00062 unsigned int)
00063 { ++m_count; }
00064
00065 virtual void write_object(const char*,
00066 soft_ref<const io::serializable>)
00067 { ++m_count; }
00068
00069 virtual void write_owned_object(const char*,
00070 ref<const io::serializable>)
00071 { ++m_count; }
00072
00073 virtual void write_base_class(const char*,
00074 ref<const io::serializable>)
00075 { ++m_count; }
00076
00077 virtual void write_root(const io::serializable*) {}
00078
00079 unsigned int get_count() const { return m_count; }
00080
00081 private:
00082 unsigned int m_count;
00083 };
00084 }
00085
00086 unsigned int io::attrib_count(const io::serializable& obj)
00087 {
00088 GVX_TRACE("io::attrib_count");
00089 counting_writer counter;
00090 obj.write_to(counter);
00091 return counter.get_count();
00092 }
00093
00094 static const char __attribute__((used)) vcid_groovx_io_attribcount_cc_utc20051112011609[] = "$Id: attribcount.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00095 #endif // !GROOVX_IO_ATTRIBCOUNT_CC_UTC20051112011609DEFINED