#include <libsswf.h>
The ErrorManager class is used to let the library call one of your function to handle the error (i.e. so you can print out the message, exit your program, etc.)
The callback happens at the time the error occurs.
At this time, only the TagHeader derives from this object. All the tags and the Actions call the sswf::ErrorManager::OnError() function.
This enumeration is a list of the different errors that can occur while using the SSWF library. Most errors are considered bad and should not happen.
To catch the errors, derive from the ErrorHandler sub-class and implement the ErrorManager::ErrorHandler::OnError(error_code_t errcode, const char *message, va_list args) function.
If your function generates multiple errors or call sub-functions which themselves can generate multiple errors, then you can use the KeepFirst(error_code_t a, error_code_t b) function to make sure that you keep the first error.
ec = ErrorManager::ERROR_CODE_NONE; ... ec = ErrorManager::KeepFirst(ec, SaveMore(obj[idx])); ... return ec;
ERROR_CODE_NONE |
No error occured.
This value should never be passed via the OnError() function. However, some functions return an error and this value can be used when the function does not generate an error.
|
ERROR_CODE_ACTION_OVERFLOW |
Trying to add too many actions in the same buffer.
Action buffers are limited in the number of actions they can record. In general this is about 64Kb of action data including constant strings, dictionaries, etc. In some circumstances, only 255 bytes are available.
|
ERROR_CODE_ALPHA_MISMATCH | |
ERROR_CODE_BAD_STATE_FLAGS | |
ERROR_CODE_BAD_STRING | |
ERROR_CODE_BUTTON_MISSING_STATE |
Buttons do not work without at least one state.
This errors tells you that you are trying to save a button which has no states whatsoever.
|
ERROR_CODE_CANNOT_CHANGE_STYLE | |
ERROR_CODE_CHILDREN_NOT_SUPPORTED |
Tag passed as parent cannot accept children.
Whenever a tag is created, you need to specify a parent tag. However, most tags do not accept children. These tags will generate this error when used as a parent of another tag. At this time, only an sswf::TagHeader and sswf::TagSprite can be used as a parent.
|
ERROR_CODE_COMPRESSED_SOUND_8BITS |
Library cannot compress 8 bits sound data.
Only 16 bits sound data can be compressed at this time. The library may later be capable of converting the 8 bits sound data in a 16 bits buffer ready for compression.
|
ERROR_CODE_EMPTY_POSITION_RANGE | |
ERROR_CODE_ENDED_ACTION_SCRIPT |
The END action was found before the end.
This error occurs when the list of actions includes an END action within the list instead of being at the end. There is usually no need for you to include the END action so just don't do so and let the system close your list of actions as expected.
|
ERROR_CODE_END_OF_STATES | |
ERROR_CODE_ENHANCED_LINE_REQUIRES_ALPHA | |
ERROR_CODE_ENVELOPE_EXISTS | |
ERROR_CODE_ENVELOPE_OVERFLOW | |
ERROR_CODE_ERRONEOUS_FORMAT | |
ERROR_CODE_FILE_NOT_FOUND | |
ERROR_CODE_FORMAT_LOCKED | |
ERROR_CODE_GLYPH_DEFINED_TWICE | |
ERROR_CODE_ICONV_ENCODER_NOT_AVAILABLE | |
ERROR_CODE_ICONV_FAILED | |
ERROR_CODE_IO | |
ERROR_CODE_INCOMPATIBLE_CHILD |
Parent refused that child (by type).
Whenever a tag is created, you need to specify a parent tag; except for the sswf::TagHeader object which represents the root tag. The parent tag checks whether it can accept the child depending on its type. If not, an error is generated and the new tag will have no parent. The only two tags which currently accept children are the sswf::TagHeader and sswf::TagSprite. The sswf::TagSprite has rather limited number of tags which can be added as a child.
|
ERROR_CODE_INCOMPATIBLE_MORPH | |
ERROR_CODE_INTERNAL_ERROR |
An error which should never occur!
This indicates a problem in logic in the library. Please report such errors if you can produce them!
|
ERROR_CODE_INVALID_DEPTH | |
ERROR_CODE_INVALID_EM_SQUARE | |
ERROR_CODE_INVALID_FILL_PARAMETER | |
ERROR_CODE_INVALID_FOCAL | |
ERROR_CODE_INVALID_GLYPH | |
ERROR_CODE_INVALID_IDENTIFIER | |
ERROR_CODE_INVALID_IMAGE | |
ERROR_CODE_INVALID_INTERPOLATION_MODE | |
ERROR_CODE_INVALID_LINE_INFO | |
ERROR_CODE_INVALID_MORPH_INDEX | |
ERROR_CODE_INVALID_OBJECT_EXPORTED | |
ERROR_CODE_INVALID_POSITION | |
ERROR_CODE_INVALID_SHAPE | |
ERROR_CODE_INVALID_SPREAD_MODE | |
ERROR_CODE_INVALID_SPRITE_DEFINITION | |
ERROR_CODE_INVALID_STYLE | |
ERROR_CODE_INVALID_TEXT_SETUP | |
ERROR_CODE_JPEG | |
ERROR_CODE_LOOP_ZERO | |
ERROR_CODE_MISSING_FRAME_NAME |
A required frame name is missing.
Some objects such as the WaitForFrame action need to be given the name of a frame to properly be defined. This error occurs if the name was not defined or set to the empty string.
|
ERROR_CODE_MISSING_SHAPE | |
ERROR_CODE_MORPH_GRADIENT_LIMIT | |
ERROR_CODE_MORPH_REQUIRES_ALPHA | |
ERROR_CODE_NAME_TOO_LONG | |
ERROR_CODE_NEGATIVE_MITER | |
ERROR_CODE_NO_FOCAL_WITH_MORPH | |
ERROR_CODE_NO_HEADER | |
ERROR_CODE_NO_STATES | |
ERROR_CODE_NO_SUCH_GLYPH | |
ERROR_CODE_LABEL_NOT_FOUND |
No label corresponding to a branch instruction was found.
Branch instructions specify the name of a label to which they jump. No label with that name could be found in the label block of action at the same level. This happens when the label was not added or when the label is in a sub-block or a parent block (i.e. you cannot branch from within a With action block to outside of that block.)
|
ERROR_CODE_LABEL_OVERFLOW |
A label is too far from a corresponding branch.
The distance between a label and a corresponding branch is limited by the offset one can use with the branch instructions. If the label is too far (i.e. more than 32Kb before or after), the branch cannot be used and the library generates this error.
|
ERROR_CODE_MORPH_MISMATCH | |
ERROR_CODE_NOT_ENOUGH_DATA | |
ERROR_CODE_OBJECT_NOT_FOUND |
An object or a tag could not be found.
Different functions use references to other objects or tags. This error occurs if a named object or tag cannot be found in the list of tags. Verify the names and try again.
|
ERROR_CODE_REGISTER_OVERFLOW |
Too large a register number was specified.
Registers are limited to 0, 1, 2 and 3 in older versions of SWF. In version 7 and over, registers 0 to 255 can be used (255 seems to be special in some ways though!) within a function. If a register number larger than what is allowed is used, the library generates this error.
|
ERROR_CODE_SIZE_MISMATCH | |
ERROR_CODE_START_SOUND_NO_INFO |
Cannot create a StartSound tag without information about the sound.
This error occurs when a StartSound tag is saved without some sound information (i.e. what sound needs to be started?!)
|
ERROR_CODE_TOO_MANY_STYLES | |
ERROR_CODE_TWO_OR_MORE_JPEGTABLES | |
ERROR_CODE_TWO_OR_MORE_METADATA | |
ERROR_CODE_UNEXPECTED_EVENT_FLAG | |
ERROR_CODE_UNKNOWN_ACTION | |
ERROR_CODE_UNKNOWN_FORMAT | |
ERROR_CODE_UNKNOWN_IMMEDIATE_DATA_TYPE | |
ERROR_CODE_UNKNOWN_OBJECT_EXPORTED | |
ERROR_CODE_UNKNOWN_TAG | |
ERROR_CODE_UNSUPPORTED_IMAGE_FORMAT | |
ERROR_CODE_UNSUPPORTED_SOUND_FORMAT |
The library does not currently support this sound format.
Thought the specified sound format is a valid SWF format, it is not currently supported by the library.
|
ERROR_CODE_UNSUPPORTED_ZONE_COUNT | |
ERROR_CODE_VERSION_UNSATISFIED | |
ERROR_CODE_VOLUME_OUT_OF_RANGE | |
ERROR_CODE_max |
The last error + 1.
This value represents the last error + 1. |
ErrorManager::ErrorManager | ( | void | ) |
The constructor sets the number of errors to zero and the error handler pointer to null.
References f_error_count, and f_error_handler.
int ErrorManager::Count | ( | void | ) | const |
This function can be used to retrieve the current error counter. This is set to zero on creation of an error manager and whenever the Reset() function is called.
You can use this counter to print out the total number of errors which occured once a function you called returns.
sswf::ErrorManager::OnError(error_code_t errcode, const char *message, va_list args) const
sswf::ErrorManager::OnError(error_code_t errcode, const char *message, ...) const
References f_error_count.
ErrorManager::error_code_t ErrorManager::KeepFirst | ( | error_code_t | a, | |
error_code_t | b | |||
) | [static] |
This function returns the first error code (a) if it is not ErrorManager::ERROR_CODE_NONE, otherwise it returns the second error code (b).
This is used in many functions where an error does not stop the function processing. Instead the very first error generated is kept and returned to the caller.
This is especially useful to generate as many errors as possible without requiring the user to re-run the Save() process 100 times if there are 100 errors.
sswf::ErrorManager::OnError(error_code_t errcode, const char *msg)
References ERROR_CODE_NONE.
Referenced by sswf::TagHeader::Save(), sswf::TagExport::Save(), sswf::TagEditText::Save(), sswf::Action::Save(), sswf::ActionWaitForFrame::SaveData(), sswf::ActionURL::SaveData(), sswf::ActionTry::SaveData(), sswf::ActionPushData::SaveData(), sswf::ActionFunction::SaveData(), and sswf::Action::SaveList().
ErrorManager::error_code_t ErrorManager::OnError | ( | error_code_t | errcode, | |
const char * | message, | |||
... | ||||
) | const |
This function is called by the library whenever an error occurs (you can also call it yourself).
The message and following arguments are defined as for printf(3C).
This function simple calls the sswf::ErrorManager::OnError(error_code_t errcode, const char *message, va_list args) const
[in] | errcode | On of the ERROR_CODE_... values |
[in] | message | The message, can include formatting characters |
[in] | ... | The arguments for the message formatting characters |
sswf::ErrorManager::OnError(error_code_t errcode, const char *message, va_list args) const
Reimplemented in sswf::TagHeader.
References OnError().
ErrorManager::error_code_t ErrorManager::OnError | ( | error_code_t | errcode, | |
const char * | message, | |||
va_list | args | |||
) | const |
This function is called by the library whenever an error occurs (you can also call it yourself).
The message and following arguments are defined as for vprintf(3C).
The error code is defined as one of the ErrorManager error code.
Each time this function is called, the number of errors is increased. You can use the sswf::ErrorManager::Count(void) const function to retrieve the value of the current counter.
There is no level for errors. All are considered as errors, some are fatal meaning that the process in progress will end immediately.
[in] | errcode | On of the ERROR_CODE_... values |
[in] | message | The message, can include formatting characters |
[in] | args | The arguments for the message formatting characters |
sswf::ErrorManager::OnError(error_code_t errcode, const char *message, ...) const
Reimplemented in sswf::TagHeader.
References f_error_count, f_error_handler, and sswf::ErrorManager::ErrorHandler::OnError().
Referenced by sswf::SoundInfo::AddEnvelope(), sswf::TagHeader::OnError(), OnError(), sswf::Style::operator==(), sswf::SoundInfo::PreSave(), sswf::TagHeader::Save(), sswf::State::Save(), sswf::Style::Save(), sswf::TagHeader::SaveEncodedString(), sswf::Style::SetBitmap(), sswf::Style::SetColor(), sswf::State::SetFlags(), sswf::Style::SetGradient(), sswf::Style::SetGradientFocal(), sswf::Style::SetGradientModes(), sswf::Style::SetLine(), sswf::Style::SetLineCaps(), sswf::Style::SetLineFillStyle(), sswf::Style::SetLineJoin(), sswf::SoundInfo::SetLoop(), sswf::Style::SetMatrix(), sswf::SoundInfo::SetRange(), sswf::SoundInfo::SetSoundID(), and sswf::Style::SetType().
void ErrorManager::Reset | ( | void | ) |
This function resets the error counter. The counter is set to zero on creation of an ErrorManager object. It is increased each time the OnError() function is called and can be retrieved using the Count() function.
sswf::ErrorManager::OnError(error_code_t errcode, const char *message, va_list args) const
sswf::ErrorManager::OnError(error_code_t errcode, const char *message, ...) const
References f_error_count.
ErrorManager::ErrorHandler * ErrorManager::SetErrorHandler | ( | ErrorManager::ErrorHandler * | error_handler | ) |
This function is called to define the pointer to use as the error handler pointer.
The function returns the current error handler. You may either call it or ignore it from within your function. By calling it you in effect create a chain and all error handlers can be called in this way.
class MyStuff { public: void AddHandler(ErrorHandler *handler) { f_handlers += handler; } std::vector<ErrorHandler*> f_handlers; error_code_t OnError(error_code_t errcode, ...) { for(i = 0; i < f_handlers.size(); ++i) { f_handlers[i].OnError(errcode, ...); } return errcode; } };
void sswf_error_manager_set_callback(struct SSWF_ErrorManager *error_manager, sswf_error_manager_on_error_callback callback);
The error_manager pointer is taken by casting your tag header as required.
[in] | error_handler | The handler to attach to this error manager |
References f_error_handler.
int sswf::ErrorManager::f_error_count [mutable, private] |
Referenced by Count(), ErrorManager(), OnError(), and Reset().
ErrorHandler* sswf::ErrorManager::f_error_handler [private] |
Referenced by ErrorManager(), OnError(), and SetErrorHandler().