Changeset 224


Ignore:
Timestamp:
Feb 28, 2006 9:52:16 AM (15 years ago)
Author:
dkearney
Message:

added support for following functions in rappture core
diff
value
entities
added support for diff function in tcl bindings.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/core/RpLibrary.h

    r205 r224  
    2222#include <time.h>
    2323
     24#include <list>
     25
    2426/* indentation size (in whitespaces) */
    2527#define INDENT_SIZE 4
    2628#define CREATE_PATH 1
    2729#define NO_CREATE_PATH 0
     30#define E_QUEUE_SIZE 100
    2831
    2932#ifndef _RpLIBRARY_H
     
    3841        RpLibrary* element (std::string path = "");
    3942        RpLibrary* parent (std::string path = "");
     43
     44        std::list<std::string> entities  (std::string path = "");
     45        std::list<std::string> value     (std::string path = "");
     46        std::list<std::string> diff      ( RpLibrary* otherLib,
     47                                            std::string path);
     48
    4049
    4150        // should return RpObject& but for simplicity right now it doesnt
     
    7887        std::string nodeComp();
    7988        std::string nodePath();
    80 
    81         int isvalid();
    8289
    8390        void result();
  • trunk/src/core/RpLibrary.cc

    r205 r224  
    501501
    502502/**********************************************************************/
     503// METHOD: entities()
     504/// Search the path of a xml tree and return its next entity.
     505/**
     506 * It is the user's responsibility to delete the object when
     507 * they are finished using it?, else i need to make this static
     508 */
     509
     510std::list<std::string>
     511RpLibrary::entities  (std::string path)
     512{
     513    std::list<std::string> queue;
     514    std::list<std::string>::iterator iter;
     515    std::list<std::string> retList;
     516    std::list<std::string> childList;
     517    std::list<std::string>::iterator childIter;
     518
     519    RpLibrary* ele = NULL;
     520
     521    RpLibrary* child = NULL;
     522    std::string childType = "";
     523    std::string childPath = "";
     524    std::string paramsPath = "";
     525
     526    RpLibrary* cchild = NULL;
     527    std::string cchildType = "";
     528    std::string cchildPath = "";
     529
     530    queue.push_back(path);
     531    iter = queue.begin();
     532
     533    while( iter != queue.end() ) {
     534        ele = this->element(*iter);
     535        child = NULL;
     536
     537        while ( (child = ele->children("",child)) != NULL ) {
     538            childList.push_back(child->nodeComp());
     539        }
     540
     541        childIter = childList.begin();
     542
     543        while (childIter != childList.end()) {
     544            child = ele->element(*childIter);
     545
     546            childType = child->nodeType();
     547            childPath = child->nodePath();
     548            if ( (childType == "group") || (childType == "phase") ) {
     549                // add this path to the queue for paths to search
     550                queue.push_back(childPath);
     551            }
     552            else if (childType == "structure") {
     553                // add this path to the return list
     554                retList.push_back(child->nodeComp());
     555
     556                // check to see if there is a ".current.parameters" node
     557                // if so, add them to the queue list for paths to search
     558                paramsPath = childPath + ".current.parameters";
     559                if (child->element(paramsPath) != NULL) {
     560                    queue.push_back(paramsPath);
     561                }
     562            }
     563            else {
     564                // add this path to the return list
     565                retList.push_back(child->nodeComp());
     566
     567                // look for embedded groups and phases
     568                // add them to the queue list for paths to search
     569                cchild = NULL;
     570                while ( (cchild = child->children("",cchild)) != NULL ) {
     571                    cchildType = cchild->nodeType();
     572                    cchildPath = cchild->nodePath();
     573                    if ( (cchildType == "group") || (cchildType == "phase") ) {
     574                        // add this path to the queue for paths to search
     575                        queue.push_back(cchildPath);
     576                    }
     577                }
     578            }
     579
     580            childList.erase(childIter);
     581            childIter = childList.begin();
     582        }
     583
     584        queue.erase(iter);
     585        iter = queue.begin();
     586    }
     587
     588    return retList;
     589}
     590
     591/**********************************************************************/
     592// METHOD: diff()
     593/// find the differences between two xml trees.
     594/**
     595 */
     596
     597std::list<std::string>
     598RpLibrary::diff (RpLibrary* otherLib, std::string path)
     599{
     600
     601    std::list<std::string> thisVal; // two node list of specific entity's value
     602    std::list<std::string> otherVal; // two node list of specific entity's value
     603
     604    std::list<std::string> thisv; // list of this library's entities
     605    std::list<std::string>::iterator thisIter;
     606
     607    std::list<std::string> otherv; // list of other library's entities
     608    std::list<std::string>::iterator otherIter;
     609
     610    std::list<std::string> retList;
     611
     612    std::string entry = "";
     613    std::string thisSpath = "";  // temp string
     614    std::string otherSpath = ""; // temp string
     615
     616    if ( (!this->root) || (!otherLib->root) ) {
     617        // library doesn't exist, do nothing;
     618        return retList;
     619    }
     620
     621    thisv = this->entities(path);
     622    otherv = otherLib->entities(path);
     623
     624    thisIter = thisv.begin();
     625
     626    while (thisIter != thisv.end() ) {
     627        // reset otherIter for a new search.
     628        otherIter = otherv.begin();
     629        while ( (otherIter != otherv.end()) && (*otherIter != *thisIter) ) {
     630            otherIter++;
     631        }
     632
     633        thisSpath = path + "." + *thisIter;
     634
     635        if (otherIter == otherv.end()) {
     636            // we've reached the end of the search
     637            // and did not find anything, mark this as a '-'
     638            thisVal = this->value(thisSpath);
     639            retList.push_back("-");
     640            retList.push_back(thisSpath);
     641            retList.push_back(thisVal.front());
     642            retList.push_back("");
     643        }
     644        else {
     645
     646            otherSpath = path + "." + *otherIter;
     647
     648            thisVal = this->value(thisSpath);
     649            otherVal = otherLib->value(otherSpath);
     650            if (thisVal.back() != otherVal.back()) {
     651                // add the difference to the return list
     652                retList.push_back("c");
     653                retList.push_back(otherSpath);
     654                retList.push_back(thisVal.front());
     655                retList.push_back(otherVal.front());
     656            }
     657
     658            // remove the last processed value from otherv
     659            otherv.erase(otherIter);
     660        }
     661
     662        // increment thisv's iterator.
     663        thisIter++;
     664    }
     665
     666    // add any left over values in otherv to the return list
     667    otherIter = otherv.begin();
     668    while ( otherIter != otherv.end() ) {
     669
     670        otherSpath = path + "." + *otherIter;
     671
     672        otherVal = otherLib->value(otherSpath);
     673
     674        retList.push_back("+");
     675        retList.push_back(otherSpath);
     676        retList.push_back(otherVal.front());
     677        retList.push_back("");
     678
     679        otherv.erase(otherIter);
     680        otherIter = otherv.begin();
     681    }
     682
     683    return retList;
     684}
     685
     686/**********************************************************************/
     687// METHOD: value(path)
     688/// find the differences between two xml trees.
     689/**
     690 */
     691
     692std::list<std::string>
     693RpLibrary::value (std::string path)
     694{
     695    std::list<std::string> retArr;
     696
     697    std::string raw = "";
     698    std::string val = "";
     699
     700    RpLibrary* ele = NULL;
     701    RpLibrary* tele = NULL;
     702
     703    int childCount = 0;
     704    std::stringstream valStr;
     705
     706    ele = this->element(path);
     707
     708    if (ele != NULL ) {
     709
     710        if (ele->nodeType() == "structure") {
     711            raw = path;
     712            // try to find a label to represent the structure
     713            val = ele->get("about.label");
     714
     715            if (val == "") {
     716               val = ele->get("current.about.label");
     717            }
     718
     719            if (val == "") {
     720               tele = ele->element("current");
     721               if ( (tele != NULL) && (tele->nodeComp() != "") ) {
     722                   tele->children("components",NULL,"",&childCount);
     723                   valStr << "<structure> with " << childCount  << " components";
     724                   val = valStr.str();
     725               }
     726            }
     727
     728        }
     729        /*
     730        else if (ele->nodeType() == "number") {
     731            retArr[0] = "";
     732            retArr[1] = "";
     733            if ( (tele = ele->element("current")) != NULL) {
     734                retArr[0] = tele->get();
     735                retArr[1] = retArr[0];
     736            }
     737            else if ( (tele = ele->element("default")) != NULL) {
     738                retArr[0] = tele->get();
     739                retArr[1] = retArr[0];
     740            }
     741        }
     742        */
     743        else {
     744            raw = "";
     745            if ( (tele = ele->element("current")) != NULL) {
     746                raw = tele->get();
     747            }
     748            else if ( (tele = ele->element("default")) != NULL) {
     749                raw = tele->get();
     750            }
     751            val = raw;
     752        }
     753    }
     754
     755    retArr.push_back(raw);
     756    retArr.push_back(val);
     757
     758    return retArr;
     759}
     760
     761/**********************************************************************/
    503762// METHOD: parent()
    504763/// Search the path of a xml tree and return its parent.
     
    8851144    if (ele) {
    8861145        scew_element_free(ele);
    887         if (setNULL) {
     1146        if (setNULL != 0) {
    8881147            // this is the case where user specified an empty path.
    8891148            // the object is useless, and will be deleted.
    8901149            this->root = NULL;
    891             delete this;
    8921150            retLib = NULL;
    8931151        }
     
    9881246
    9891247    return _node2path(root);
    990 }
    991 
    992 /**********************************************************************/
    993 // METHOD: isvalid()
    994 /// Returns true if the library is a valid Rappture Object with a document root
    995 /**
    996  */
    997 
    998 int
    999 RpLibrary::isvalid ()
    1000 {
    1001     if (!this->root) {
    1002         // library doesn't exist, return false;
    1003         return 0;
    1004     }
    1005 
    1006     return 1;
    10071248}
    10081249
  • trunk/src/tcl/README

    r207 r224  
    44
    55within tclsh
    6     package require RapptureLibrary
     6    package require Rappture
  • trunk/src/tcl/src/RpLibraryTclInterface.cc

    r207 r224  
    33 *  Rappture::library
    44 *
    5  *  This is an interface to the system getrlimit() and setrlimit()
    6  *  routines.  It allows you to get/set resource limits for child
    7  *  executables.  We use this in Rappture::exec, for example, to make
    8  *  sure that jobs don't run forever or fill up the disk.
     5 *  This is an interface to the rappture library module.
     6 *  It allows you to create rappture library objects.
    97 * ======================================================================
    108 *  AUTHOR:  Derrick Kearney, Purdue University
     
    1917// #include <typeinfo.h>
    2018#include "core/RpLibrary.h"
     19#include <sstream>
    2120
    2221#ifdef __cplusplus
     
    3837static int RpTclLibCopy   _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    3938                                        int argc, const char *argv[]    ));
     39static int RpTclLibDiff   _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
     40                                        int argc, const char *argv[]    ));
    4041static int RpTclLibElem   _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    4142                                        int argc, const char *argv[]    ));
    4243static int RpTclLibGet    _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
     44                                        int argc, const char *argv[]    ));
     45static int RpTclLibIsa    _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
    4346                                        int argc, const char *argv[]    ));
    4447static int RpTclLibParent _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,
     
    6568    {"copy", 2, (Blt_Op)RpTclLibCopy, 5, 6,
    6669        "<path> from ?<xmlobj>? <path>",},
     70    {"diff", 1, (Blt_Op)RpTclLibDiff, 3, 3, "<xmlobj>",},
    6771    {"element", 1, (Blt_Op)RpTclLibElem, 2, 5, "?-as <fval>? ?<path>?",},
    6872    {"get", 1, (Blt_Op)RpTclLibGet, 2, 3, "?<path>?",},
     73    {"isa", 1, (Blt_Op)RpTclLibIsa, 3, 3, "<objType>",},
    6974    {"parent", 2, (Blt_Op)RpTclLibParent, 2, 5, "?-as <fval>? ?<path>?",},
    7075    {"put", 2, (Blt_Op)RpTclLibPut, 2, 8,
     
    7681
    7782static int nRpLibOps = sizeof(rpLibOps) / sizeof(Blt_OpSpec);
     83
     84#define RAPPTURE_OBJ_TYPE "::Rappture::LibraryObj"
    7885
    7986#ifdef __cplusplus
     
    115122{
    116123    RpLibrary *rpptr = NULL;
    117     RpLibrary *testObj = NULL;
    118124    std::string libName = "";
    119125    int noerr = 0;
    120     Tcl_CmdInfo* infoPtr = NULL;  // pointer to the command info
     126    std::stringstream result;
     127    Tcl_CmdInfo info;  // pointer to the command info
     128
    121129
    122130    if ( (argc > 2) && (strncmp(argv[1],"isvalid",7) == 0) ) {
     131        result.str("0");
    123132        if (argc != 3) {
    124             std::cout << "wrong # args: should be \"" << argv[0]
    125                 << " isvalid object\"" << std::endl;
     133            Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     134                "\": isvalid object",
     135                (char*)NULL);
    126136            return TCL_ERROR;
    127137        }
    128138
    129         libName = std::string(argv[2]);
    130         std::cout << "argv[2] = " << argv[2] << std::endl;
    131         std::cout << "interp = " << interp << std::endl;
    132         noerr = Tcl_GetCommandInfo(interp, libName.c_str(), infoPtr);
    133         std::cout << "interp = " << interp << std::endl;
    134         if (noerr && infoPtr) {
    135             testObj = (RpLibrary*) (infoPtr->clientData);
    136             // if ( (testObj) && (typeid(RpLibrary) == typeid(testObj)) ) {
    137             if (testObj) {
    138                 // return testObj->isvalid();
    139                 // need a way to try this and catch any errors
    140                 try {
    141                     testObj->isvalid();
    142                     return 1; // return true
    143                 }
    144                 catch (const std::exception& e) {
    145                     return 0; // return false
    146                 }
    147             }
    148             else {
    149                 return 0; // return false
    150             }
    151         }
    152         else {
    153             return 0; // return false
    154         }
     139        noerr = Tcl_GetCommandInfo(interp, argv[2], &info);
     140        if (noerr == 1) {
     141            if (info.proc == &RpLibCallCmd) {
     142                result.clear();
     143                result.str("1");
     144            }
     145        }
     146
     147        Tcl_ResetResult(interp);
     148        Tcl_AppendResult(interp, result.str().c_str(), (char*)NULL);
     149        return TCL_OK;
    155150    }
    156151
    157152    if (argc != 2) {
    158         std::cout << "usage: " << argv[0] << " <xmlfile>" << std::endl;
     153        Tcl_AppendResult(interp, "usage: ", argv[0], " <xmlfile>",(char*)NULL);
    159154        return TCL_ERROR;
    160155    }
     
    165160    libName = rpLib2command(interp,rpptr);
    166161
    167     Tcl_ResetResult(interp);
    168162    Tcl_AppendResult(interp, libName.c_str(), (char*)NULL);
    169 
    170163    return TCL_OK;
    171164}
     
    194187
    195188    if (argc < 2) {
    196         std::cout <<"usage: "<< argv[0] <<" <command> <arg-list>"<< std::endl;
     189        Tcl_AppendResult(interp, "usage: \"", argv[0],
     190            "\": <command> <arg-list>",
     191            (char*)NULL);
    197192        return TCL_ERROR;
    198193    }
     
    325320    int argsLeft         = 0;     // temp variable for calculation
    326321    int noerr              = 0;     // err flag for Tcl_GetCommandInfo
    327     Tcl_CmdInfo* infoPtr = NULL;  // pointer to the command info
     322    Tcl_CmdInfo info;  // pointer to the command info
    328323
    329324    toPath = std::string(argv[nextarg++]);
     
    333328    if (argsLeft == 2) {
    334329        fromObjStr = std::string(argv[nextarg++]);
    335         noerr = Tcl_GetCommandInfo(interp, fromObjStr.c_str(), infoPtr);
    336         if (noerr && infoPtr) {
    337             fromObj = (RpLibrary*) (infoPtr->clientData);
    338         }
    339         fromObj = NULL; // gotta figure out how to get the actual lib here
     330        noerr = Tcl_GetCommandInfo(interp, fromObjStr.c_str(), &info);
     331        if (noerr == 1) {
     332            if (info.proc == RpLibCallCmd) {
     333                fromObj = (RpLibrary*) (info.clientData);
     334            }
     335            else {
     336                Tcl_ResetResult(interp);
     337                Tcl_AppendResult(interp,
     338                    "wrong arg type: xmlobj should be a Rappture Library\"",
     339                    (char*)NULL);
     340                return TCL_ERROR;
     341            }
     342        }
    340343        fromPath = std::string(argv[nextarg++]);
    341344    }
     
    344347    }
    345348    else {
     349        Tcl_ResetResult(interp);
    346350        Tcl_AppendResult(interp,
    347351            "wrong # args: should be \"copy path from ?xmlobj? path\"",
     
    351355
    352356    if (from != "from") {
     357        Tcl_ResetResult(interp);
    353358        Tcl_AppendResult(interp,
    354359            "bad syntax: should be \"copy path from ?xmlobj? path\"",
     
    365370    Tcl_AppendResult(interp, "", (char*)NULL);
    366371
     372    return TCL_OK;
     373}
     374
     375int
     376RpTclLibDiff     (   ClientData cdata,
     377                    Tcl_Interp *interp,
     378                    int argc,
     379                    const char *argv[]  )
     380{
     381
     382    Tcl_CmdInfo info;                // pointer to the command info
     383    std::string otherLibStr = "";
     384    RpLibrary* otherLib     = NULL;
     385    int nextarg             = 2;     // start parsing using the '2'th argument
     386    int argsLeft            = 0;     // temp variable for calculation
     387    int noerr               = 0;     // err flag for Tcl_GetCommandInfo
     388
     389    std::list<std::string> diffList; // list to store the return value
     390                                     // from diff command
     391    std::list<std::string>::iterator diffListIter;
     392
     393    // parse input arguments
     394    argsLeft = (argc-nextarg);
     395    if (argsLeft == 1) {
     396        otherLibStr = std::string(argv[nextarg++]);
     397        noerr = Tcl_GetCommandInfo(interp, otherLibStr.c_str(), &info);
     398        if (noerr == 1) {
     399            if (info.proc == RpLibCallCmd) {
     400                otherLib = (RpLibrary*) (info.clientData);
     401            }
     402            else {
     403                Tcl_ResetResult(interp);
     404                Tcl_AppendResult(interp,
     405                    "wrong arg type: xmlobj should be a Rappture Library\"",
     406                    (char*)NULL);
     407                return TCL_ERROR;
     408            }
     409        }
     410    }
     411    else {
     412        Tcl_ResetResult(interp);
     413        Tcl_AppendResult(interp,
     414            "wrong # args: should be \"diff <xmlobj>\"",
     415            (char*)NULL);
     416        return TCL_ERROR;
     417    }
     418
     419    // perform the diff command
     420    diffList = ((RpLibrary*) (cdata))->diff(otherLib,"input");
     421    diffListIter = diffList.begin();
     422
     423    Tcl_ResetResult(interp);
     424
     425    // parse through the output of the diff command
     426    // put it into the return result
     427    while (diffListIter != diffList.end()) {
     428        Tcl_AppendElement(interp,(*diffListIter).c_str());
     429
     430        // increment the iterator
     431        diffListIter++;
     432    }
     433
     434
     435    // Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL);
    367436    return TCL_OK;
    368437}
     
    473542    std::string path = "";
    474543
    475     if (argc > 2) {
     544    if (argc == 3) {
    476545        path = std::string(argv[2]);
     546    }
     547    else if (argc != 2) {
     548        Tcl_ResetResult(interp);
     549        Tcl_AppendResult(interp,
     550            "wrong # args: should be \"get ?path?\"",
     551            "\":", (char*)NULL);
     552        return TCL_ERROR;
    477553    }
    478554
    479555    // call the Rappture Library Get Function
    480556    retStr = ((RpLibrary*) cdata)->getString(path);
     557
     558    // clear any previous result in the interpreter
     559    // store the new result in the interpreter
     560    Tcl_ResetResult(interp);
     561    Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL);
     562
     563    return TCL_OK;
     564}
     565
     566int
     567RpTclLibIsa     (   ClientData cdata,
     568                    Tcl_Interp *interp,
     569                    int argc,
     570                    const char *argv[]  )
     571{
     572
     573    std::string compVal = ""; // string value of object being compared to
     574    std::string retStr  = ""; // return value of rappture get fxn
     575
     576    if (argc == 3) {
     577        compVal = std::string(argv[2]);
     578    }
     579    else {
     580        Tcl_ResetResult(interp);
     581        Tcl_AppendResult(interp,
     582            "wrong # args: should be \"get ?path?\"",
     583            "\":", (char*)NULL);
     584        return TCL_ERROR;
     585    }
     586
     587    if (compVal == RAPPTURE_OBJ_TYPE) {
     588        retStr = "1";
     589    }
     590    else {
     591        retStr = "0";
     592    }
    481593
    482594    // clear any previous result in the interpreter
     
    653765{
    654766
    655     std::string path = std::string("");    // path of where to copy data from
     767    std::string path = std::string("");    // path of where to remove data from
    656768    int nextarg = 2;
    657769
     
    664776    }
    665777    else {
    666         Tcl_AppendResult(interp, 
     778        Tcl_AppendResult(interp,
    667779            "wrong # args: should be \"remove ?path?\"",
    668780            (char*)NULL);
  • trunk/src/tcl/tcl_test.tcl

    r207 r224  
    7777
    7878puts "COPYING BETWEEN LIBS"
    79 $libObj1 copy "input.test" from libObj2 "input.(max)"
     79$libObj1 copy "input.test" from $libObj2 "input.(max)"
    8080puts [$libObj1 xml]
     81
     82puts "COPYING BETWEEN LIBS - this should fail"
     83set err [$libObj1 copy "input.test" from put "input.(max)"]
     84puts $err
    8185
    8286#puts [$libObj xml]
    8387puts "isvalid test1: "
    84 # puts [Rappture::library isvalid $libObj1]
     88puts [Rappture::library isvalid $libObj1]
    8589puts "isvalid test2: "
    86 # puts [Rappture::library isvalid library0]
     90puts [Rappture::library isvalid library0]
     91puts "isvalid test3: "
     92puts [Rappture::library isvalid puts]
     93puts "testing lib0's xml"
     94puts [library0 xml]
     95
     96puts "TEST ISA"
     97puts "$libObj1 isa ::Rappture::LibraryObj : "
     98puts [$libObj1 isa ::Rappture::LibraryObj]
     99puts "$libObj1 isa ::Rappture::Table : "
     100puts [$libObj1 isa ::Rappture::Table]
     101#puts "$libObj1 isa ::Rappture::LibraryObj ::Rappture::LibraryObj: "
     102#puts [$libObj1 isa ::Rappture::LibraryObj ::Rappture::LibraryObj]
     103
     104puts "TEST DIFF"
     105puts "changing the value of input.number(min) to 4"
     106$libObj1 put input.number(min).current "4"
     107$libObj2 put input.number(jdjd).current "4"
     108puts "$libObj1 diff $libObj2"
     109puts [$libObj1 diff $libObj2]
     110#foreach {op vpath oldval newval} [$libObj1 diff $libObj2] {
     111#    puts "op
     112
  • trunk/test/src/RpLibrary_test.cc

    r200 r224  
    1313
    1414#include "RpLibrary.h"
     15#include <list>
    1516
    1617int test_element (RpLibrary* lib, std::string path );
     
    198199}
    199200
     201int test_entities (RpLibrary* lib)
     202{
     203    std::list<std::string>::iterator iter;
     204    std::list<std::string> elist = lib->entities();
     205
     206    iter = elist.begin();
     207
     208    std::cout << "TESTING ENTITIES BEGIN" << std::endl;
     209    std::cout << "path = "<< lib->nodePath() << std::endl;
     210
     211    while (iter != elist.end() ) {
     212        std::cout << *iter << std::endl;
     213        iter++;
     214    }
     215
     216    std::cout << "TESTING ENTITIES END" << std::endl;
     217
     218    return 0;
     219}
     220
     221int test_diff (RpLibrary* lib1, RpLibrary* lib2)
     222{
     223    std::list<std::string>::iterator iter;
     224    std::list<std::string> elist;
     225
     226    elist = lib1->diff(lib2,"input");
     227
     228    iter = elist.begin();
     229
     230    std::cout << "TESTING DIFF BEGIN" << std::endl;
     231
     232    int count = 0;
     233    while (iter != elist.end() ) {
     234        std::cout << *iter << " ";
     235        iter++;
     236        count++;
     237        if (count == 4) {
     238            std::cout << std::endl;
     239            count = 0;
     240        }
     241
     242    }
     243
     244    std::cout << "TESTING DIFF END" << std::endl;
     245
     246    return 0;
     247}
    200248
    201249/*
     
    315363    std::cout << lib->xml() << std::endl;
    316364
     365    RpLibrary* libInput = lib->element("input");
     366    test_entities(lib);
     367    test_entities(libInput);
     368
     369    /*
     370    std::list<std::string> l1 = lib->value("input.number(min)");
     371    std::list<std::string> l2 = lib->value("input.number(max)");
     372    std::cout << "l1 = " << l1.front() << " " << l1.back() << std::endl;
     373    std::cout << "l2 = " << l2.front() << " " << l2.back() << std::endl;
     374    */
     375
     376    RpLibrary* dlib1 = new RpLibrary(std::string(argv[1]));
     377    RpLibrary* dlib2 = new RpLibrary(std::string(argv[1]));
     378    test_diff(dlib1,dlib2);
     379    std::cout << "dlib1-------------------------------------" << std::endl;
     380    std::cout << dlib1->xml() << std::endl;
     381    std::cout << "dlib2-------------------------------------" << std::endl;
     382    std::cout << dlib1->xml() << std::endl;
     383    dlib1 = lib;
     384    test_diff(dlib1,dlib2);
     385    std::cout << "dlib1-------------------------------------" << std::endl;
     386    std::cout << dlib1->xml() << std::endl;
     387    std::cout << "dlib2-------------------------------------" << std::endl;
     388    std::cout << dlib1->xml() << std::endl;
     389
     390
     391
    317392    // test copy assignment operator
    318393    lib2 = *lib;
     
    345420
    346421    lib2.result();
     422
    347423
    348424    return 0;
Note: See TracChangeset for help on using the changeset viewer.