stlab.adobe.com Adobe Systems Incorporated

name_fwd.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /*************************************************************************************************/
00008 
00009 #ifndef ADOBE_NAME_FWD_HPP
00010 #define ADOBE_NAME_FWD_HPP
00011 
00012 #include <adobe/config.hpp>
00013 
00014 #include <cstddef>
00015 #include <cassert>
00016 
00017 #include <boost/operators.hpp>
00018 #include <boost/type_traits/is_pod.hpp>
00019 #include <boost/type_traits/has_nothrow_constructor.hpp>
00020 
00021 #include <adobe/implementation/swap.hpp>
00022 
00023 #include <adobe/empty.hpp>
00024 
00025 #if defined(ADOBE_STD_SERIALIZATION)
00026 #include <iosfwd>
00027 #endif
00028 
00029 /*************************************************************************************************/
00030 
00031 namespace adobe {
00032 
00033 namespace version_1 {
00034 
00035 class name_t;
00036 
00037 inline bool operator < (const name_t& x, const name_t& y);
00038 inline bool operator == (const name_t& x, const name_t& y);
00039 
00040 /*************************************************************************************************/
00041 
00042 /*
00043     REVISIT (sparent) : I would prefer to use the explicit instantiation instead of inheritance
00044     for the totally_ordered<> templates (the base class chaining mechanism is a bit of a hack).
00045     However, doing so seems to trip into a compiler bug with CW 9.3 and boost 1.31.0 - 
00046     comparisions somehow end up executing unrelated code in a different file.
00047 */
00048 
00049 class name_t : boost::totally_ordered<name_t, name_t, empty_base<name_t> >
00050 {
00051  private:
00052     operator int () const;
00053  public:
00054 
00055     explicit name_t (const char* string_name = "");
00056                 
00057     const char* c_str() const;
00058 
00059 #if !defined(ADOBE_NO_DOCUMENTATION)
00060     operator bool() const;
00061     bool operator!() const;
00062     
00063     friend void swap(name_t& x, name_t& y) { std::swap(x.name_m, y.name_m); }
00064 #endif
00065 
00066  private:
00067     friend class static_name_t;
00068     friend struct aggregate_name_t;
00069     
00070     struct dont_copy_t { };
00071     struct dont_initialize_t { };
00072     
00073     name_t (const char* x, dont_copy_t)
00074     {
00075         /*
00076             NOTE (sparent@adobe.com) : The body of this function is inline to avoid a bug with gcc
00077             4.0.1 (5465) when -O3 is used. However, generally it is a good piece of code to inline
00078             anyway.
00079         */
00080 
00081         assert(x && "WARNING (sparent) : Null string_name in name_t");
00082         name_m = x;
00083     }
00084     
00085     name_t (dont_initialize_t) { }
00086     
00087     const char* name_m;
00088 };
00089     
00090 /*************************************************************************************************/
00091 
00092 class static_name_t;
00093 struct aggregate_name_t;
00094 
00095 /*************************************************************************************************/
00096 
00097 #if defined(ADOBE_STD_SERIALIZATION)
00098 std::ostream& operator << (std::ostream& os, const name_t& t);
00099 #endif
00100 
00101 /*************************************************************************************************/
00102 
00103 } // namespace version_1
00104 
00105 using version_1::name_t;
00106 using version_1::static_name_t;
00107 using version_1::aggregate_name_t;
00108 
00109 } // namespace adobe
00110 
00111 /*************************************************************************************************/
00112 
00113 namespace boost {
00114 
00115 template <> struct is_pod<adobe::name_t> : boost::mpl::true_ { };
00116     // implies has_nothrow_constructor and has_nothrow_copy
00117 
00118 }
00119 
00120 /*************************************************************************************************/
00121 
00122 #endif // ADOBE_NAME_FWD_HPP
00123 
00124 /*************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google