QByteArray sourceData ; QByteArray lzoData ; // ... // Load sourceData by your own code // ... if ( ToLZO ( sourceData , lzoData ) ) { // handling LZO compressed data } else { // error when compress data into LZO format } |
QByteArray sourceData ;
QtLzo L ; QVariantList v ; v << level ; v << method ; r = L . BeginCompress ( v ) ; if ( L . IsCorrect ( r ) ) { L . doCompress ( sourceData , lzoData ) ; } ; |
QByteArray sourceData ;
QtLzo L ; QVariantList v ; v << level ; // default 9 v << method ; // default LZO1x r = L . BeginCompress ( v ) ; r = L . doSection ( sourceData , lzoData ) ; |
QByteArray sourceData ; QByteArray lzoData ; // ... // Load lzoData by your own code // ... if ( FromLZO ( lzoData , sourceData ) ) { // handling sourceData } else { // error when decompress LZO data into sourceData } |
QByteArray sourceData ; QByteArray lzoData ; QtLzo L ; int r ; r = L . BeginDecompress ( ) ; if ( L . IsCorrect ( r ) ) { L . doDecompress ( lzoData , sourceData ) ; } ; |
QByteArray sourceData ; QByteArray lzoData ; int r ; r = L . BeginDecompress ( ) ; r = L . undoSection ( lzoData , sourceData ) ; if ( L . IsCorrect ( r ) ) { } ;
} ; } ; |
QByteArray sourceData ; // ... // Obtain sourceData by your own code // ... if ( SaveLZO ( "LzoFilename.lzo" , sourceData ) ) { // successful compress sourceData into LzoFilename.lzo file } else { // error to compress into LZO file } |
QByteArray sourceData ; if ( LoadLZO ( "LzoFilename.lzo" , sourceData ) ) { // successful decompress LzoFilename.lzo file into sourceData } else { // error to decompress LZO file } |
if ( LzoToFile ( "LzoFilename.lzo" ,
"NormalFilename.dat" ) ) { // successful decompress LzoFilename.lzo file into NormalFilename.dat } else { // error to decompress LZO file } |
if ( FileToLzo ( "NormalFilename.dat" ,
"LzoFilename.lzo" ) ) { // successful compress NormalFilename.dat into LzoFilename.lzo } else { // error to compress into LZO file } |
QScriptValue AttachmentLzo(QScriptContext * context,QScriptEngine * engine) {
ScriptableLzo * lzo = new ScriptableLzo ( engine ) ; return engine -> newQObject ( lzo ) ; }
bool JsLzo(QString ifile,QString entry) {
QString m ; QByteArray SCRIPT ; //////////////////////////////////////////////////////////////////////////// if ( ( ! LoadAll ( ifile , SCRIPT ) ) || ( SCRIPT . size ( ) <= 0 ) ) { return false ; } ; //////////////////////////////////////////////////////////////////////////// QScriptEngine Engine ; QString script ; QScriptValue func ; QScriptValue global ; QScriptValue lzo ; QScriptValue again ; QScriptValueList args ; //////////////////////////////////////////////////////////////////////////// script = QString::fromUtf8 ( SCRIPT ) ; func = Engine . evaluate ( script ) ; global = Engine . globalObject ( ) ; global . setProperty ( "QtLZO" , Engine . newFunction ( AttachmentLzo ) ) ; lzo = global . property ( entry ) ; //////////////////////////////////////////////////////////////////////////// if ( lzo . isFunction ( ) ) { again = lzo . call ( func , args ) ; } else { // function entry can not be found in ifile. return false ; } ; //////////////////////////////////////////////////////////////////////////// return true ; |
function CompressLZO()
{ lzo = new QtLZO() ; lzo . ToLzo ( "Testing.txt" , "Testing.lzo" , 9 , 1 ) ; delete lzo ; } function DecompressLZO() { lzo = new QtLZO() ; lzo . ToFile ( "Testing.lzo" , "Testing.txt" ) ; delete lzo ; } |