File size: 6,004 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
/** @file */
// -------------------------------------------------------------------------
// object which allow to parse upon generic JSON structure and format it back
//
//
class JsonApiStruct : Managed
{
void JsonApiStruct()
{
}
void ~JsonApiStruct()
{
}
/**
\brief Event when expand (unpack) process starts
*/
void OnExpand()
{
}
/**
\brief Event when pack starts - you will pack your stuff here
*/
void OnPack()
{
Print( "OnPack() ");
}
/**
\brief Verification event after successfull JSON packing
*/
void OnBufferReady()
{
}
/**
\brief Event called when pending store operation is finished - callback from JsonApiHandle before handle release
*/
void OnSuccess( int errorCode )
{
// errorCode is EJsonApiError
}
/**
\brief Event called when pending store operation is finished - callback from JsonApiHandle before handle release
*/
void OnError( int errorCode )
{
// errorCode is EJsonApiError
}
/**
\brief Called when parsing object
*/
void OnObject( string name )
{
Print( "OnObject: " + name );
}
/**
\brief Called when parsing integer value
*/
void OnInteger( string name, int value )
{
Print( "OnInteger: " + value );
}
/**
\brief Called when parsing float value
*/
void OnFloat( string name, float value )
{
Print( "OnFloat: " + value );
}
/**
\brief Called when parsing boolean value
*/
void OnBoolean( string name, bool value )
{
Print( "OnBoolean: " + value );
}
/**
\brief Called when parsing string value
*/
void OnString( string name, string value )
{
Print( "OnString: " + value );
}
/**
\brief Called when parsing vector value
*/
void OnVector( string name, vector value )
{
Print( "OnVector: " + value );
}
/**
\brief Called when parsing array
*/
void OnStartArray( string name )
{
Print( "OnStartArray: " + name );
}
/**
\brief Called when array end, returns count of items
*/
void OnEndArray( int itemCount )
{
Print( "OnEndArray: " + itemCount );
}
/**
\brief Called when parsing object
*/
void OnItemObject( int index, string name )
{
Print( "OnItemObject: " + name );
}
/**
\brief Called when parsing integer value
*/
void OnItemInteger( int index, int value )
{
Print( "OnItemInteger: " + value );
}
/**
\brief Called when parsing float value
*/
void OnItemFloat( int index, float value )
{
Print( "OnItemFloat: " + value );
}
/**
\brief Called when parsing boolean value
*/
void OnItemBoolean( int index, bool value )
{
Print( "OnItemBoolean: " + value );
}
/**
\brief Called when parsing string value from array
*/
void OnItemString( int index, string value )
{
Print( "OnItemString: " + value );
}
/**
\brief Called when parsing vector value from array
*/
void OnItemVector( int index, vector value )
{
Print( "OnItemVector: " + value );
}
/**
\brief Register script variable for auto-feature
*/
proto native void RegV( string name );
/**
\brief Push object to parse (only during parse operation)
*/
proto native void Push( JsonApiStruct obj );
/**
\brief Start object at hierarchy - !!! Be cautious and doublecheck results when using this !!!
*/
proto native void StartObject( string name );
/**
\brief End object at hierarchy - !!! Be cautious and doublecheck results when using this !!!
*/
proto native void EndObject();
/**
\brief Add scripted object to hierarchy (calls through hierarchy)
*/
proto native void StoreObject( string name, JsonApiStruct obj );
/**
\brief Add float value to hierarchy
*/
proto native void StoreFloat( string name, float value );
/**
\brief Add integer value to hierarchy
*/
proto native void StoreInteger( string name, int value );
/**
\brief Add boolean value to hierarchy
*/
proto native void StoreBoolean( string name, bool value );
/**
\brief Add string value to hierarchy
*/
proto native void StoreString( string name, string value );
/**
\brief Add vector value to hierarchy
*/
proto native void StoreVector( string name, vector value );
/**
\brief Start array at hierarchy - !!! Be cautious and doublecheck results when using this !!!
*/
proto native void StartArray( string name );
/**
\brief End array at hierarchy - !!! Be cautious and doublecheck results when using this !!!
*/
proto native void EndArray();
/**
\brief Add scripted unnamed/ array object
*/
proto native void ItemObject( JsonApiStruct obj );
/**
\brief Add unnamed/ array float value
*/
proto native void ItemFloat( float value );
/**
\brief Add unnamed/ array integer value
*/
proto native void ItemInteger( int value );
/**
\brief Add unnamed/ array boolean value
*/
proto native void ItemBoolean( bool value );
/**
\brief Add unnamed/ array string value
*/
proto native void ItemString( string value );
/**
\brief Add unnamed/ array vector value
*/
proto native void ItemVector( vector value );
/**
\brief Call this when you've done packing or unpacking (interrupt operation)
*/
proto native void SetDone();
/**
\brief Call this when you've done packing or unpacking + want to generate error - prevent to send invalid data etc.
*/
proto native void SetFail();
/**
\brief Start object packing - when it can be done (when sending remote etc.)
*/
proto native void Pack();
/**
\brief Start object packing now - for use at main thread only!
*/
proto native void InstantPack();
/**
\brief Start object unpacking from RAW string data
*/
proto native void ExpandFromRAW( string data );
/**
\brief Get packed JSON as string (!only if you called Pack() first, it may return null)
*/
proto native string AsString();
/**
\brief Pack() and save JSON to file
*/
proto native bool PackToFile( string FileName );
/**
\brief Save JSON to file (only If something was loaded or recieved previously!)
*/
proto native bool SaveToFile( string FileName );
/**
\brief Load JSON from file and Expand
*/
proto native bool LoadFromFile( string FileName );
};
|