Changeset 4948 in CLRX


Ignore:
Timestamp:
Sep 4, 2019, 10:25:43 PM (2 weeks ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCmBin: Replace MsgPackArrayWriter? by MsgPackStaticArrayWriter? (array with known element number).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdbin/ROCmMetadataMP.cpp

    r4947 r4948  
    10621062class CLRX_INTERNAL MsgPackMapWriter;
    10631063
    1064 class CLRX_INTERNAL MsgPackArrayWriter
     1064class CLRX_INTERNAL MsgPackStaticArrayWriter
    10651065{
    10661066private:
    10671067    std::vector<cxbyte>& output;
    10681068    size_t elemsNum;
    1069     std::vector<cxbyte> temp;
     1069    size_t count;
    10701070public:
    1071     MsgPackArrayWriter(std::vector<cxbyte>& output);
     1071    MsgPackStaticArrayWriter(size_t elemsNum, std::vector<cxbyte>& output);
    10721072   
    10731073    void putBool(bool b);
    10741074    void putString(const char* str);
    10751075    void putUInt(uint64_t v);
    1076     MsgPackArrayWriter putArray();
     1076    MsgPackStaticArrayWriter putStaticArray(size_t aelemsNum);
    10771077    MsgPackMapWriter putMap();
    10781078    void flush();
     
    10921092    void putValueString(const char* str);
    10931093    void putValueUInt(uint64_t v);
    1094     MsgPackArrayWriter putValueArray();
     1094    MsgPackStaticArrayWriter putValueStaticArray(size_t aelemsNum);
    10951095    MsgPackMapWriter putValueMap();
     1096    std::vector<cxbyte>& putValueElement();
    10961097    void flush();
    10971098};
    10981099
    1099 MsgPackArrayWriter::MsgPackArrayWriter(std::vector<cxbyte>& _output)
    1100         : output(_output), elemsNum(0)
    1101 { }
    1102 
    1103 void MsgPackArrayWriter::putBool(bool b)
    1104 {
    1105     elemsNum++;
    1106     msgPackWriteBool(b, temp);
    1107 }
    1108 
    1109 void MsgPackArrayWriter::putString(const char* str)
    1110 {
    1111     elemsNum++;
    1112     msgPackWriteString(str, temp);
    1113 }
    1114 
    1115 void MsgPackArrayWriter::putUInt(uint64_t v)
    1116 {
    1117     elemsNum++;
    1118     msgPackWriteUInt(v, temp);
    1119 }
    1120 
    1121 MsgPackArrayWriter MsgPackArrayWriter::putArray()
    1122 {
    1123     elemsNum++;
    1124     return MsgPackArrayWriter(temp);
    1125 }
    1126 
    1127 void MsgPackArrayWriter::flush()
     1100MsgPackStaticArrayWriter::MsgPackStaticArrayWriter(size_t _elemsNum,
     1101            std::vector<cxbyte>& _output) : output(_output), elemsNum(_elemsNum), count(0)
    11281102{
    11291103    if (elemsNum < 16)
     
    11461120        output.insert(output.end(), d, d+3);
    11471121    }
    1148     output.insert(output.end(), temp.begin(), temp.end());
     1122}
     1123
     1124void MsgPackStaticArrayWriter::putBool(bool b)
     1125{
     1126    if (count == elemsNum)
     1127        throw BinException("MsgPack: Too many array elements");
     1128    count++;
     1129    msgPackWriteBool(b, output);
     1130}
     1131
     1132void MsgPackStaticArrayWriter::putString(const char* str)
     1133{
     1134    if (count == elemsNum)
     1135        throw BinException("MsgPack: Too many array elements");
     1136    count++;
     1137    msgPackWriteString(str, output);
     1138}
     1139
     1140void MsgPackStaticArrayWriter::putUInt(uint64_t v)
     1141{
     1142    if (count == elemsNum)
     1143        throw BinException("MsgPack: Too many array elements");
     1144    count++;
     1145    msgPackWriteUInt(v, output);
     1146}
     1147
     1148MsgPackStaticArrayWriter MsgPackStaticArrayWriter::putStaticArray(size_t aelemsNum)
     1149{
     1150    if (count == elemsNum)
     1151        throw BinException("MsgPack: Too many array elements");
     1152    count++;
     1153    return MsgPackStaticArrayWriter(aelemsNum, output);
    11491154}
    11501155
     
    11861191}
    11871192
    1188 MsgPackArrayWriter MsgPackMapWriter::putValueArray()
     1193MsgPackStaticArrayWriter MsgPackMapWriter::putValueStaticArray(size_t aelemsNum)
    11891194{
    11901195    if (inKey)
    11911196        throw BinException("MsgPack: Not in value value");
    11921197    inKey = true;
    1193     return MsgPackArrayWriter(temp);
     1198    return MsgPackStaticArrayWriter(aelemsNum, temp);
     1199}
     1200
     1201std::vector<cxbyte>& MsgPackMapWriter::putValueElement()
     1202{
     1203    if (inKey)
     1204        throw BinException("MsgPack: Not in value value");
     1205    inKey = true;
     1206    return temp;
    11941207}
    11951208
Note: See TracChangeset for help on using the changeset viewer.