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
00024 namespace gnash {
00025
00027 class PropFlags
00028 {
00029
00031 int _flags;
00032
00034
00035
00036 public:
00037
00039 enum Flags {
00040
00042 dontEnum = 1 << 0,
00043
00045 dontDelete = 1 << 1,
00046
00048 readOnly = 1 << 2,
00049
00051 onlySWF6Up = 1 << 7,
00052
00054 ignoreSWF6 = 1 << 8,
00055
00057 onlySWF7Up = 1 << 10,
00058
00060 onlySWF8Up = 1 << 12,
00061
00063 onlySWF9Up = 1 << 13
00064
00065 };
00066
00068 PropFlags() : _flags(0)
00069 {
00070 }
00071
00073 PropFlags(const bool read_only, const bool dont_delete,
00074 const bool dont_enum)
00075 :
00076 _flags(((read_only) ? readOnly : 0) |
00077 ((dont_delete) ? dontDelete : 0) |
00078 ((dont_enum) ? dontEnum : 0))
00079 {
00080 }
00081
00083 PropFlags(const int flags)
00084 : _flags(flags)
00085 {
00086 }
00087
00088 bool operator== (const PropFlags& o) const
00089 {
00090 return ( _flags == o._flags );
00091 }
00092
00093 bool operator!= (const PropFlags& o) const
00094 {
00095 return ( _flags != o._flags );
00096 }
00097
00099 bool get_read_only() const
00100 {
00101 return (_flags & readOnly);
00102 }
00103
00105 void set_read_only() { _flags |= readOnly; }
00106
00108 void clear_read_only() { _flags &= ~readOnly; }
00109
00111 bool get_dont_delete() const
00112 {
00113 return (_flags & dontDelete);
00114 }
00115
00117 void set_dont_delete() { _flags |= dontDelete; }
00118
00120 void clear_dont_delete() { _flags &= ~dontDelete; }
00121
00123 bool get_dont_enum() const
00124 {
00125 return (_flags & dontEnum);
00126 }
00127
00129 void set_dont_enum() { _flags |= dontEnum; }
00130
00132 void clear_dont_enum() { _flags &= ~dontEnum; }
00133
00135 bool get_visible(int swfVersion) const
00136 {
00137 if ( _flags & onlySWF6Up && swfVersion < 6 ) return false;
00138 if ( _flags & ignoreSWF6 && swfVersion == 6 ) return false;
00139 if ( _flags & onlySWF7Up && swfVersion < 7 ) return false;
00140 if ( _flags & onlySWF8Up && swfVersion < 8 ) return false;
00141 if ( _flags & onlySWF9Up && swfVersion < 9 ) return false;
00142 return true;
00143 }
00144
00145 void clear_visible(int swfVersion)
00146 {
00147 if ( swfVersion == 6)
00148 {
00149
00150
00151 _flags &= ~(onlySWF6Up|ignoreSWF6|onlySWF8Up|onlySWF9Up);
00152 }
00153 else
00154 {
00155 _flags &= ~(onlySWF6Up|ignoreSWF6|onlySWF7Up|onlySWF8Up|onlySWF9Up);
00156 }
00157
00158 }
00159
00161 int get_flags() const { return _flags; }
00162
00176 bool set_flags(const int setTrue, const int setFalse = 0)
00177 {
00178 _flags &= ~setFalse;
00179 _flags |= setTrue;
00180 return true;
00181 }
00182 };
00183
00184 inline std::ostream&
00185 operator << (std::ostream& os, const PropFlags& fl)
00186 {
00187 os << "(";
00188 if ( fl.get_read_only() ) os << " readonly";
00189 if ( fl.get_dont_delete() ) os << " nodelete";
00190 if ( fl.get_dont_enum() ) os << " noenum";
00191 os << " )";
00192
00193 return os;
00194 }
00195
00196
00197
00198 }
00199
00200 #endif // GNASH_AS_PROP_FLAGS_H