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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.