Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GNASH_AS_PROP_FLAGS_H
00020 #define GNASH_AS_PROP_FLAGS_H
00021
00022 #include <ostream>
00023 #include <boost/cstdint.hpp>
00024
00025 namespace gnash {
00026
00028 class PropFlags
00029 {
00030 public:
00031
00033 enum Flags {
00034
00036 dontEnum = 1 << 0,
00037
00039 dontDelete = 1 << 1,
00040
00042 readOnly = 1 << 2,
00043
00045 onlySWF6Up = 1 << 7,
00046
00048 ignoreSWF6 = 1 << 8,
00049
00051 onlySWF7Up = 1 << 10,
00052
00054 onlySWF8Up = 1 << 12,
00055
00057 onlySWF9Up = 1 << 13
00058
00059 };
00060
00062 PropFlags()
00063 :
00064 _flags(0)
00065 {
00066 }
00067
00069 PropFlags(const bool read_only, const bool dont_delete,
00070 const bool dont_enum)
00071 :
00072 _flags(((read_only) ? readOnly : 0) |
00073 ((dont_delete) ? dontDelete : 0) |
00074 ((dont_enum) ? dontEnum : 0))
00075 {
00076 }
00077
00079 PropFlags(boost::uint16_t flags)
00080 :
00081 _flags(flags)
00082 {
00083 }
00084
00085 bool operator==(const PropFlags& o) const {
00086 return (_flags == o._flags);
00087 }
00088
00089 bool operator!=(const PropFlags& o) const {
00090 return !(*this == o);
00091 }
00092
00093 template<Flags f>
00094 bool test() const {
00095 return (_flags & f);
00096 }
00097
00099 bool get_visible(int swfVersion) const {
00100 if (test<onlySWF6Up>() && swfVersion < 6) return false;
00101 if (test<ignoreSWF6>() && swfVersion == 6) return false;
00102 if (test<onlySWF7Up>() && swfVersion < 7) return false;
00103 if (test<onlySWF8Up>() && swfVersion < 8) return false;
00104 if (test<onlySWF9Up>() && swfVersion < 9) return false;
00105 return true;
00106 }
00107
00108 void clear_visible(int swfVersion) {
00109 if (swfVersion == 6) {
00110
00111
00112 _flags &= ~(onlySWF6Up|ignoreSWF6|onlySWF8Up|onlySWF9Up);
00113 }
00114 else {
00115 _flags &= ~(onlySWF6Up|ignoreSWF6|onlySWF7Up|onlySWF8Up|onlySWF9Up);
00116 }
00117 }
00118
00120 boost::uint16_t get_flags() const { return _flags; }
00121
00130 bool set_flags(boost::uint16_t setTrue, boost::uint16_t setFalse = 0) {
00131 _flags &= ~setFalse;
00132 _flags |= setTrue;
00133 return true;
00134 }
00135
00136 private:
00137
00139 boost::uint16_t _flags;
00140
00141 };
00142
00143 inline std::ostream&
00144 operator<<(std::ostream& os, const PropFlags& fl)
00145 {
00146 os << "(";
00147 if (fl.test<PropFlags::readOnly>()) os << " readonly";
00148 if (fl.test<PropFlags::dontDelete>()) os << " nodelete";
00149 if (fl.test<PropFlags::dontEnum>()) os << " noenum";
00150 os << " )";
00151 return os;
00152 }
00153
00154
00155
00156 }
00157
00158 #endif // GNASH_AS_PROP_FLAGS_H