Changeset 752


Ignore:
Timestamp:
May 30, 2007 12:19:11 AM (14 years ago)
Author:
dkearney
Message:

added use of RPENC_HDR flag in decode function so users can give the RPENC_Z and RPENC_B64 flags and tell the decode function to only use those flags
if the header does not say how to treat the data.

in library.tcl, added a -decode flag set to yes by default. this flag allows the user to tell if they want the data to be automatically decoded when
it is retrieved from the xmlobj. this is paricaularly useful for dx data held within a field where we do not want the data automatcially decoded.

added the -decode no flag to dx data being retrieved from fields

updated nanovis.cpp with capability to decode data with the new @@RP-ENC: style headers.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/field.tcl

    r738 r752  
    639639            #
    640640            set _comp2dims($cname) "3D"
    641             set _comp2dx($cname) [$_field get $cname.dx]
     641            set _comp2dx($cname) [$_field get -decode no $cname.dx]
    642642            set _comp2style($cname) [$_field get $cname.style]
    643643            incr _counter
  • trunk/src2/core/RpEncode.cc

    r751 r752  
    129129    int decompress            = 0;
    130130    int base64                = 0;
     131    int checkHDR              = 0;
    131132    Rappture::Outcome err;
    132133    Rappture::Buffer outData;
     
    138139        base64 = 1;
    139140    }
     141    if ((flags & RPENC_HDR) == RPENC_HDR ) {
     142        checkHDR = 1;
     143    }
    140144
    141145    if ((buf.size() > 11) && (strncmp(buf.bytes(),"@@RP-ENC:z\n",11) == 0)) {
    142146        outData.append(buf.bytes()+11,buf.size()-11);
    143         if ( (decompress == 0) && (base64 == 0) ) {
     147        if ( (checkHDR == 1) || ( (decompress == 0) && (base64 == 0) ) ) {
    144148            decompress = 1;
    145149            base64 = 0;
     
    148152    else if ((buf.size() > 13) && (strncmp(buf.bytes(),"@@RP-ENC:b64\n",13) == 0)) {
    149153        outData.append(buf.bytes()+13,buf.size()-13);
    150         if ( (decompress == 0) && (base64 == 0) ) {
     154        if ( (checkHDR == 1) || ( (decompress == 0) && (base64 == 0) ) ) {
    151155            decompress = 0;
    152156            base64 = 1;
     
    155159    else if ((buf.size() > 14) && (strncmp(buf.bytes(),"@@RP-ENC:zb64\n",14) == 0)) {
    156160        outData.append(buf.bytes()+14,buf.size()-14);
    157         if ( (decompress == 0) && (base64 == 0) ) {
     161        if ( (checkHDR == 1) || ( (decompress == 0) && (base64 == 0) ) ) {
    158162            decompress = 1;
    159163            base64 = 1;
  • trunk/tcl/scripts/library.tcl

    r702 r752  
    171171    public method parent {args}
    172172    public method children {args}
    173     public method get {{path ""}}
     173    public method get {args}
    174174    public method put {args}
    175175    public method copy {path from args}
     
    435435
    436436# ----------------------------------------------------------------------
    437 # USAGE: get ?<path>?
    438 #
    439 # Clients use this to query the value of a node.  If the path is not
     437# USAGE: get ?-decode yes? ?<path>?
     438#
     439# Clients use this to query the value of a node. Clients can specify
     440# if they want the data to be automatically decoded or no using the
     441# -decode flag. This is useful for situations where you want to keep
     442# the data encoded to pass to another system, like dx data in fields
     443# sending data to nanovis. If the path is not
    440444# specified, it returns the value associated with the root node.
    441445# Otherwise, it returns the value for the element specified by the
    442446# path.
    443447# ----------------------------------------------------------------------
    444 itcl::body Rappture::LibraryObj::get {{path ""}} {
     448itcl::body Rappture::LibraryObj::get {args} {
     449    array set params {
     450        -decode yes
     451    }
     452    while {[llength $args] > 0} {
     453        set first [lindex $args 0]
     454        if {[string index $first 0] == "-"} {
     455            set choices [array names params]
     456            if {[lsearch $choices $first] < 0} {
     457                error "bad option \"$first\": should be [join [lsort $choices] {, }]"
     458            }
     459            set params($first) [lindex $args 1]
     460            set args [lrange $args 2 end]
     461        } else {
     462            break
     463        }
     464    }
     465    if {[llength $args] > 1} {
     466        error "wrong # args: should be \"get ?-decode yes? ?path?\""
     467    }
     468    if {[llength $args] == 1} {
     469        set path [lindex $args 0]
     470    } else {
     471        set path ""
     472    }
     473
    445474    set node [find $path]
    446475    if {$node == ""} {
    447476        return ""
    448477    }
    449     return [Rappture::encoding::decode [string trim [$node text]]]
     478    if {$params(-decode) == "yes"} {
     479        return [Rappture::encoding::decode [string trim [$node text]]]
     480    } else {
     481        return [string trim [$node text]]
     482    }
    450483}
    451484
  • trunk/vizservers/nanovis/nanovis.cpp

    r720 r752  
    3333#include "RpFieldRect3D.h"
    3434#include "RpFieldPrism3D.h"
    35 #include "RpBuffer.h"
     35#include "RpEncode.h"
    3636
    3737//transfer function headers
     
    818818            }
    819819
    820             err = buf.decode();
     820            // err = buf.decode();
     821            err = Rappture::encoding::decode(buf,RPENC_Z|RPENC_B64|RPENC_HDR);
    821822            if (err) {
    822823                Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);
Note: See TracChangeset for help on using the changeset viewer.