{
class Base64Writer;
- enum Base64State
+ namespace fs
{
- Uncertain,
- NotUse,
- InUse,
- };
+ enum State
+ {
+ Uncertain,
+ NotUse,
+ InUse,
+ };
+ }
}
#define CV_XML_OPENING_TAG 1
base64::Base64Writer * base64_writer;
bool is_default_using_base64;
- base64::Base64State state_of_writing_base64; /**< used in WriteRawData only */
+ base64::fs::State state_of_writing_base64; /**< used in WriteRawData only */
bool is_write_struct_delayed;
char* delayed_struct_key;
return std::find(params.begin(), params.end(), param) != params.end();
}
-static void switch_to_Base64_state( CvFileStorage* fs, base64::Base64State state )
+static void switch_to_Base64_state( CvFileStorage* fs, base64::fs::State state )
{
const char * err_unkonwn_state = "Unexpected error, unable to determine the Base64 state.";
const char * err_unable_to_switch = "Unexpected error, unable to switch to this state.";
/* like a finite state machine */
switch (fs->state_of_writing_base64)
{
- case base64::Base64State::Uncertain:
+ case base64::fs::Uncertain:
switch (state)
{
- case base64::Base64State::InUse:
+ case base64::fs::InUse:
CV_DbgAssert( fs->base64_writer == 0 );
fs->base64_writer = new base64::Base64Writer( fs );
break;
- case base64::Base64State::Uncertain:
+ case base64::fs::Uncertain:
break;
- case base64::Base64State::NotUse:
+ case base64::fs::NotUse:
break;
default:
CV_Error( CV_StsError, err_unkonwn_state );
break;
}
break;
- case base64::Base64State::InUse:
+ case base64::fs::InUse:
switch (state)
{
- case base64::Base64State::InUse:
- case base64::Base64State::NotUse:
+ case base64::fs::InUse:
+ case base64::fs::NotUse:
CV_Error( CV_StsError, err_unable_to_switch );
break;
- case base64::Base64State::Uncertain:
+ case base64::fs::Uncertain:
delete fs->base64_writer;
fs->base64_writer = 0;
break;
break;
}
break;
- case base64::Base64State::NotUse:
+ case base64::fs::NotUse:
switch (state)
{
- case base64::Base64State::InUse:
- case base64::Base64State::NotUse:
+ case base64::fs::InUse:
+ case base64::fs::NotUse:
CV_Error( CV_StsError, err_unable_to_switch );
break;
- case base64::Base64State::Uncertain:
+ case base64::fs::Uncertain:
break;
default:
CV_Error( CV_StsError, err_unkonwn_state );
if ( change_type_to_base64 )
{
fs->start_write_struct( fs, struct_key, struct_flags, "binary");
- if ( fs->state_of_writing_base64 != base64::Base64State::Uncertain )
- switch_to_Base64_state( fs, base64::Base64State::Uncertain );
- switch_to_Base64_state( fs, base64::Base64State::InUse );
+ if ( fs->state_of_writing_base64 != base64::fs::Uncertain )
+ switch_to_Base64_state( fs, base64::fs::Uncertain );
+ switch_to_Base64_state( fs, base64::fs::InUse );
}
else
{
fs->start_write_struct( fs, struct_key, struct_flags, type_name);
- if ( fs->state_of_writing_base64 != base64::Base64State::Uncertain )
- switch_to_Base64_state( fs, base64::Base64State::Uncertain );
- switch_to_Base64_state( fs, base64::Base64State::NotUse );
+ if ( fs->state_of_writing_base64 != base64::fs::Uncertain )
+ switch_to_Base64_state( fs, base64::fs::Uncertain );
+ switch_to_Base64_state( fs, base64::fs::NotUse );
}
delete struct_key;
icvYMLWrite( CvFileStorage* fs, const char* key, const char* data )
{
check_if_write_struct_is_delayed( fs );
- if ( fs->state_of_writing_base64 == base64::Base64State::Uncertain )
+ if ( fs->state_of_writing_base64 == base64::fs::Uncertain )
{
- switch_to_Base64_state( fs, base64::Base64State::NotUse );
+ switch_to_Base64_state( fs, base64::fs::NotUse );
}
- else if ( fs->state_of_writing_base64 == base64::Base64State::InUse )
+ else if ( fs->state_of_writing_base64 == base64::fs::InUse )
{
CV_Error( CV_StsError, "At present, output Base64 data only." );
}
icvXMLWriteScalar( CvFileStorage* fs, const char* key, const char* data, int len )
{
check_if_write_struct_is_delayed( fs );
- if ( fs->state_of_writing_base64 == base64::Base64State::Uncertain )
+ if ( fs->state_of_writing_base64 == base64::fs::Uncertain )
{
- switch_to_Base64_state( fs, base64::Base64State::NotUse );
+ switch_to_Base64_state( fs, base64::fs::NotUse );
}
- else if ( fs->state_of_writing_base64 == base64::Base64State::InUse )
+ else if ( fs->state_of_writing_base64 == base64::fs::InUse )
{
CV_Error( CV_StsError, "Currently only Base64 data is allowed." );
}
fs->base64_writer = 0;
fs->is_default_using_base64 = write_base64;
- fs->state_of_writing_base64 = base64::Base64State::Uncertain;
+ fs->state_of_writing_base64 = base64::fs::Uncertain;
fs->is_write_struct_delayed = false;
fs->delayed_struct_key = 0;
{
CV_CHECK_OUTPUT_FILE_STORAGE(fs);
check_if_write_struct_is_delayed( fs );
- if ( fs->state_of_writing_base64 == base64::Base64State::NotUse )
- switch_to_Base64_state( fs, base64::Base64State::Uncertain );
+ if ( fs->state_of_writing_base64 == base64::fs::NotUse )
+ switch_to_Base64_state( fs, base64::fs::Uncertain );
- if ( fs->state_of_writing_base64 == base64::Base64State::Uncertain
+ if ( fs->state_of_writing_base64 == base64::fs::Uncertain
&&
CV_NODE_IS_SEQ(struct_flags)
&&
/* Must output Base64 data */
if ( !CV_NODE_IS_SEQ(struct_flags) )
CV_Error( CV_StsBadArg, "must set 'struct_flags |= CV_NODE_SEQ' if using Base64.");
- else if ( fs->state_of_writing_base64 != base64::Base64State::Uncertain )
+ else if ( fs->state_of_writing_base64 != base64::fs::Uncertain )
CV_Error( CV_StsError, "function \'cvStartWriteStruct\' calls cannot be nested if using Base64.");
fs->start_write_struct( fs, key, struct_flags, type_name );
- if ( fs->state_of_writing_base64 != base64::Base64State::Uncertain )
- switch_to_Base64_state( fs, base64::Base64State::Uncertain );
- switch_to_Base64_state( fs, base64::Base64State::InUse );
+ if ( fs->state_of_writing_base64 != base64::fs::Uncertain )
+ switch_to_Base64_state( fs, base64::fs::Uncertain );
+ switch_to_Base64_state( fs, base64::fs::InUse );
}
else
{
/* Won't output Base64 data */
- if ( fs->state_of_writing_base64 == base64::Base64State::InUse )
+ if ( fs->state_of_writing_base64 == base64::fs::InUse )
CV_Error( CV_StsError, "At the end of the output Base64, `cvEndWriteStruct` is needed.");
fs->start_write_struct( fs, key, struct_flags, type_name );
- if ( fs->state_of_writing_base64 != base64::Base64State::Uncertain )
- switch_to_Base64_state( fs, base64::Base64State::Uncertain );
- switch_to_Base64_state( fs, base64::Base64State::NotUse );
+ if ( fs->state_of_writing_base64 != base64::fs::Uncertain )
+ switch_to_Base64_state( fs, base64::fs::Uncertain );
+ switch_to_Base64_state( fs, base64::fs::NotUse );
}
}
CV_CHECK_OUTPUT_FILE_STORAGE(fs);
check_if_write_struct_is_delayed( fs );
- if ( fs->state_of_writing_base64 != base64::Base64State::Uncertain )
- switch_to_Base64_state( fs, base64::Base64State::Uncertain );
+ if ( fs->state_of_writing_base64 != base64::fs::Uncertain )
+ switch_to_Base64_state( fs, base64::fs::Uncertain );
fs->end_write_struct( fs );
}
cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt )
{
if (fs->is_default_using_base64 ||
- fs->state_of_writing_base64 == base64::Base64State::InUse )
+ fs->state_of_writing_base64 == base64::fs::InUse )
{
base64::cvWriteRawDataBase64( fs, _data, len, dt );
return;
}
- else if ( fs->state_of_writing_base64 == base64::Base64State::Uncertain )
+ else if ( fs->state_of_writing_base64 == base64::fs::Uncertain )
{
- switch_to_Base64_state( fs, base64::Base64State::NotUse );
+ switch_to_Base64_state( fs, base64::fs::NotUse );
}
const char* data0 = (const char*)_data;
check_if_write_struct_is_delayed( fs, true );
- if ( fs->state_of_writing_base64 == base64::Base64State::Uncertain )
+ if ( fs->state_of_writing_base64 == base64::fs::Uncertain )
{
- switch_to_Base64_state( fs, base64::Base64State::InUse );
+ switch_to_Base64_state( fs, base64::fs::InUse );
}
- else if ( fs->state_of_writing_base64 != base64::Base64State::InUse )
+ else if ( fs->state_of_writing_base64 != base64::fs::InUse )
{
CV_Error( CV_StsError, "Base64 should not be used at present." );
}
* Interface
***************************************************************************/
-void cvWriteMatBase64(::CvFileStorage* fs, const char* name, const ::CvMat* mat)
-{
- ::cv::Mat holder = ::cv::cvarrToMat(mat);
- ::base64::cvWriteMat_Base64(fs, name, holder);
-}
-
-void cvWriteMatNDBase64(::CvFileStorage* fs, const char* name, const ::CvMatND* mat)
-{
- ::cv::Mat holder = ::cv::cvarrToMat(mat);
- ::base64::cvWriteMat_Base64(fs, name, holder);
-}
-
CV_IMPL void cvWriteRawDataBase64(::CvFileStorage* fs, const void* _data, int len, const char* dt)
{
::base64::cvWriteRawDataBase64(fs, _data, len, dt);