(file) Return to BinaryStreamer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

   1 karl  1.9 //%2004////////////////////////////////////////////////////////////////////////
   2 schuur 1.1 //
   3 karl   1.9 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl   1.9 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 schuur 1.1 //
  10            // Permission is hereby granted, free of charge, to any person obtaining a copy
  11            // of this software and associated documentation files (the "Software"), to
  12            // deal in the Software without restriction, including without limitation the
  13            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  14            // sell copies of the Software, and to permit persons to whom the Software is
  15            // furnished to do so, subject to the following conditions:
  16 karl   1.9 // 
  17 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  18            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  19            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  20            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  21            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  23            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25            //
  26            //==============================================================================
  27            //
  28            // Author: Adrian Schuur (schuur@de.ibm.com) - PEP 164
  29            //
  30 dave.sudlik 1.2 // Modified By: Dave Sudlik (dsudlik@us.ibm.com)
  31 schuur      1.1 //
  32                 //%/////////////////////////////////////////////////////////////////////////////
  33                 
  34                 #include "XmlWriter.h"
  35                 #include "XmlReader.h"
  36                 #include "XmlParser.h"
  37                 
  38                 #include "CIMName.h"
  39                 #include "BinaryStreamer.h"
  40                 #include "CIMClassRep.h"
  41                 #include "CIMInstanceRep.h"
  42                 #include "CIMMethodRep.h"
  43                 #include "CIMParameterRep.h"
  44                 #include "CIMPropertyRep.h"
  45                 #include "CIMQualifierRep.h"
  46                 
  47                 #include "CIMValue.h"
  48                 #include "CIMValueRep.h"
  49                 
  50                 PEGASUS_USING_STD;
  51                 
  52 schuur      1.1 PEGASUS_NAMESPACE_BEGIN
  53                 
  54 konrad.r    1.8 #if defined(PEGASUS_OS_HPUX)
  55                 #define TYPE_CONV 
  56                 #endif
  57                 
  58 schuur      1.1 void BinaryStreamer::encode(Array<Sint8>& out, const CIMClass& cls)
  59                 {
  60                    toBin(out, cls);
  61                 }
  62                 
  63                 void BinaryStreamer::encode(Array<Sint8>& out, const CIMInstance& inst)
  64                 {
  65                    toBin(out, inst);
  66                 }
  67                 
  68                 void BinaryStreamer::encode(Array<Sint8>& out, const CIMQualifierDecl& qual)
  69                 {
  70                    toBin(out, qual);
  71                 }
  72                 
  73                 void BinaryStreamer::decode(const Array<Sint8>& in, unsigned int pos, CIMClass& cls)
  74                 {
  75                    cls=extractClass(in,pos,"");
  76                 }
  77                 
  78                 void BinaryStreamer::decode(const Array<Sint8>& in, unsigned int pos, CIMInstance& inst)
  79 schuur      1.1 {
  80                    inst=extractInstance(in,pos,"");
  81                 }
  82                 
  83                 void BinaryStreamer::decode(const Array<Sint8>& in, unsigned int pos, CIMQualifierDecl& qual)
  84                 {
  85                    qual=extractQualifierDecl(in,pos,"");
  86                 }
  87                 
  88                 
  89                 
  90                 void BinaryStreamer::append(Array<Sint8>& out, const CIMObjectPath &op)
  91                 {
  92                    CString ustr=op.toString().getCString();
  93                    Uint16 nl=strlen((const char*)ustr);
  94                    out.append((Sint8*)&nl,sizeof(Uint16));
  95                    out.append((Sint8*)((const char*)ustr),nl);
  96                 }
  97                 
  98                 void BinaryStreamer::append(Array<Sint8>& out, const CIMName &cn)
  99                 {
 100 schuur      1.1    CString ustr=cn.getString().getCString();
 101                    Uint16 nl=strlen((const char*)ustr);
 102                    out.append((Sint8*)&nl,sizeof(Sint16));
 103                    if (nl)
 104                        out.append((Sint8*)((const char*)ustr),nl);
 105                 }
 106                 
 107                 void BinaryStreamer::append(Array<Sint8>& out, const CIMType &typ)
 108                 {
 109                    Uint16 type=(Uint16)typ;
 110                    out.append((Sint8*)&type,sizeof(Uint16));
 111                 }
 112                 
 113                 void BinaryStreamer::append(Array<Sint8>& out, Uint16 ui)
 114                 {
 115                    out.append((Sint8*)&ui,sizeof(Uint16));
 116                 }
 117                 
 118                 void BinaryStreamer::append(Array<Sint8>& out, Uint32 ui)
 119                 {
 120                    out.append((Sint8*)&ui,sizeof(Uint32));
 121 schuur      1.1 }
 122                 
 123                 void BinaryStreamer::append(Array<Sint8>& out, Boolean b)
 124                 {
 125                    Sint8 rs=(b==true);
 126                    out.append(rs);
 127                 }
 128                 
 129                 
 130                 
 131                 CIMObjectPath BinaryStreamer::extractObjectPath(const Sint8 *ar, Uint32 & pos)
 132                 {
 133 konrad.r    1.5    Uint16 sl; //=*(Uint16*)(ar+pos);
 134                    memcpy( &sl, ar + pos, sizeof (Uint16));
 135 schuur      1.1    Uint32 ppos=pos+=sizeof(Uint16);
 136 konrad.r    1.5 
 137 schuur      1.1    pos+=sl;
 138                    return CIMObjectPath(String(((char*)(ar+ppos)),sl));
 139                 }
 140                 
 141                 CIMName BinaryStreamer::extractName(const Sint8 *ar, Uint32 & pos)
 142                 {
 143 konrad.r    1.5    Uint16 sl; //=*(Uint16*)(ar+pos);
 144                    memcpy(&sl, ar + pos, sizeof (Uint16)); 
 145 schuur      1.1    Uint32 ppos=pos+=sizeof(Uint16);
 146                    if (sl) {
 147                       pos+=sl;
 148                       return CIMName(String(((char*)(ar+ppos)),sl));
 149                    }
 150                    return CIMName();
 151                 }
 152                 
 153                 Uint16 BinaryStreamer::extractUint16(const Sint8 *ar, Uint32 & pos)
 154                 {
 155 konrad.r    1.5    Uint16 ui; //=*(Uint16*)(ar+pos);
 156                    memcpy (&ui, ar + pos, sizeof (Uint16));
 157 schuur      1.1    pos+=sizeof(Uint16);
 158                    return ui;
 159                 }
 160                 
 161                 CIMType BinaryStreamer::extractType(const Sint8 *ar, Uint32 & pos)
 162                 {
 163 konrad.r    1.5    Uint16 ui; //=*(Uint16*)(ar+pos);
 164                    memcpy( &ui, ar + pos, sizeof (Uint16));
 165 schuur      1.1    pos+=sizeof(Uint16);
 166                    CIMType t=(CIMType)ui;
 167                    return t;
 168                 }
 169                 
 170                 Uint32 BinaryStreamer::extractUint32(const Sint8 *ar, Uint32 & pos)
 171                 {
 172 konrad.r    1.5    Uint32 ui; //=*(Uint32*)(ar+pos);
 173                    memcpy ( &ui, ar + pos, sizeof(Uint32));
 174 schuur      1.1    pos+=sizeof(Uint32);
 175                    return ui;
 176                 }
 177                 
 178                 Boolean BinaryStreamer::extractBoolean(const Sint8 *ar, Uint32 & pos)
 179                 {
 180                    return ((*(ar+(pos++)))!=0);
 181                 }
 182                 
 183                 
 184                 
 185                 
 186                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMClass& cls)
 187                 {
 188                    CIMClassRep *rep=cls._rep;
 189                    static BINREP_CLASS_PREAMBLE_V1(preamble);
 190                    out.append((Sint8*)&preamble,sizeof(preamble));
 191                 
 192                    append(out,rep->getClassName());
 193                 
 194                    append(out,rep->getSuperClassName());
 195 schuur      1.1 
 196                    Uint16 qn=rep->getQualifierCount();
 197                    append(out,qn);
 198                    for (Uint16 i=0; i<qn; i++) {
 199                        const CIMQualifier &cq=rep->getQualifier(i);
 200                        toBin(out,cq);
 201                    }
 202                 
 203                    Uint16 pn=rep->getPropertyCount();
 204                    append(out,pn);
 205                    for (Uint16 i = 0; i < pn; i++) {
 206                        toBin(out,rep->getProperty(i));
 207                    }
 208                 
 209                    Uint16 mn=rep->getMethodCount();
 210                    append(out,mn);
 211                    for (Uint16 i = 0; i < mn; i++) {
 212                        toBin(out,rep->getMethod(i));
 213                    }
 214                 
 215                    append(out,rep->_resolved);
 216 schuur      1.1 }
 217                 
 218                 
 219                 CIMClass BinaryStreamer::extractClass(const Array<Sint8>& in, Uint32 & pos, const String &path)
 220                 {
 221 konrad.r    1.8 #ifdef TYPE_CONV
 222                   AutoPtr<record_preamble> preamble(new record_preamble());
 223                 
 224                   Uint32 idx = pos;
 225                   memcpy( &preamble->_format, in.getData() +idx, sizeof(Uint8));
 226                   idx+=sizeof(Uint8);
 227                   memcpy( &preamble->_pVersion, in.getData()+idx, sizeof(Uint8));
 228                   idx+=sizeof(Uint8);
 229                   memcpy( &preamble->_pLenAndCtl, in.getData()+idx, sizeof(Uint16));
 230                   idx+=sizeof(Uint16);
 231                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 232                   idx+=sizeof(Uint8);
 233                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 234                   //idx+=sizeof(Uint8);
 235                 #else
 236 schuur      1.1    BINREP_RECORD_IN(preamble,in,pos);
 237 konrad.r    1.8 #endif
 238 schuur      1.1    const Sint8 *ar=in.getData();
 239                 
 240                    try {
 241                       if (!preamble->endogenous()) {
 242                           throw BinException(BINREP_CLASS,String("Incompatible Binary Repository not supported"));
 243                       }
 244                       if (preamble->type()!=BINREP_CLASS) {
 245                           throw BinException(BINREP_CLASS,String("Expected CIMClass subtype not found"));
 246                       }
 247                 
 248                       pos+=preamble->size();
 249                 
 250                       switch (preamble->version()) {
 251                       case BINREP_CLASS_V1: {
 252                 
 253                          CIMName name=extractName(ar,pos); //if (name=="CIM_Memory") asm("int $3");
 254                          CIMName super=extractName(ar,pos);
 255                          CIMClass cls(name,super);
 256                 
 257                          Uint16 qn=extractUint16(ar,pos);
 258                          for (Uint16 i=0; i<qn; i++) {
 259 schuur      1.1             CIMQualifier q=extractQualifier(in,pos);
 260                             cls.addQualifier(q);
 261                          }
 262                 
 263                          Uint16 pn=extractUint16(ar,pos);
 264                          for (Uint16 i=0; i<pn; i++) {
 265                             CIMProperty p=extractProperty(in,pos);
 266                             cls.addProperty(p);
 267                          }
 268                 
 269                          Uint16 mn=extractUint16(ar,pos);
 270                          for (Uint16 i=0; i<mn; i++) {
 271                             CIMMethod m=extractMethod(in,pos);
 272                             cls.addMethod(m);
 273                          }
 274                 
 275                          cls._rep->_resolved=extractBoolean(ar,pos);
 276                          return cls;
 277                       }
 278                       default:
 279                           throw BinException(BINREP_CLASS,String("CIMClass subtype version ")+
 280 schuur      1.1              CIMValue(preamble->version()).toString()+" not supported ");
 281                       }
 282                    }
 283                    catch (BinException &be) {
 284                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,"Binary Repository integraty failure: "+
 285                          be.message+" - Accessing class: "+path);
 286                    }
 287                    return CIMClass();
 288                 }
 289                 
 290                 
 291                 
 292                 
 293                 
 294                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMInstance& inst)
 295                 {
 296                    CIMInstanceRep *rep=inst._rep;
 297                 
 298                    static BINREP_INSTANCE_PREAMBLE_V1(preamble);
 299                    out.append((Sint8*)&preamble,sizeof(preamble));
 300                 
 301 schuur      1.1    append(out,rep->getPath());
 302                 
 303                    Uint16 qn=rep->getQualifierCount();
 304                    append(out,qn);
 305                    for (Uint16 i=0; i<qn; i++) {
 306                        const CIMQualifier &cq=rep->getQualifier(i);
 307                        toBin(out,cq);
 308                    }
 309                 
 310                    Uint16 pn=rep->getPropertyCount();
 311                    append(out,pn);
 312                    for (Uint16 i = 0; i < pn; i++) {
 313                        toBin(out,rep->getProperty(i));
 314                    }
 315                 
 316                    append(out,rep->_resolved);
 317                 }
 318                 
 319                 
 320                 CIMInstance BinaryStreamer::extractInstance(const Array<Sint8>& in, Uint32 & pos,
 321                         const String & path)
 322 schuur      1.1 {
 323 konrad.r    1.8 
 324                 #ifdef TYPE_CONV
 325                   AutoPtr<record_preamble> preamble(new record_preamble());
 326                 
 327                   Uint32 idx = pos;
 328                   memcpy( &preamble->_format, in.getData() +idx, sizeof(Uint8));
 329                   idx+=sizeof(Uint8);
 330                   memcpy( &preamble->_pVersion, in.getData()+idx, sizeof(Uint8));
 331                   idx+=sizeof(Uint8);
 332                   memcpy( &preamble->_pLenAndCtl, in.getData()+idx, sizeof(Uint16));
 333                   idx+=sizeof(Uint16);
 334                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 335                   idx+=sizeof(Uint8);
 336                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 337                   //idx+=sizeof(Uint8);
 338                 #else
 339 schuur      1.1    BINREP_RECORD_IN(preamble,in,pos);
 340 konrad.r    1.8 #endif
 341 schuur      1.1    const Sint8 *ar=in.getData();
 342                 
 343                    try {
 344                       if (!preamble->endogenous()) {
 345                           throw BinException(BINREP_INSTANCE,String("Incompatible Binary Repository not supported"));
 346                       }
 347                       if (preamble->type()!=BINREP_INSTANCE) {
 348                           throw BinException(BINREP_INSTANCE,String("Expected CIMInstance subtype not found"));
 349                       }
 350                 
 351                       pos+=preamble->size();
 352                 
 353                       switch (preamble->version()) {
 354                       case BINREP_INSTANCE_V1: {
 355                 
 356                          CIMObjectPath op=extractObjectPath(ar,pos);
 357                          CIMInstance inst(op.getClassName());
 358                          inst.setPath(op);
 359                 
 360                          Uint16 qn=extractUint16(ar,pos);
 361                          for (Uint16 i=0; i<qn; i++) {
 362 schuur      1.1             CIMQualifier q=extractQualifier(in,pos);
 363                             inst.addQualifier(q);
 364                          }
 365                 
 366                          Uint16 pn=extractUint16(ar,pos);
 367                          for (Uint16 i=0; i<pn; i++) {
 368                             CIMProperty p=extractProperty(in,pos);
 369                             inst.addProperty(p);
 370                          }
 371                 
 372                          inst._rep->_resolved=extractBoolean(ar,pos);
 373                 
 374                          return inst;
 375                       }
 376                       default:
 377                           throw BinException(BINREP_INSTANCE,String("CIMInstance subtype version ")+
 378                              CIMValue(preamble->version()).toString()+" not supported ");
 379                       }
 380                    }
 381                    catch (BinException &be) {
 382                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,"Binary Repository integraty failure: "+
 383 schuur      1.1          be.message+" - Accessing instance: "+path);
 384                    }
 385                    return CIMInstance();
 386                 }
 387                 
 388                 
 389                 
 390                 
 391                 
 392                 
 393                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMQualifierDecl& qdc)
 394                 {
 395                    static BINREP_QUALIFIERDECL_PREAMBLE_V1(preamble);
 396                    out.append((Sint8*)&preamble,sizeof(preamble));
 397                 
 398                    append(out,qdc.getName());
 399                 
 400                    toBin(out,qdc.getValue());
 401                 
 402                    toBin(out,qdc.getScope());
 403                 
 404 schuur      1.1    toBin(out,qdc.getFlavor());
 405                 
 406                    append(out,qdc.getArraySize());
 407                 
 408                 }
 409                 
 410                 
 411                 CIMQualifierDecl BinaryStreamer::extractQualifierDecl(const Array<Sint8>& in, Uint32 & pos,
 412                         const String &path)
 413                 {
 414 konrad.r    1.8 #ifdef TYPE_CONV
 415                   AutoPtr<record_preamble> preamble(new record_preamble());
 416                 
 417                   Uint32 idx = pos;
 418                   memcpy( &preamble->_format, in.getData() +idx, sizeof(Uint8));
 419                   idx+=sizeof(Uint8);
 420                   memcpy( &preamble->_pVersion, in.getData()+idx, sizeof(Uint8));
 421                   idx+=sizeof(Uint8);
 422                   memcpy( &preamble->_pLenAndCtl, in.getData()+idx, sizeof(Uint16));
 423                   idx+=sizeof(Uint16);
 424                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 425                   idx+=sizeof(Uint8);
 426                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 427                   //idx+=sizeof(Uint8);
 428                 #else
 429 schuur      1.1    BINREP_RECORD_IN(preamble,in,pos);
 430 konrad.r    1.8 #endif
 431 schuur      1.1    const Sint8 *ar=in.getData();
 432                 
 433                    try {
 434                       if (!preamble->endogenous()) {
 435                           throw BinException(BINREP_QUALIFIERDECL,String
 436                              ("Incompatible Binary Repository not supported"));
 437                       }
 438                       if (preamble->type()!=BINREP_QUALIFIERDECL) {
 439                           throw BinException(BINREP_QUALIFIERDECL,String(
 440                              "Expected CIMQualifierDecl subtype not found"));
 441                       }
 442                 
 443                       pos+=preamble->size();
 444                 
 445                       switch (preamble->version()) {
 446                       case BINREP_INSTANCE_V1: {
 447                 
 448                          CIMName name=extractName(ar,pos);
 449                          CIMValue val=extractValue(in,pos);
 450                          CIMScope scp=extractScope(in,pos);
 451                          CIMFlavor fl=extractFlavor(in,pos);
 452 schuur      1.1          Uint32    as=extractUint32(ar,pos);
 453                 
 454                          CIMQualifierDecl qdl(name,val,scp,fl,as);
 455                 
 456                          return qdl;
 457                       }
 458                       default:
 459                           throw BinException(BINREP_INSTANCE,String("CIMInstance subtype version ")+
 460                              CIMValue(preamble->version()).toString()+" not supported ");
 461                       }
 462                    }
 463                    catch (BinException &be) {
 464                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,"Binary Repository integraty failure: "+
 465                          be.message+" - Accessing instance: "+path);
 466                    }
 467                    return CIMQualifierDecl();
 468                 }
 469                 
 470                 
 471                 
 472                 
 473 schuur      1.1 
 474                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMMethod &meth)
 475                 {
 476                    CIMMethodRep *rep=meth._rep;
 477                 
 478                    static BINREP_METHOD_PREAMBLE_V1(preamble);
 479                    out.append((Sint8*)&preamble,sizeof(preamble));
 480                 
 481                    append(out,rep->getName());
 482                 
 483                    append(out,rep->getType());
 484                 
 485                    append(out,rep->getClassOrigin());
 486                 
 487                    append(out,rep->getPropagated());
 488                 
 489                    Uint16 qn=rep->getQualifierCount();
 490                    append(out,qn);
 491                    for (Uint16 i=0; i<qn; i++) {
 492                        const CIMQualifier &cq=rep->getQualifier(i);
 493                        toBin(out,cq);
 494 schuur      1.1    }
 495                 
 496                     Uint16 pn=rep->getParameterCount();
 497                     out.append((Sint8*)&pn,sizeof(Uint16));
 498                     for (Uint16 i = 0; i < pn; i++) {
 499                        toBin(out,rep->getParameter(i));
 500                     }
 501                 }
 502                 
 503                 
 504                 CIMMethod BinaryStreamer::extractMethod(const Array<Sint8>& in, Uint32 & pos)
 505                 {
 506 konrad.r    1.8 #ifdef TYPE_CONV
 507                   AutoPtr<subtype_preamble> preamble(new subtype_preamble());
 508                 
 509                   Uint32 idx = pos;
 510                   memcpy( &preamble->_pLength, in.getData() +idx, sizeof(Uint8));
 511                   idx+=sizeof(Uint8);
 512                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 513                   idx+=sizeof(Uint8);
 514                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 515                   //idx+=sizeof(Uint8);
 516                 #else
 517 schuur      1.1    BINREP_SUBTYPE_IN(preamble,in,pos);
 518 konrad.r    1.8 #endif
 519 schuur      1.1    const Sint8 *ar=in.getData();
 520                 
 521                    if (preamble->type()!=BINREP_METHOD) {
 522                        throw BinException(BINREP_METHOD,String("Expected CIMMethod subtype not found"));
 523                    }
 524                 
 525                    pos+=preamble->size();
 526                 
 527                    switch (preamble->version()) {
 528                    case BINREP_METHOD_V1: {
 529                 
 530                       CIMName name=extractName(ar,pos);
 531                       CIMType type=extractType(ar,pos);
 532                       CIMName orig=extractName(ar,pos);
 533                       Boolean prpg=extractBoolean(ar,pos);
 534                 
 535                       CIMMethod meth(name,type,orig,prpg);
 536                 
 537                       Uint16 qn=extractUint16(ar,pos);
 538                       for (Uint16 i=0; i<qn; i++) {
 539                          CIMQualifier q=extractQualifier(in,pos);
 540 schuur      1.1          meth.addQualifier(q);
 541                       }
 542                 
 543                       Uint16 pn=extractUint16(ar,pos);
 544                       for (Uint16 i=0; i<pn; i++) {
 545                          CIMParameter p=extractParameter(in,pos);
 546                          meth.addParameter(p);
 547                       }
 548                 
 549                       return meth;
 550                    }
 551                    default: ;
 552                        throw BinException(BINREP_METHOD,String("CIMMethod subtype version ")+
 553                           CIMValue(preamble->version()).toString()+" not supported ");
 554                    }
 555                    return CIMMethod();
 556                 }
 557                 
 558                 
 559                 
 560                 
 561 schuur      1.1 
 562                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMParameter& prm)
 563                 {
 564                    CIMParameterRep *rep=prm._rep;
 565                 
 566                    static BINREP_PARAMETER_PREAMBLE_V1(preamble);
 567                    out.append((Sint8*)&preamble,sizeof(preamble));
 568                 
 569                    append(out,rep->getName());
 570                 
 571                    append(out,rep->getType());
 572                 
 573                    append(out,rep->isArray());
 574                 
 575                    append(out,rep->getArraySize());
 576                 
 577                    append(out,rep->getReferenceClassName());
 578                 
 579                    Uint16 qn=rep->getQualifierCount();
 580                    append(out,qn);
 581                    for (Uint16 i=0; i<qn; i++) {
 582 schuur      1.1        const CIMQualifier &cq=rep->getQualifier(i);
 583                        toBin(out,cq);
 584                    }
 585                 }
 586                 
 587                 CIMParameter BinaryStreamer::extractParameter(const Array<Sint8>& in, Uint32 &pos)
 588                 {
 589 konrad.r    1.8 #ifdef TYPE_CONV
 590                   AutoPtr<subtype_preamble> preamble(new subtype_preamble());
 591                 
 592                   Uint32 idx = pos;
 593                   memcpy( &preamble->_pLength, in.getData() +idx, sizeof(Uint8));
 594                   idx+=sizeof(Uint8);
 595                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 596                   idx+=sizeof(Uint8);
 597                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 598                   //idx+=sizeof(Uint8);
 599                 #else
 600 schuur      1.1    BINREP_SUBTYPE_IN(preamble,in,pos);
 601 konrad.r    1.8 #endif
 602 schuur      1.1    const Sint8 *ar=in.getData();
 603                 
 604                    if (preamble->type()!=BINREP_PARAMETER) {
 605                        throw BinException(BINREP_PARAMETER,String("Expected CIMParameter subtype not found"));
 606                   }
 607                 
 608                    pos+=preamble->size();
 609                 
 610                    switch (preamble->version()) {
 611                    case BINREP_PARAMETER_V1: {
 612                 
 613                       CIMName name=extractName(ar,pos);
 614                       CIMType type=extractType(ar,pos);
 615                       Boolean isAr=extractBoolean(ar,pos);
 616                       Uint32    as=extractUint32(ar,pos);
 617                       CIMName clsr=extractName(ar,pos);
 618                 
 619                       CIMParameter parm(name,type,isAr,as,clsr);
 620                 
 621                       Uint16 qn=extractUint16(ar,pos);
 622                       for (Uint16 i=0; i<qn; i++) {
 623 schuur      1.1          CIMQualifier q=extractQualifier(in,pos);
 624                          parm.addQualifier(q);
 625                       }
 626                 
 627                       return parm;
 628                    }
 629                    default: ;
 630                        throw BinException(BINREP_PARAMETER,String("CIMParameter subtype version ")+
 631                           CIMValue(preamble->version()).toString()+" not supported ");
 632                    }
 633                    return CIMParameter();
 634                 }
 635                 
 636                 
 637                 
 638                 
 639                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMProperty& prop)
 640                 {
 641                    CIMPropertyRep *rep=prop._rep;
 642                 
 643                    static BINREP_PROPERTY_PREAMBLE_V1(preamble);
 644 schuur      1.1    out.append((Sint8*)&preamble,sizeof(preamble));
 645                 
 646                    append(out,rep->getName());
 647                 
 648                    toBin(out,rep->getValue());
 649                 
 650                    append(out,rep->getArraySize());
 651                 
 652                    append(out,rep->getReferenceClassName());
 653                 
 654                    append(out,rep->getClassOrigin());
 655                 
 656                    append(out,rep->getPropagated());
 657                 
 658                    Uint16 qn=rep->getQualifierCount();
 659                    append(out,qn);
 660                    for (Uint16 i=0; i<qn; i++) {
 661                        const CIMQualifier &cq=rep->getQualifier(i);
 662                        toBin(out,cq);
 663                    }
 664                 }
 665 schuur      1.1 
 666                 
 667                 CIMProperty BinaryStreamer::extractProperty(const Array<Sint8>& in, Uint32 &pos)
 668                 {
 669 konrad.r    1.8 #ifdef TYPE_CONV
 670                   AutoPtr<subtype_preamble> preamble(new subtype_preamble());
 671                 
 672                   Uint32 idx = pos;
 673                   memcpy( &preamble->_pLength, in.getData() +idx, sizeof(Uint8));
 674                   idx+=sizeof(Uint8);
 675                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 676                   idx+=sizeof(Uint8);
 677                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 678                   //idx+=sizeof(Uint8);
 679                 #else
 680 schuur      1.1    BINREP_SUBTYPE_IN(preamble,in,pos);
 681 konrad.r    1.8 #endif
 682 schuur      1.1    const Sint8 *ar=in.getData();
 683                 
 684                    if (preamble->type()!=BINREP_PROPERTY) {
 685                        throw BinException(BINREP_PROPERTY,String("Expected CIMProperty subtype not found"));
 686                    }
 687                 
 688                    pos+=preamble->size();
 689                 
 690                    switch (preamble->version()) {
 691                    case BINREP_PROPERTY_V1: {
 692                 
 693                       CIMName name=extractName(ar,pos);
 694                       CIMValue val=extractValue(in,pos);
 695                       Uint32    as=extractUint32(ar,pos);
 696                       CIMName clsr=extractName(ar,pos);
 697                       CIMName orig=extractName(ar,pos);
 698                       Boolean prpg=extractBoolean(ar,pos);
 699                 
 700                       CIMProperty prop(name,val,as,clsr,orig,prpg);
 701                 
 702                       Uint16 qn=extractUint16(ar,pos);
 703 schuur      1.1       for (Uint16 i=0; i<qn; i++) {
 704                          CIMQualifier q=extractQualifier(in,pos);
 705                          prop.addQualifier(q);
 706                       }
 707                 
 708                       return prop;
 709                    }
 710                    default: ;
 711                        throw BinException(BINREP_PROPERTY,String("CIMProperty subtype version ")+
 712                           CIMValue(preamble->version()).toString()+" not supported ");
 713                    }
 714                    return CIMProperty();
 715                 }
 716                 
 717                 
 718                 
 719                 
 720                 
 721                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMFlavor& flav)
 722                 {
 723                    out.append((Sint8*)&flav.cimFlavor,sizeof(flav.cimFlavor));
 724 schuur      1.1 }
 725                 
 726                 
 727                 CIMFlavor BinaryStreamer::extractFlavor(const Array<Sint8>& in, Uint32 & pos)
 728                 {
 729                    CIMFlavor flav;
 730                    flav.cimFlavor=extractUint32(in.getData(),pos);
 731                    return flav;
 732                 }
 733                 
 734                 
 735                 
 736                 
 737                 
 738                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMScope& scp)
 739                 {
 740                    out.append((Sint8*)&scp.cimScope,sizeof(scp.cimScope));
 741                 }
 742                 
 743                 
 744                 CIMScope BinaryStreamer::extractScope(const Array<Sint8>& in, Uint32 & pos)
 745 schuur      1.1 {
 746                    CIMScope scp;
 747                    scp.cimScope=extractUint32(in.getData(),pos);
 748                    return scp;
 749                 }
 750                 
 751                 
 752                  
 753                 
 754                 void BinaryStreamer::toBin(Array<Sint8>& out, const CIMQualifier& qual)
 755                 {
 756                    CIMQualifierRep *rep=qual._rep;
 757                 
 758                    static BINREP_QUALIFIER_PREAMBLE_V1(preamble);
 759                    out.append((Sint8*)&preamble,sizeof(preamble));
 760                 
 761                    CIMName name=rep->getName();
 762                    append(out,name);
 763                 
 764 dave.sudlik 1.4    toBin(out,rep->getValue());
 765 schuur      1.1 
 766                    toBin(out,rep->getFlavor());
 767                 
 768                    append(out,rep->getPropagated());
 769                 }
 770                 
 771                 
 772                 CIMQualifier BinaryStreamer::extractQualifier(const Array<Sint8>& in, Uint32 & pos)
 773                 {
 774 konrad.r    1.8 #ifdef TYPE_CONV
 775                   AutoPtr<subtype_preamble> preamble(new subtype_preamble());
 776                 
 777                   Uint32 idx = pos;
 778                   memcpy( &preamble->_pLength, in.getData() +idx, sizeof(Uint8));
 779                   idx+=sizeof(Uint8);
 780                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 781                   idx+=sizeof(Uint8);
 782                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 783                   //idx+=sizeof(Uint8);
 784                 #else
 785 schuur      1.1    BINREP_SUBTYPE_IN(preamble,in,pos);
 786 konrad.r    1.8 #endif
 787 schuur      1.1    const Sint8 *ar=in.getData();
 788                 
 789                    if (preamble->type()!=BINREP_QUALIFIER) {
 790                        throw BinException(BINREP_QUALIFIER,String("Expected CIMQualifier subtype not found"));
 791                    }
 792                 
 793                   pos+=preamble->size();
 794                 
 795                    switch (preamble->version()) {
 796                    case BINREP_QUALIFIER_V1: {
 797                 
 798                       CIMName name=extractName(ar,pos);
 799                       CIMValue val=extractValue(in,pos);
 800                       CIMFlavor fl=extractFlavor(in,pos);
 801                       Boolean prpg=extractBoolean(ar,pos);
 802                 
 803                       CIMQualifier q(name,val,fl,prpg);
 804                 
 805                       return q;
 806                    }
 807                    default: ;
 808 schuur      1.1        throw BinException(BINREP_QUALIFIER,String("CIMQualifier subtype version ")+
 809                           CIMValue(preamble->version()).toString()+" not supported ");
 810                    }
 811                    return CIMQualifier();
 812                 }
 813                 
 814                 
 815                 
 816                 
 817                 void BinaryStreamer::toBin(Array<Sint8> & out, const CIMValue& val)
 818                 {
 819                    CIMValueRep *_rep=val._rep;
 820                 
 821                    static BINREP_VALUE_PREAMBLE_V1(preamble);
 822                    out.append((Sint8*)&preamble,sizeof(preamble));
 823                 
 824                    append(out,val.getType());
 825                 
 826                    Boolean isArray=val.isArray();
 827                    append(out,isArray);
 828                 
 829 schuur      1.1    Uint32 as=0;
 830                 
 831                    if (isArray) {
 832                       as=val.getArraySize();
 833                       append(out,as);
 834                    }
 835                 
 836                    Boolean isNull=val.isNull();
 837                    append(out,isNull);
 838                 
 839                    if (!isNull) {
 840                       if (isArray) {
 841                          switch (val.getType()) {
 842                          case CIMTYPE_BOOLEAN: {
 843                                out.append((Sint8*)_rep->_u._booleanArray->getData(),sizeof(Boolean)*as);
 844                             }
 845                             break;
 846                          case CIMTYPE_UINT8: {
 847                                out.append((Sint8*)_rep->_u._uint8Array->getData(),sizeof(Uint8)*as);
 848                             }
 849                             break;
 850 schuur      1.1          case CIMTYPE_SINT8: {
 851                                out.append((Sint8*)_rep->_u._sint8Array->getData(),sizeof(Sint8)*as);
 852                             }
 853                             break;
 854                          case CIMTYPE_UINT16: {
 855                                out.append((Sint8*)_rep->_u._uint16Array->getData(),sizeof(Uint16)*as);
 856                             }
 857                             break;
 858                          case CIMTYPE_SINT16: {
 859                                out.append((Sint8*)_rep->_u._sint16Array->getData(),sizeof(Sint16)*as);
 860                             }
 861                             break;
 862                          case CIMTYPE_UINT32: {
 863                                out.append((Sint8*)_rep->_u._uint32Array->getData(),sizeof(Uint32)*as);
 864                             }
 865                             break;
 866                          case CIMTYPE_SINT32: {
 867                                out.append((Sint8*)_rep->_u._sint32Array->getData(),sizeof(Sint32)*as);
 868                             }
 869                             break;
 870                          case CIMTYPE_UINT64: {
 871 schuur      1.1                out.append((Sint8*)_rep->_u._uint64Array->getData(),sizeof(Uint64)*as);
 872                             }
 873                             break;
 874                          case CIMTYPE_SINT64: {
 875                                out.append((Sint8*)_rep->_u._sint64Array->getData(),sizeof(Uint64)*as);
 876                             }
 877                             break;
 878                          case CIMTYPE_REAL32: {
 879                                out.append((Sint8*)_rep->_u._real32Array->getData(),sizeof(Real32)*as);
 880                             }
 881                             break;
 882                          case CIMTYPE_REAL64: {
 883                                out.append((Sint8*)_rep->_u._real64Array->getData(),sizeof(Real64)*as);
 884                             }
 885                             break;
 886                          case CIMTYPE_CHAR16: {
 887                                out.append((Sint8*)_rep->_u._char16Array->getData(),sizeof(Char16)*as);
 888                             }
 889                             break;
 890                          case CIMTYPE_STRING: {
 891                                for (Uint32 i=0; i<as; i++) {
 892 schuur      1.1                   CString ustr=(*(_rep->_u._stringArray))[i].getCString();
 893                                   Uint32 sz=strlen((const char*)ustr);
 894                                   out.append((Sint8*)&sz,sizeof(Uint32));
 895                                   out.append((Sint8*)((const char*)ustr),sz);
 896                                }
 897                             }
 898                             break;
 899                          case CIMTYPE_DATETIME: {
 900                                for (Uint32 i=0; i<as; i++) {
 901                                   String dts=(*(_rep->_u._dateTimeArray))[i].toString();
 902                                   Sint32 dtl=dts.size();
 903                                   out.append((Sint8*)&dtl,sizeof(Sint32));
 904                                   out.append((Sint8*)dts.getChar16Data(),dtl*sizeof(Char16));
 905                                }
 906                             }
 907                             break;
 908                          case CIMTYPE_REFERENCE: {
 909                                 for (Uint32 i=0; i<as; i++) {
 910                                   String rfs=(*(_rep->_u._referenceArray))[i].toString();
 911                                   Sint32 rfl=rfs.size();
 912                                   out.append((Sint8*)&rfl,sizeof(Sint32));
 913 schuur      1.1                   out.append((Sint8*)rfs.getChar16Data(),rfl*sizeof(Char16));
 914                                }
 915                             }
 916                             break;
 917                          }
 918                       }
 919                 
 920                       else switch (val.getType()) {
 921                       case CIMTYPE_BOOLEAN:
 922                          out.append((Sint8*)&_rep->_u,sizeof(Boolean));  break;
 923                       case CIMTYPE_UINT8:
 924                          out.append((Sint8*)&_rep->_u,sizeof(Uint8));    break;
 925                       case CIMTYPE_SINT8:
 926                          out.append((Sint8*)&_rep->_u,sizeof(Sint8));    break;
 927                       case CIMTYPE_UINT16:
 928                          out.append((Sint8*)&_rep->_u,sizeof(Uint16));   break;
 929                       case CIMTYPE_SINT16:
 930                          out.append((Sint8*)&_rep->_u,sizeof(Sint16));   break;
 931                       case CIMTYPE_UINT32:
 932                          out.append((Sint8*)&_rep->_u,sizeof(Uint32));   break;
 933                       case CIMTYPE_SINT32:
 934 schuur      1.1          out.append((Sint8*)&_rep->_u,sizeof(Sint32));   break;
 935                       case CIMTYPE_UINT64:
 936                          out.append((Sint8*)&_rep->_u,sizeof(Uint64));   break;
 937                       case CIMTYPE_SINT64:
 938                          out.append((Sint8*)&_rep->_u,sizeof(Uint64));   break;
 939                       case CIMTYPE_REAL32:
 940                          out.append((Sint8*)&_rep->_u,sizeof(Real32));   break;
 941                       case CIMTYPE_REAL64:
 942                          out.append((Sint8*)&_rep->_u,sizeof(Real64));   break;
 943                       case CIMTYPE_CHAR16:
 944                          out.append((Sint8*)&_rep->_u,sizeof(Char16));   break;
 945                       case CIMTYPE_STRING: {
 946                             CString ustr=_rep->_u._stringValue->getCString();
 947                             Uint32 sz=strlen((const char*)ustr);
 948                             out.append((Sint8*)&sz,sizeof(Uint32));
 949                             out.append((Sint8*)((const char*)ustr),sz);
 950                          }
 951                          break;
 952                       case CIMTYPE_DATETIME: {
 953                             String dts=_rep->_u._dateTimeValue->toString();
 954                             Sint32 dtl=dts.size();
 955 schuur      1.1             out.append((Sint8*)&dtl,sizeof(Sint32));
 956                             out.append((Sint8*)dts.getChar16Data(),dtl*sizeof(Char16));
 957                          }
 958                          break;
 959                       case CIMTYPE_REFERENCE: {
 960                             String rfs=_rep->_u._referenceValue->toString();
 961                             Sint32 rfl=rfs.size();
 962                             out.append((Sint8*)&rfl,sizeof(Sint32));
 963                             out.append((Sint8*)rfs.getChar16Data(),rfl*sizeof(Char16));
 964                          }
 965                          break;
 966                       }
 967                    }
 968                    else {
 969                    }
 970                 }
 971                 
 972                 
 973                 CIMValue BinaryStreamer::extractValue(const Array<Sint8>& in, Uint32 & pos)
 974                 {
 975 konrad.r    1.8 #ifdef TYPE_CONV
 976                   AutoPtr<subtype_preamble> preamble(new subtype_preamble());
 977                 
 978                   Uint32 idx = pos;
 979                   memcpy( &preamble->_pLength, in.getData() +idx, sizeof(Uint8));
 980                   idx+=sizeof(Uint8);
 981                   memcpy( &preamble->_type, in.getData()+idx, sizeof(Uint8));
 982                   idx+=sizeof(Uint8);
 983                   memcpy( &preamble->_tVersion, in.getData()+idx, sizeof(Uint8));
 984                   //idx+=sizeof(Uint8);
 985                 #else
 986 schuur      1.1     BINREP_SUBTYPE_IN(preamble,in,pos);
 987 konrad.r    1.8 #endif
 988 schuur      1.1     const Sint8 *ar=in.getData();
 989                 
 990                    if (preamble->type()!=BINREP_VALUE) {
 991                        throw BinException(BINREP_VALUE,String("Expected CIMValue subtype not found"));
 992                    }
 993                 
 994                     pos+=preamble->size();
 995                 
 996                     Uint32 as=0;
 997                 
 998                     switch (preamble->version()) {
 999                     case BINREP_VALUE_V1: {
1000                 
1001                       const Sint8 *ar=in.getData();
1002                 
1003                       CIMType type=extractType(ar,pos);
1004                 
1005                       Boolean isArray=extractBoolean(ar,pos);
1006                       if (isArray)
1007                           as=extractUint32(ar,pos);
1008                 
1009 schuur      1.1       Boolean isNull=extractBoolean(ar,pos);
1010                 
1011                       if (!isNull) {
1012                          if (isArray) {
1013                 
1014                             CIMValue val(type,isArray,as);
1015                 
1016                             switch (type) {
1017                             case CIMTYPE_BOOLEAN: {
1018 konrad.r    1.7 #ifdef TYPE_CONV
1019                 		  Array<Boolean> a_val;
1020                 		  a_val.reserveCapacity(as);
1021                 		  for (Uint32 i =0; i < as*sizeof(Boolean); i+=sizeof(Boolean)) {
1022                 			Boolean b;
1023                 			memcpy( &b, ar + pos + i, sizeof(Boolean));
1024                 		  	a_val.append(b);
1025                 		  }
1026                 		  val.set(a_val);
1027                 #else
1028 schuur      1.1                   val.set(Array<Boolean>((Boolean*)(ar+pos),as));
1029 konrad.r    1.7 #endif
1030 schuur      1.1                   pos+=sizeof(Boolean)*as;
1031                                }
1032                                break;
1033                             case CIMTYPE_UINT8: {
1034 konrad.r    1.7 #ifdef TYPE_CONV
1035                 		  Array<Uint8> a_val;
1036                 		  a_val.reserveCapacity(as);
1037                 		  for (Uint32 i =0; i < as*sizeof(Uint8); i+=sizeof(Uint8)) {
1038                 			Uint8 val;
1039                 			memcpy( &val, ar + pos + i, sizeof(Uint8));
1040                 		  	a_val.append(val);
1041                 		  }
1042                 		  val.set(a_val);
1043                 #else		  
1044 schuur      1.1                   val.set(Array<Uint8>((Uint8*)(ar+pos),as));
1045 konrad.r    1.7 #endif
1046 schuur      1.1                   pos+=sizeof(Uint8)*as;
1047                                }
1048                                break;
1049                             case CIMTYPE_SINT8: {
1050 konrad.r    1.7 #ifdef TYPE_CONV
1051                 		  Array<Sint8> a_val;
1052                 		  a_val.reserveCapacity(as);
1053                 		  for (Uint32 i =0; i < as*sizeof(Sint8); i+=sizeof(Sint8)) {
1054                 			Sint8 val;
1055                 			memcpy( &val, ar + pos + i, sizeof(Sint8));
1056                 		  	a_val.append(val);
1057                 		  }
1058                 		  val.set(a_val);
1059                 #else
1060 schuur      1.1                   val.set(Array<Sint8>((Sint8*)(ar+pos),as));
1061 konrad.r    1.7 #endif
1062 schuur      1.1                   pos+=sizeof(Sint8)*as;
1063                                }
1064                                break;
1065                             case CIMTYPE_UINT16: {
1066 konrad.r    1.7 #ifdef TYPE_CONV
1067                 		  Array<Uint16> a_val;
1068                 		  a_val.reserveCapacity(as);
1069                 		  for (Uint32 i =0; i < as*sizeof(Uint16); i+=sizeof(Uint16)) {
1070                 			Uint16 val;
1071                 			memcpy( &val, ar + pos + i, sizeof(Uint16));
1072                 		  	a_val.append(val);
1073                 		  }
1074                 		  val.set(a_val);
1075                 #else
1076 schuur      1.1                   val.set(Array<Uint16>((Uint16*)(ar+pos),as));
1077 konrad.r    1.7 #endif
1078 schuur      1.1                   pos+=sizeof(Uint16)*as;
1079                                }
1080                                break;
1081                             case CIMTYPE_SINT16: {
1082 konrad.r    1.7 #ifdef TYPE_CONV
1083                 		  Array<Sint16> a_val;
1084                 		  a_val.reserveCapacity(as);
1085                 		  for (Uint32 i =0; i < as*sizeof(Sint16); i+=sizeof(Sint16)) {
1086                 			Sint16 val;
1087                 			memcpy( &val, ar + pos + i, sizeof(Sint16));
1088                 		  	a_val.append(val);
1089                 		  }
1090                 		  val.set(a_val);
1091                 #else
1092 schuur      1.1                   val.set(Array<Sint16>((Sint16*)(ar+pos),as));
1093 konrad.r    1.7 #endif
1094 schuur      1.1                   pos+=sizeof(Sint16)*as;
1095                                }
1096                                break;
1097                             case CIMTYPE_UINT32: {
1098 konrad.r    1.7 #ifdef TYPE_CONV
1099                 		  Array<Uint32> a_val;
1100                 		  a_val.reserveCapacity(as);
1101                 		  for (Uint32 i =0; i < as*sizeof(Uint32); i+=sizeof(Uint32)) {
1102                 			Uint32 val;
1103                 			memcpy( &val, ar + pos + i, sizeof(Uint32));
1104                 		  	a_val.append(val);
1105                 		  }
1106                 		  val.set(a_val);
1107                 #else
1108 schuur      1.1                   val.set(Array<Uint32>((Uint32*)(ar+pos),as));
1109 konrad.r    1.7 #endif
1110 schuur      1.1                   pos+=sizeof(Uint32)*as;
1111                                }
1112                                break;
1113                             case CIMTYPE_SINT32: {
1114 konrad.r    1.7 #ifdef TYPE_CONV
1115                 		  Array<Sint32> a_val;
1116                 		  a_val.reserveCapacity(as);
1117                 		  for (Uint32 i =0; i < as*sizeof(Sint32); i+=sizeof(Sint32)) {
1118                 			Sint32 val;
1119                 			memcpy( &val, ar + pos + i, sizeof(Sint32));
1120                 		  	a_val.append(val);
1121                 		  }
1122                 		  val.set(a_val);
1123                 #else
1124 schuur      1.1                   val.set(Array<Sint32>((Sint32*)(ar+pos),as));
1125 konrad.r    1.7 #endif
1126 schuur      1.1                   pos+=sizeof(Sint32)*as;
1127                                }
1128                                break;
1129                             case CIMTYPE_UINT64: {
1130 konrad.r    1.7 #ifdef TYPE_CONV
1131                 		  Array<Uint64> a_val;
1132                 		  a_val.reserveCapacity(as);
1133                 		  for (Uint32 i =0; i < as*sizeof(Uint64); i+=sizeof(Uint64)) {
1134                 			Uint64 val;
1135                 			memcpy( &val, ar + pos + i, sizeof(Uint64));
1136                 		  	a_val.append(val);
1137                 		  }
1138                 		  val.set(a_val);
1139                 #else
1140 schuur      1.1                   val.set(Array<Uint64>((Uint64*)(ar+pos),as));
1141 konrad.r    1.7 #endif
1142 schuur      1.1                   pos+=sizeof(Uint64)*as;
1143                                }
1144                                break;
1145                             case CIMTYPE_SINT64: {
1146 konrad.r    1.7 #ifdef TYPE_CONV
1147                 		  Array<Sint64> a_val;
1148                 		  a_val.reserveCapacity(as);
1149                 		  for (Uint32 i =0; i < as*sizeof(Sint64); i+=sizeof(Sint64)) {
1150                 			Sint64 val;
1151                 			memcpy( &val, ar + pos + i, sizeof(Sint64));
1152                 		  	a_val.append(val);
1153                 		  }
1154                 		  val.set(a_val);
1155                 #else
1156 schuur      1.1                   val.set(Array<Sint64>((Sint64*)(ar+pos),as));
1157 konrad.r    1.7 #endif
1158 schuur      1.1                   pos+=sizeof(Sint64)*as;
1159                                }
1160                                break;
1161                             case CIMTYPE_REAL32: {
1162 konrad.r    1.7 #ifdef TYPE_CONV
1163                 		  Array<Real32> a_val;
1164                 		  a_val.reserveCapacity(as);
1165                 		  for (Uint32 i =0; i < as*sizeof(Real32); i+=sizeof(Real32)) {
1166                 			Real32 val;
1167                 			memcpy( &val, ar + pos + i, sizeof(Real32));
1168                 		  	a_val.append(val);
1169                 		  }
1170                 		  val.set(a_val);
1171                 #else
1172 schuur      1.1                   val.set(Array<Real32>((Real32*)(ar+pos),as));
1173 konrad.r    1.7 #endif
1174 schuur      1.1                   pos+=sizeof(Real32)*as;
1175                                }
1176                                break;
1177                             case CIMTYPE_REAL64: {
1178 konrad.r    1.7 #ifdef TYPE_CONV
1179                 		  Array<Real64> a_val;
1180                 		  a_val.reserveCapacity(as);
1181                 		  for (Uint32 i =0; i < as*sizeof(Real64); i+=sizeof(Real64)) {
1182                 			Real64 val;
1183                 			memcpy( &val, ar + pos + i, sizeof(Real64));
1184                 		  	a_val.append(val);
1185                 		  }
1186                 		  val.set(a_val);
1187                 #else
1188 schuur      1.1                   val.set(Array<Real64>((Real64*)(ar+pos),as));
1189 konrad.r    1.7 #endif
1190 schuur      1.1                   pos+=sizeof(Real64)*as;
1191                                }
1192                                break;
1193                             case CIMTYPE_CHAR16: {
1194 konrad.r    1.7 #ifdef TYPE_CONV
1195                 		  Array<Char16> a_val;
1196                 		  a_val.reserveCapacity(as);
1197                 		  for (Uint32 i =0; i < as*sizeof(Char16); i+=sizeof(Char16)) {
1198                 			Char16 val;
1199                 			memcpy( &val, ar + pos + i, sizeof(Char16));
1200                 		  	a_val.append(val);
1201                 		  }
1202                 		  val.set(a_val);
1203                 #else
1204 schuur      1.1                   val.set(Array<Char16>((Char16*)(ar+pos),as));
1205 konrad.r    1.7 #endif
1206 schuur      1.1                   pos+=sizeof(Char16)*as;
1207                                }
1208                                break;
1209                             case CIMTYPE_STRING: {
1210                                   Array<String> sar;
1211                                   for (Uint32 i=0; i<as; i++) {
1212 konrad.r    1.5                      Uint32 sl; //=*(Uint32*)(ar+pos);
1213                 		     memcpy( &sl, ar+pos, sizeof(Uint32));
1214 schuur      1.1                      pos+=sizeof(Uint32);
1215                                      sar.append(String(((char*)(ar+pos)),sl));
1216                                      pos+=sl;
1217                                   }
1218                                   val.set(sar);
1219                                }
1220                                break;
1221                             case CIMTYPE_DATETIME: {
1222                                   Array<CIMDateTime> dar;
1223                                   for (Uint32 i=0; i<as; i++) {
1224 konrad.r    1.5                      Uint32 sl; //=*(Uint32*)(ar+pos);
1225                 		     memcpy( &sl, ar + pos, sizeof(Uint32));		    
1226 schuur      1.1                      pos+=sizeof(Uint32);
1227 konrad.r    1.7 #ifdef TYPE_CONV
1228                 		     String string;
1229                 		     string.reserveCapacity(sl);
1230                 		     for (Uint32 j=0; j < sl*sizeof(Char16); j+=sizeof(Char16)) {
1231                 			Char16 char16;
1232                 			memcpy( &char16, ar + pos + j, sizeof(Char16));
1233                 			string.append( char16 );
1234                 		     }
1235                 		     dar.append(CIMDateTime(string));
1236                 #else
1237 schuur      1.1                      dar.append(CIMDateTime(String(((Char16*)(ar+pos)),sl)));
1238 konrad.r    1.7 #endif
1239 schuur      1.1                      pos+=sl*sizeof(Char16);
1240                                   }
1241                                   val.set(dar);
1242                                }
1243                                break;
1244                             case CIMTYPE_REFERENCE: {
1245                                   Array<CIMObjectPath> rar;
1246                                   for (Uint32 i=0; i<as; i++) {
1247 konrad.r    1.5                      Uint32 sl; //=*(Uint32*)(ar+pos);
1248                 		     memcpy( &sl, ar + pos, sizeof(Uint32));
1249 schuur      1.1                      pos+=sizeof(Uint32);
1250 konrad.r    1.7 #ifdef TYPE_CONV
1251                 		     String string;
1252                 		     string.reserveCapacity(sl);
1253                 		     for (Uint32 j=0; j < sl*sizeof(Char16); j+=sizeof(Char16)) {
1254                 			Char16 char16;
1255                 			memcpy( &char16, ar + pos + j, sizeof(Char16));
1256                 			string.append( char16 );
1257                 		     }
1258                 		     rar.append(CIMObjectPath( string ));
1259                 #else
1260 schuur      1.1                      rar.append(CIMObjectPath(String(((Char16*)(ar+pos)),sl)));
1261 konrad.r    1.7 #endif
1262 schuur      1.1                      pos+=sl*sizeof(Char16);
1263                                   }
1264                                   val.set(rar);
1265                                }
1266                                break;
1267                             default:
1268                                PEGASUS_ASSERT(false);
1269                             }
1270                             return val;
1271                          }
1272                 
1273                          else {
1274                 
1275                             CIMValue val(type,isArray);
1276                 
1277                             switch (type) {
1278                             case CIMTYPE_BOOLEAN:
1279 konrad.r    1.6 	       Boolean b;
1280                 	       memcpy(&b, ar + pos, sizeof(Boolean));
1281                                //val.set(*(Boolean*)(ar+pos));
1282                 	       val.set(b);
1283 schuur      1.1                pos++;
1284                                break;
1285                             case CIMTYPE_SINT8:
1286 w.otsuka    1.9.2.1 	      {
1287                     	       Sint8 sint=0;
1288 w.otsuka    1.9.2.2 	       memcpy( &sint, ar + pos, sizeof(Sint8));
1289 konrad.r    1.6                    //val.set(*(Sint8*)(ar+pos));
1290                     	       val.set(sint);
1291 schuur      1.1                    pos++;
1292 w.otsuka    1.9.2.1 	      }
1293 schuur      1.1                    break;
1294                                 case CIMTYPE_UINT8:
1295 konrad.r    1.6     	       Uint8 uint;
1296                                    //val.set(*(Uint8*)(ar+pos));
1297                     	       memcpy(&uint, ar + pos, sizeof(Uint8));
1298                     	       val.set(uint);
1299 schuur      1.1                    pos++;
1300                                    break;
1301                                 case CIMTYPE_UINT16:
1302 konrad.r    1.6     	       Uint16 uint16;
1303                                    //val.set(*(Uint16*)(ar+pos));
1304                     	       memcpy( &uint16, ar + pos, sizeof(Uint16));
1305                     	       val.set(uint16);
1306 schuur      1.1                    pos+=sizeof(Uint16);
1307                                    break;
1308                                 case CIMTYPE_SINT16:
1309 konrad.r    1.6     	       Sint16 sint16;
1310                                    //val.set(*(Sint16*)(ar+pos));
1311                     	       memcpy( &sint16, ar + pos, sizeof(Sint16));
1312                     	       val.set(sint16);
1313 schuur      1.1                    pos+=sizeof(Sint16);
1314                                    break;
1315 konrad.r    1.7                 case CIMTYPE_CHAR16: {
1316                     		Char16 char16;
1317                     		memcpy( &char16, ar + pos, sizeof(Char16));
1318                                    //val.set(*(Char16*)(ar+pos));
1319                     		val.set ( char16 );
1320 schuur      1.1                    pos+=sizeof(Char16);
1321                                    break;
1322 konrad.r    1.7     	  	}
1323 schuur      1.1                 case CIMTYPE_UINT32:
1324 konrad.r    1.6     	       Uint32 uint32;
1325                     	       memcpy ( &uint32, ar + pos, sizeof(Uint32));
1326                                    //val.set(*(Uint32*)(ar+pos));
1327                     	       val.set( uint32 );
1328 schuur      1.1                    pos+=sizeof(Uint32);
1329                                    break;
1330                                 case CIMTYPE_SINT32:
1331 konrad.r    1.6     	       Sint32 sint32;
1332                     	       memcpy ( &sint32, ar + pos, sizeof(Sint32));
1333                                    //val.set(*(Sint32*)(ar+pos));
1334                     	       val.set ( sint32 );
1335 schuur      1.1                    pos+=sizeof(Sint32);
1336                                    break;
1337                                 case CIMTYPE_REAL32:
1338 konrad.r    1.6     	       Real32 real32;
1339                     	       memcpy ( &real32, ar + pos, sizeof(Real32));
1340                                    //val.set(*(Real32*)(ar+pos));
1341                     	       val.set ( real32 );
1342 schuur      1.1                    pos+=sizeof(Real32);
1343                                    break;
1344                                 case CIMTYPE_UINT64:
1345 konrad.r    1.6     	       Uint64 uint64;
1346                     	       memcpy ( &uint64, ar + pos, sizeof(Uint64));
1347                                    //val.set(*(Uint64*)(ar+pos));
1348                     	       val.set( uint64 );
1349 schuur      1.1                    pos+=sizeof(Uint64);
1350                                    break;
1351                                 case CIMTYPE_SINT64:
1352 konrad.r    1.6     	       Sint64 sint64;
1353                     	       memcpy( &sint64, ar + pos, sizeof(Sint64));
1354                                    //val.set(*(Sint64*)(ar+pos));
1355                     	       val.set( sint64 );
1356 schuur      1.1                    pos+=sizeof(Sint64);
1357                                    break;
1358                                 case CIMTYPE_REAL64:
1359 konrad.r    1.6     	       Real64 real64;
1360                     	       memcpy ( &real64, ar + pos, sizeof(Real64));
1361                                    //val.set(*(Real64*)(ar+pos));
1362                     		val.set( real64 );
1363 schuur      1.1                    pos+=sizeof(Real64);
1364                                    break;
1365                                 case CIMTYPE_STRING: {
1366 konrad.r    1.5                       Uint32 sl; //=*(Uint32*)(ar+pos);
1367                     		  memcpy( &sl, ar + pos, sizeof(Uint32));
1368 schuur      1.1                       pos+=sizeof(Uint32);
1369                                       val.set(String(((char*)(ar+pos)),sl));
1370                                       pos+=sl;
1371                                    }
1372                                    break;
1373                                 case CIMTYPE_DATETIME: {
1374 konrad.r    1.5                       Uint32 dtl; //=*(Uint32*)(ar+pos);
1375                     		  memcpy( &dtl, ar + pos, sizeof (Uint32));
1376 schuur      1.1                       pos+=sizeof(Uint32);
1377 konrad.r    1.7     
1378                     		  CIMDateTime time;
1379                     #ifdef TYPE_CONV
1380                     		  String string;
1381                     		  string.reserveCapacity(dtl);
1382                     
1383                     		   for (Uint32 i =0; i < dtl*sizeof(Char16); i+=sizeof(Char16)) {
1384                     			Char16 char_at;
1385                     			memcpy( &char_at, ar + pos + i, sizeof(Char16));
1386                     			string.append( char_at );
1387                     		   }
1388                     		 time = CIMDateTime ( string ); 
1389                     #else
1390                     		 time = CIMDateTime(String(((Char16*)(ar+pos)),dtl));
1391                     #endif
1392                                      val.set( time );
1393                                      pos+=dtl*sizeof(Char16);
1394 schuur      1.1                    }
1395                                    break;
1396                                 case CIMTYPE_REFERENCE: {
1397 konrad.r    1.5                       Uint32 rfl; //=*(Uint32*)(ar+pos);
1398                     		  memcpy( &rfl, ar + pos, sizeof (Uint32));
1399 schuur      1.1                       pos+=sizeof(Uint32);
1400 konrad.r    1.7     
1401                     		  CIMObjectPath objPath;
1402                     #ifdef TYPE_CONV
1403                     		  String string;
1404                     
1405                     		  string.reserveCapacity(rfl);
1406                     		  for (Uint32 i =0; i < rfl*sizeof(Char16); i+=sizeof(Char16)) {
1407                     			Char16 char_at;
1408                     			memcpy ( &char_at, ar + pos +i, sizeof(Char16));
1409                     			string.append( char_at );
1410                     		  }
1411                     		  objPath = CIMObjectPath( string );
1412                     #else
1413                     		  objPath = CIMObjectPath(String(((Char16*)(ar+pos)),rfl));
1414                     #endif
1415                     		  val.set( objPath);
1416 schuur      1.1                       pos+=rfl*sizeof(Char16);
1417                                    }
1418                                    break;
1419                                 default:
1420                                    PEGASUS_ASSERT(false);
1421                                 }
1422                                 return val;
1423                              }
1424                           }
1425                           else {
1426                              CIMValue val;
1427                              val.setNullValue(type,isArray,as);
1428                              return val;
1429                           }
1430                           break;
1431                        }
1432                        default:
1433                            throw BinException(BINREP_VALUE,String("CIMValue subtype version ")+
1434                               CIMValue(preamble->version()).toString()+" not supported ");
1435                        }
1436                        return CIMValue();
1437 schuur      1.1     }
1438                     
1439                     
1440                     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2