9Block::Block() : filename_(0), blockSize_(512), indexEnd_(0), fileSize_(0)
 
   18    size_t filenameLength = wcslen(filename);
 
   19    char* 
name = 
new char[filenameLength+1];
 
   21    name[filenameLength] = 0;
 
   28    bool ret = this->
Open(filename);
 
   33bool Block::Open(
const wchar_t* filename, ios_base::openmode mode)
 
   38    size_t filenameLength = wcslen(filename);
 
   43    if (!
file_.is_open()) 
return false;
 
   48    if (mode & ios_base::in)
 
   50        file_.seekg(0, ios_base::end);
 
   53    else if (mode & ios_base::out)
 
   55        file_.seekp(0, ios_base::end);
 
   79    return !
file_.is_open();
 
   86    return file_.is_open();
 
   94    if (!(
mode_ & ios_base::in)) 
return false;
 
  109    if (!(
mode_ & ios_base::out)) 
return false;
 
  120    return file_.is_open();
 
  128    if (!(
mode_ & ios_base::out)) 
return false;
 
  131        if (index1 == index2) 
return true;
 
  134        if (!this->
Read(index1, block1)) 
return false;
 
  137        if (!this->
Read(index2, block2)) 
return false;
 
  139        if (!this->
Write(index1, block2)) 
return false;
 
  140        if (!this->
Write(index2, block1)) 
return false;
 
  154    if (!(
mode_ & ios_base::out)) 
return false;
 
  159            for (
size_t i=from; i!=to; ++i)
 
  161                if (!this->
Swap(i, i+1)) 
return false;
 
  166            for (
size_t i=from; i!=to; --i)
 
  168                if (!this->
Swap(i, i-1)) 
return false;
 
  181    if (!(
mode_ & ios_base::out)) 
return false;
 
  194        return this->
Write(index, block);
 
  203    if (!(
mode_ & ios_base::out)) 
return false;
 
  211        for (
size_t i=0, j=0; i!=
indexEnd_+1; ++i)
 
  236    if (!(
mode_ & ios_base::out)) 
return false;
 
  239    size_t maxIndices = indices.size();
 
  245        bool toDelete = 
false;
 
  246        for (
size_t j=0; j<maxIndices; ++j)
 
  275    uk1_(0), uk2_(0), uk3_(0), uk4_(0), uk5_(0x003B), uk6_(0x0003), uk7_(-2),
 
  276    log2BigBlockSize_(9), log2SmallBlockSize_(6),
 
  278    BATCount_(1), propertiesStart_(1),
 
  279    uk10_(0), uk11_(0x00001000),
 
  280    SBATStart_(-2), SBATCount_(0),
 
  281    XBATStart_(-2), XBATCount_(0)
 
  345    bigBlockSize_ = (size_t)pow(2.0, log2BigBlockSize_);        
 
  346    smallBlockSize_ = (size_t)pow(2.0, log2SmallBlockSize_);    
 
  354    propertyType_(1), nodeColor_(1),
 
  355    previousProp_(-1), nextProp_(-1), childProp_(-1),
 
  356    uk1_(0), uk2_(0), uk3_(0), uk4_(0), uk5_(0),
 
  357    seconds1_(0), days1_(0), seconds2_(0), days2_(0),
 
  358    startBlock_(-2), size_(0)
 
  417    size_t maxChildren = children_.size();
 
  418    for (
size_t i=0; i<maxChildren; ++i) 
delete children_[i];
 
  452    wcscpy(root->
name_, L
"Root Entry");
 
  472    if (!
file_.
Open(filename, mode)) 
return false;
 
  497    for (
size_t i=0; i<maxProperties; ++i)
 
  530    if (wcscmp(path, L
".") == 0)
 
  536    if (wcscmp(path, L
"..") == 0)
 
  546    if (wcscmp(path, L
"\\") == 0)
 
  557    size_t pathLength = wcslen(path);
 
  558    if (pathLength > 0 && path[0] == L
'\\')
 
  567        for (; npos<pathLength; ++npos)
 
  569            if (path[npos] == L
'\\') 
break;
 
  572        wchar_t* directory = 
new wchar_t[npos-ipos+1];
 
  573        copy (path+ipos, path+npos, directory);
 
  574        directory[npos-ipos] = 0;
 
  586    } 
while (npos < pathLength);
 
  613    vector<wchar_t> fullpath;
 
  617        vector<wchar_t> directory(directoryLength+1);
 
  618        directory[0] = L
'\\';
 
  621              directory.begin()+1);
 
  622        fullpath.insert(fullpath.begin(), directory.begin(), directory.end());
 
  625    fullpath.erase(fullpath.begin(), fullpath.begin()+11);
 
  626    if (fullpath.empty()) fullpath.push_back(L
'\\');
 
  627    copy (fullpath.begin(), fullpath.end(), path);
 
  628    path[fullpath.size()] = 0;
 
  642        vector<wchar_t> directory(directoryLength+1);
 
  643        directory[0] = L
'\\';
 
  646              directory.begin()+1);
 
  647        path.insert(path.begin(), directory.begin(), directory.end());
 
  650    path.erase(path.begin(), path.begin()+11);
 
  651    if (path.empty()) path.push_back(L
'\\');
 
  680        size_t maxChildren = directory->
children_.size();
 
  681        wchar_t* curpath = 
new wchar_t[65535];
 
  682        for (
size_t i=0; i<maxChildren; ++i)
 
  686            if (directory->
children_[i]->self_->propertyType_ == 1)
 
  691            else if (directory->
children_[i]->self_->propertyType_ == 2)
 
  723        if (ret != 
SUCCESS) 
return ret;
 
  727    vector<wchar_t> 
name(32);
 
  728    for (
size_t i=0; i<maxChildren; ++i)
 
  731        list.push_back(
name);
 
  778    if (wcscmp(path, L
"\\") == 0)
 
  789        size = 
property->self_->size_;
 
  803    if (wcscmp(path, L
"\\") == 0)
 
  816    if (property->self_->size_ >= 4096)
 
  819        buffer = 
new char[
DataSize(property->self_->startBlock_, 
true)];
 
  820        ReadData(property->self_->startBlock_, buffer, 
true);
 
  825        buffer = 
new char[
DataSize(property->self_->startBlock_, 
false)];
 
  826        ReadData(property->self_->startBlock_, buffer, 
false);
 
  829    copy (buffer, buffer+property->self_->size_, data);
 
  842    if (ret != 
SUCCESS) 
return ret;
 
  844    data.resize(dataSize);
 
  845    return ReadFile(path, &*(data.begin()));
 
  855    if (property->self_->size_ >= 4096)
 
  857        if (size >= 4096) 
property->self_->startBlock_ = 
WriteData(data, size, property->self_->startBlock_, 
true);
 
  860            property->self_->startBlock_ = 
WriteData(0, 0, property->self_->startBlock_, 
true);
 
  861            property->self_->startBlock_ = 
WriteData(data, size, property->self_->startBlock_, 
false);
 
  866        if (size < 4096) 
property->self_->startBlock_ = 
WriteData(data, size, property->self_->startBlock_, 
false);
 
  869            property->self_->startBlock_ = 
WriteData(0, 0, property->self_->startBlock_, 
false);
 
  870            property->self_->startBlock_ = 
WriteData(data, size, property->self_->startBlock_, 
true);
 
  873    property->self_->size_ = size;
 
  884    return WriteFile(path, &*(data.begin()), size);
 
  890    size_t filenameLength = strlen(filename);
 
  891    wchar_t* wname = 
new wchar_t[filenameLength+1];
 
  892    mbstowcs(wname, filename, filenameLength);
 
  893    wname[filenameLength] = 0;
 
  901    size_t filenameLength = strlen(filename);
 
  902    wchar_t* wname = 
new wchar_t[filenameLength+1];
 
  903    mbstowcs(wname, filename, filenameLength);
 
  904    wname[filenameLength] = 0;
 
  905    bool ret = 
Open(wname, mode);
 
  912    size_t pathLength = strlen(path);
 
  913    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  914    mbstowcs(wpath, path, pathLength);
 
  915    wpath[pathLength] = 0;
 
  923    size_t pathLength = strlen(path);
 
  924    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  925    mbstowcs(wpath, path, pathLength);
 
  926    wpath[pathLength] = 0;
 
  934    size_t pathLength = strlen(path);
 
  935    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  939        pathLength = wcslen(wpath);
 
  941        path[pathLength] = 0;
 
  949    vector<wchar_t> wpath;
 
  953        size_t pathLength = wpath.size();
 
  954        path.resize(pathLength);
 
  955        wcstombs(&*(path.begin()), &*(wpath.begin()), pathLength);
 
  956        path[pathLength] = 0;
 
  963    size_t pathLength = strlen(path);
 
  964    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  965    mbstowcs(wpath, path, pathLength);
 
  966    wpath[pathLength] = 0;
 
  974    size_t pathLength = strlen(path);
 
  975    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  976    mbstowcs(wpath, path, pathLength);
 
  977    wpath[pathLength] = 0;
 
  985    size_t pathLength = strlen(path);
 
  986    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  987    mbstowcs(wpath, path, pathLength);
 
  988    wpath[pathLength] = 0;
 
  996    size_t pathLength = strlen(path);
 
  997    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
  998    mbstowcs(wpath, path, pathLength);
 
  999    wpath[pathLength] = 0;
 
 1007    size_t pathLength = strlen(path);
 
 1008    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
 1009    mbstowcs(wpath, path, pathLength);
 
 1010    wpath[pathLength] = 0;
 
 1017    size_t pathLength = strlen(path);
 
 1018    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
 1019    mbstowcs(wpath, path, pathLength);
 
 1020    wpath[pathLength] = 0;
 
 1027    size_t pathLength = strlen(path);
 
 1028    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
 1029    mbstowcs(wpath, path, pathLength);
 
 1030    wpath[pathLength] = 0;
 
 1037    size_t pathLength = strlen(path);
 
 1038    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
 1039    mbstowcs(wpath, path, pathLength);
 
 1040    wpath[pathLength] = 0;
 
 1047    size_t pathLength = strlen(path);
 
 1048    wchar_t* wpath = 
new wchar_t[pathLength+1];
 
 1049    mbstowcs(wpath, path, pathLength);
 
 1050    wpath[pathLength] = 0;
 
 1065    size_t maxIndices = indices.size();
 
 1071        for (
size_t j=0; j<maxIndices; ++j)
 
 1083        for (
size_t j=0; j<maxIndices; ++j)
 
 1095        for (
size_t j=0; j<maxIndices; ++j)
 
 1108        for (
size_t j=0; j<maxIndices; ++j)
 
 1119    {
for (
size_t i=0; i<maxIndices; ++i)
 
 1131        for (
size_t j=0; j<maxIndices; ++j)
 
 1133            if (
properties_[0]->startBlock_ >= (
int)indices[j] &&
 
 1138    {
for (
size_t i=1; i<maxProperties; ++i)
 
 1143            for (
size_t j=0; j<maxIndices; ++j)
 
 1145                if (
properties_[i]->startBlock_ >= (
int)indices[j] &&
 
 1163    size_t maxIndices = indices.size();
 
 1169        for (
size_t j=0; j<maxIndices; ++j)
 
 1181        for (
size_t j=0; j<maxIndices; ++j)
 
 1193        for (
size_t j=0; j<maxIndices; ++j)
 
 1211            for (
size_t j=0; j<maxIndices; ++j)
 
 1223    sort (indices.begin(), indices.end(), greater<size_t>());
 
 1224    {
for (
size_t i=0; i<maxIndices; ++i)
 
 1234        for (
size_t j=0; j<maxIndices; ++j)
 
 1245    {
for (
size_t i=0; i<maxIndices; ++i)
 
 1257        for (
size_t j=0; j<maxIndices; ++j)
 
 1259            if (
properties_[0]->startBlock_ > (
int)indices[j] &&
 
 1264    {
for (
size_t i=1; i<maxProperties; ++i)
 
 1270            for (
size_t j=0; j<maxIndices; ++j)
 
 1272                if (
properties_[i]->startBlock_ > (
int)indices[j] &&
 
 1281                             wchar_t*& parentpath,
 
 1282                             wchar_t*& propertyname)
 
 1288    size_t pathLength = wcslen(path);
 
 1291    for (npos=pathLength-1; npos>0; --npos)
 
 1293        if (path[npos] == L
'\\') 
break;
 
 1299        parentpath = 
new wchar_t[npos+1];
 
 1300        copy (path, path+npos, parentpath);
 
 1301        parentpath[npos] = 0;
 
 1306    if (npos==0 && pathLength > 0 && path[0] == L
'\\') ++npos;
 
 1307    propertyname = 
new wchar_t[pathLength-npos+1];
 
 1308    copy (path+npos, path+pathLength, propertyname);
 
 1309    propertyname[pathLength-npos] = 0;
 
 1345        for (
size_t j=0; j<128; ++j)
 
 1356        for (
size_t j=0; j<128; ++j)
 
 1367        for (
size_t j=0; j<128; ++j)
 
 1380        for (
size_t j=0; j<128; ++j)
 
 1390        for (
size_t j=0; j<128; ++j)
 
 1400        for (
size_t j=0; j<128; ++j)
 
 1414    vector<size_t> indices;
 
 1435    vector<size_t> indices;
 
 1439        size_t maxIndices = indices.size();
 
 1440        for (
size_t i=0; i<maxIndices; ++i)
 
 1449        size_t minIndex = *min_element(indices.begin(), indices.end());
 
 1452        size_t minBlock = minIndex / smallBlocksPerBigBlock;
 
 1459        size_t maxIndices = indices.size();
 
 1460        for (
size_t i=0; i<maxIndices; ++i)
 
 1481        if (size==0 && startIndex==-2) 
return startIndex;
 
 1484        vector<size_t> indices;
 
 1486        size_t maxPresentBlocks = indices.size();
 
 1493        int extraBlocks = maxPresentBlocks - maxNewBlocks;
 
 1494        if (extraBlocks > 0)
 
 1497            if (maxNewBlocks != 0) 
blocksIndices_[indices[maxNewBlocks]-1] = -2;
 
 1498            else startIndex = -2;
 
 1501            vector<size_t> indicesToRemove(extraBlocks);
 
 1502            copy (indices.begin()+maxNewBlocks, indices.end(), indicesToRemove.begin());
 
 1503            indices.erase(indices.begin()+maxNewBlocks, indices.end());
 
 1512        if (maxPresentBlocks != 0)
 
 1514            for (; remainingFullBlocks && curIndex<maxPresentBlocks;
 
 1515                   --remainingFullBlocks, ++curIndex)
 
 1523        if (indices.empty()) index = 0;
 
 1524        else if (curIndex == 0) index = indices[0];
 
 1525        else index = (startIndex != -2) ? indices[curIndex-1] : 0;
 
 1526        if (remainingFullBlocks != 0)
 
 1532                if (startIndex == -2) startIndex = newIndex; 
 
 1537            } 
while (--remainingFullBlocks);
 
 1543            if (curIndex >= maxPresentBlocks)
 
 1547                if (startIndex == -2) startIndex = newIndex;
 
 1550            else newIndex = indices[curIndex];
 
 1555            file_.
Write(newIndex+1, &*(tempdata.begin()));
 
 1561        if (size==0 && startIndex==-2) 
return startIndex;
 
 1563        if (size != 0 && 
properties_[0]->startBlock_ == -2)
 
 1574        vector<size_t> indices;
 
 1576        size_t maxPresentBlocks = indices.size();
 
 1582        vector<char> smallBlocksData;
 
 1583        int extraBlocks = maxPresentBlocks - maxNewBlocks;
 
 1584        if (extraBlocks > 0)
 
 1589            else startIndex = -2;
 
 1592            vector<size_t> indicesToRemove(extraBlocks);
 
 1593            copy (indices.begin()+maxNewBlocks, indices.end(), indicesToRemove.begin());
 
 1594            indices.erase(indices.begin()+maxNewBlocks, indices.end());
 
 1599        else if (extraBlocks < 0)
 
 1604            smallBlocksData.resize(actualSize);
 
 1609            size_t newBlocksNeeded = -extraBlocks;
 
 1610            size_t index = maxPresentBlocks - 1;
 
 1611            for (
size_t i=0; i<newBlocksNeeded; ++i)
 
 1614                if (startIndex == -2) startIndex = newIndex; 
 
 1616                smallBlocksData.insert(smallBlocksData.begin()+newIndex,
 
 1622        if (smallBlocksData.empty())
 
 1627            smallBlocksData.resize(actualSize);
 
 1635        for (
size_t i=0; i<fullBlocks; ++i)
 
 1661            indices.push_back(i);
 
 1666            indices.push_back(i);
 
 1794        size_t maxIndices = indices.size();
 
 1795        {
for (
size_t i=0; i<maxIndices; ++i) ++indices[i];} 
 
 1799        vector<size_t> indicesToRemove;
 
 1818                if (BATindex != 109)
 
 1827        if (!indicesToRemove.empty()) 
file_.
Erase(indicesToRemove);
 
 1832        size_t maxIndices = indices.size();
 
 1836        char* data = 
new char[size];
 
 1840        {
for (
size_t i=0, j=0; i<maxSmallBlocks; ++i)
 
 1842            if (find(indices.begin(), indices.end(), i) == indices.end())
 
 1858        {
for (
size_t i=0; i<maxIndices; ++i)
 
 1860            for (
size_t j=0; j<maxSBATindices; ++j)
 
 1862                if (j == indices[i]) 
continue;
 
 1869        sort (indices.begin(), indices.end(), greater<size_t>());
 
 1870        {
for (
size_t i=0; i<maxIndices; ++i)
 
 1875        vector<size_t> indicesToRemove;
 
 1896    char* buffer = 
new char[propertiesSize];
 
 1902    size_t maxProperties = maxPropertiesBlock * propertiesPerBlock;
 
 1903    size_t maxBlocks = maxProperties / propertiesPerBlock +
 
 1904                       (maxProperties % propertiesPerBlock ? 1 : 0);
 
 1906    for (
size_t i=0; i<maxBlocks; ++i)
 
 1908        for (
size_t j=0; j<4; ++j)
 
 1912            property->
Read(buffer+i*512+j*128);
 
 1913            if (wcslen(property->name_) == 0)
 
 1939    size_t maxBlocks = maxProperties / propertiesPerBlock +
 
 1940                       (maxProperties % propertiesPerBlock ? 1 : 0);
 
 1942    char* buffer = 
new char[propertiesSize];
 
 1943    {
for (
size_t i=0; i<propertiesSize; ++i) buffer[i] = 0;}
 
 1944    {
for (
size_t i=0; i<maxProperties; ++i)
 
 1960    wchar_t* parentpath = 0;
 
 1961    wchar_t* propertyname = 0;
 
 1965    if (wcslen(path) != 0)
 
 1969    SplitPath(path, parentpath, propertyname);
 
 1971    if (propertyname != 0)
 
 1973        if (parentpath != 0)
 
 1980                    delete[] parentpath;
 
 1981                    delete[] propertyname;
 
 1986            delete[] parentpath;
 
 1990        size_t propertynameLength = wcslen(propertyname);
 
 1991        if (propertynameLength >= 32)
 
 1993            delete[] propertyname;
 
 1996        wcscpy(property->
name_, propertyname);
 
 1997        delete[] propertyname;
 
 1998        property->nameSize_ = propertynameLength*2+2;
 
 2004            for (index=1; index<maxProperties; ++index)
 
 2008            if (index != maxProperties)
 
 2021        if (parentpath != 0) 
delete[] parentpath;
 
 2033    if (currentTree->
index_ != index)
 
 2035        size_t maxChildren = currentTree->
children_.size();
 
 2036        for (
size_t i=0; i<maxChildren; ++i)
 
 2064    wchar_t* parentpath = 0;
 
 2065    wchar_t* filename = 0;
 
 2067    if (wcslen(path) != 0)
 
 2073    if (parentpath != 0)
 
 2076        delete[] parentpath;
 
 2080            if (filename != 0) 
delete[] filename;
 
 2109        size_t maxChildren = parentTree->
children_.size();
 
 2110        for (
size_t i=0; i<maxChildren; ++i)
 
 2112            if (wcscmp(parentTree->
children_[i]->self_->name_, 
name) == 0)
 
 2139    tree->
self_ = property;
 
 2164    size_t maxChildren = parentTree->
children_.size();
 
 2166    for (i=0; i<maxChildren; ++i)
 
 2168        if (index < parentTree->children_[i]->index_) 
break;
 
 2192    for (i=0; i<maxChildren; ++i)
 
 2205    size_t maxChildren = parentTree->
children_.size();
 
 2206    if (maxChildren != 0)
 
 2208        vector<PropertyTree*>& children = parentTree->
children_;
 
 2209        size_t prevChild = 0;
 
 2210        children[0]->self_->previousProp_ = -1;
 
 2211        children[0]->self_->nextProp_ = -1;
 
 2213        for (curChild=1; curChild<=maxChildren/2; ++curChild)
 
 2215            children[curChild]->self_->previousProp_ = children[prevChild]->index_;
 
 2216            children[curChild]->self_->nextProp_ = -1;
 
 2217            prevChild = curChild;
 
 2222        children[curChild]->parent_->self_->childProp_ = children[curChild]->index_;
 
 2225        size_t nextChild = curChild + 1;
 
 2226        if (nextChild < maxChildren)
 
 2228            children[curChild]->self_->nextProp_ = children[nextChild]->index_;
 
 2229            for (++curChild, ++nextChild;
 
 2230                 nextChild<maxChildren;
 
 2231                 ++curChild, ++nextChild)
 
 2233                children[curChild]->self_->previousProp_ = -1;
 
 2234                children[curChild]->self_->nextProp_ = children[nextChild]->index_;
 
 2237            children[curChild]->self_->previousProp_ = -1;
 
 2238            children[curChild]->self_->nextProp_ = -1;
 
 2278    size_t maxChildren = parentTree->
children_.size();
 
 2279    for (
size_t i=0; i<maxChildren; ++i)
 
 2315    size_t maxChildren = parentTree->
children_.size();
 
 2316    for (
size_t i=0; i<maxChildren; ++i)
 
 2369            copy (
data_.begin()+i*8224, 
data_.begin()+(i+1)*8224, data+npos);
 
 2382        copy (
data_.begin()+i*8224, 
data_.begin()+i*8224+size, data+npos);
 
 2391        copy (
data_.begin(), 
data_.begin()+size, data+npos);
 
 2394        for (c=1; c<maxContinue; ++c)
 
 2457    wname_(0), name_(0), unicode_(s.unicode_)
 
 2461        size_t len = strlen(s.
name_);
 
 2462        name_ = 
new char[len+1];
 
 2467        size_t len = wcslen(s.
wname_);
 
 2468        wname_ = 
new wchar_t[len+1];
 
 2478        size_t len = strlen(s.
name_);
 
 2479        name_ = 
new char[len+1];
 
 2484        size_t len = wcslen(s.
wname_);
 
 2485        wname_ = 
new wchar_t[len+1];
 
 2494    size_t len = strlen(str);
 
 2495    name_ = 
new char[len+1];
 
 2503    size_t len = wcslen(str);
 
 2504    wname_ = 
new wchar_t[len+1];
 
 2519    size_t bytesRead = 2;
 
 2523        name_ = 
new char[stringSize+1];
 
 2525        name_[(size_t)stringSize] = 0;
 
 2526        bytesRead += stringSize;
 
 2531        wname_ = 
new wchar_t[stringSize+1];
 
 2533        wname_[(size_t)stringSize] = 0;
 
 2534        bytesRead += stringSize*2;
 
 2540    size_t stringSize = 0;
 
 2541    size_t bytesWrite = 0;
 
 2547            stringSize = strlen(
name_);
 
 2551            bytesWrite = 2 + stringSize;
 
 2565            stringSize = wcslen(
wname_);
 
 2569            bytesWrite = 2 + stringSize*2;
 
 2600    wname_(s.wname_), name_(s.name_),
 
 2601    unicode_(s.unicode_), richtext_(s.richtext_), phonetic_(s.phonetic_) {};
 
 2617    size_t len = strlen(str);
 
 2618    name_.resize(len+1);
 
 2619    strcpy(&*(
name_.begin()), str);
 
 2628    size_t len = wcslen(str);
 
 2630    wcscpy(&*(
wname_.begin()), str);
 
 2647    size_t bytesRead = 2;
 
 2648    if (stringSize>0) bytesRead += 
ContinueRead(data+2, stringSize);
 
 2654    if (size == 0) 
return 0;
 
 2666        size_t strpos = 
wname_.size();
 
 2667        wname_.resize(strpos+size, 0);
 
 2676            vector<char> 
name(size);
 
 2678            mbstowcs(&*(
wname_.begin())+strpos, &*(
name.begin()), size);
 
 2692        size_t strpos = 
name_.size();
 
 2693        name_.resize(strpos+size, 0);
 
 2697            vector<wchar_t> 
name(size);
 
 2714    size_t stringSize = 0;
 
 2715    size_t bytesWrite = 0;
 
 2722            stringSize = 
wname_.size();
 
 2741            stringSize = 
name_.size();
 
 2745            bytesWrite = 3 + stringSize;
 
 2767    else return name_.size();
 
 2785    size_t bytesRead = 0;
 
 2793                bytesRead += 
bof_.
Read(data+bytesRead);
 
 2802                bytesRead += 
fonts_.back().Read(data+bytesRead);
 
 2807                bytesRead += 
XFs_.back().Read(data+bytesRead);
 
 2812                bytesRead += 
styles_.back().Read(data+bytesRead);
 
 2821                bytesRead += 
sst_.
Read(data+bytesRead);
 
 2830                bytesRead += rec.
Read(data+bytesRead);
 
 2839    size_t bytesWritten = 0;
 
 2841    bytesWritten += 
bof_.
Write(data+bytesWritten);
 
 2845    size_t maxFonts = 
fonts_.size();
 
 2846    {
for (
size_t i=0; i<maxFonts; ++i) {bytesWritten += 
fonts_[i].Write(data+bytesWritten);}}
 
 2848    size_t maxXFs = 
XFs_.size();
 
 2849    {
for (
size_t i=0; i<maxXFs; ++i) {bytesWritten += 
XFs_[i].Write(data+bytesWritten);}}
 
 2851    size_t maxStyles = 
styles_.size();
 
 2852    {
for (
size_t i=0; i<maxStyles; ++i) {bytesWritten += 
styles_[i].Write(data+bytesWritten);}}
 
 2855    {
for (
size_t i=0; i<maxBoundSheets; ++i) {bytesWritten += 
boundSheets_[i].Write(data+bytesWritten);}}
 
 2857    bytesWritten += 
sst_.
Write(data+bytesWritten);
 
 2860    bytesWritten += 
eof_.
Write(data+bytesWritten);
 
 2862    return bytesWritten;
 
 2870    size_t maxFonts = 
fonts_.size();
 
 2871    {
for (
size_t i=0; i<maxFonts; ++i) {size += 
fonts_[i].RecordSize();}}
 
 2873    size_t maxXFs = 
XFs_.size();
 
 2874    {
for (
size_t i=0; i<maxXFs; ++i) {size += 
XFs_[i].RecordSize();}}
 
 2876    size_t maxStyles = 
styles_.size();
 
 2877    {
for (
size_t i=0; i<maxStyles; ++i) {size += 
styles_[i].RecordSize();}}
 
 2880    {
for (
size_t i=0; i<maxBoundSheets; ++i) {size += 
boundSheets_[i].RecordSize();}}
 
 2892    horizontalPos_(0x78), verticalPos_(0x78), width_(0x3B1F), height_(0x2454),
 
 2893    options_(0x38), activeWorksheetIndex_(0), firstVisibleTabIndex_(0), selectedWorksheetNo_(1),
 
 2911    data_.resize(dataSize_);
 
 2927    height_(200), options_(0), colourIndex_(0x7FFF), weight_(400), escapementType_(0),
 
 2928    underlineType_(0), family_(0), characterSet_(0), unused_(0)
 
 2948    name_.Read(&*(data_.begin())+14);
 
 2963    name_.Write(&*(data_.begin())+14);
 
 2972    fontRecordIndex_(0), formatRecordIndex_(0), protectionType_(0xFFF5), alignment_(0x20), rotation_(0x00),
 
 2973    textProperties_(0x00), usedAttributes_(0x00), borderLines_(0x0000), colour1_(0x0000), colour2_(0x20C0)
 
 2992    data_.resize(dataSize_);
 
 3009    XFRecordIndex_(0x8000), identifier_(0), level_(0xFF)
 
 3015    if (XFRecordIndex_ & 0x8000)
 
 3024        name_.Read(&*(data_.begin())+2);
 
 3032    if (XFRecordIndex_ & 0x8000)
 
 3041        name_.Write(&*(data_.begin())+2);
 
 3051    BOFpos_(0x0000), visibility_(0), type_(0)
 
 3065    name_.Read(&*(data_.begin())+6);
 
 3074    name_.Write(&*(data_.begin())+6);
 
 3090    strings_.resize(uniqueStringsTotal_);
 
 3093    if (continueIndices_.empty())
 
 3095        for (
size_t i = 0; i < (size_t)uniqueStringsTotal_; ++i)
 
 3097            npos += strings_[i].Read(&*(data_.begin())+npos);
 
 3103        size_t maxContinue = continueIndices_.size();
 
 3105        for (
size_t i = 0, c = 0; i < (size_t)uniqueStringsTotal_; ++i)
 
 3111            size_t multiplier = unicode & 1 ? 2 : 1;
 
 3112            if (c >= maxContinue || npos+stringSize*multiplier+3 <= continueIndices_[c])
 
 3115                npos += strings_[i].Read(&*(data_.begin())+npos);
 
 3122                int size = continueIndices_[c] - npos - 1 - bytesRead;
 
 3127                    bytesRead += strings_[i].ContinueRead(&*(data_.begin())+npos+bytesRead, size);
 
 3131                while (c<maxContinue && npos+stringSize+1>continueIndices_[c])
 
 3133                    size_t dataSize = (continueIndices_[c] - continueIndices_[c-1] - 1) / multiplier;
 
 3134                    bytesRead += strings_[i].ContinueRead(&*(data_.begin())+npos+bytesRead, dataSize);
 
 3135                    stringSize -= dataSize + 1;
 
 3140                    bytesRead += strings_[i].ContinueRead(&*(data_.begin())+npos+bytesRead, stringSize);
 
 3146    return npos + 4*(npos/8224 + 1);
 
 3154    size_t maxContinue = continueIndices_.size();
 
 3155    for (
size_t i = 0, c = 0, npos = 8; i < (size_t)uniqueStringsTotal_; ++i)
 
 3157        npos += strings_[i].Write(&*(data_.begin())+npos);
 
 3158        if (c<maxContinue && npos==continueIndices_[c]) ++c;
 
 3159        else if (c<maxContinue && npos > continueIndices_[c])
 
 3162            data_.insert(data_.begin()+continueIndices_[c], strings_[i].unicode_);
 
 3173    continueIndices_.clear();
 
 3174    size_t curMax = 8224;
 
 3175    for (
size_t i = 0; i < (size_t)uniqueStringsTotal_; ++i)
 
 3177        size_t stringSize = strings_[i].StringSize();
 
 3178        if (dataSize_+stringSize+3 <= curMax)
 
 3180            dataSize_ += stringSize + 3;
 
 3186            bool unicode = strings_[i].unicode_ & 1;
 
 3187            if (curMax - dataSize_ >= 12)
 
 3189                if (unicode && !((curMax-dataSize_)%2)) --curMax;   
 
 3190                continueIndices_.push_back(curMax);
 
 3191                stringSize -= (curMax - dataSize_ - 3);
 
 3195                size_t additionalContinueRecords = unicode ? stringSize/8222 : stringSize/8223; 
 
 3196                for (
size_t j=0; j<additionalContinueRecords; ++j)
 
 3201                        continueIndices_.push_back(curMax);
 
 3208                        continueIndices_.push_back(curMax);
 
 3214                dataSize_ += stringSize + 1;
 
 3218                continueIndices_.push_back(dataSize_);
 
 3219                curMax = dataSize_ + 8224;
 
 3220                if (dataSize_+stringSize+3 < curMax)
 
 3222                    dataSize_ += stringSize + 3;
 
 3228                    if (curMax - dataSize_ >= 12)
 
 3230                        if (unicode && !((curMax-dataSize_)%2)) --curMax;   
 
 3231                        continueIndices_.push_back(curMax);
 
 3232                        stringSize -= (curMax - dataSize_ - 3);
 
 3236                        size_t additionalContinueRecords = unicode ? stringSize/8222 : stringSize/8223; 
 
 3237                        for (
size_t j=0; j<additionalContinueRecords; ++j)
 
 3242                                continueIndices_.push_back(curMax);
 
 3249                                continueIndices_.push_back(curMax);
 
 3255                        dataSize_ += stringSize + 1;
 
 3266    return (recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3270    stringsTotal_(0), streamPos_(0), firstStringPos_(0), unused_(0)
 
 3282    size_t maxPortions = (dataSize_-2) / 8;
 
 3284    streamPos_.resize(maxPortions);
 
 3285    firstStringPos_.clear();
 
 3286    firstStringPos_.resize(maxPortions);
 
 3288    unused_.resize(maxPortions);
 
 3290    for (
size_t i=0, npos=2; i<maxPortions; ++i)
 
 3305    size_t maxPortions = streamPos_.size();
 
 3306    for (
size_t i=0, npos=2; i<maxPortions; ++i)
 
 3318    dataSize_ = 2 + streamPos_.size()*8;
 
 3319    dataSize_ += (int)(dataSize_/8224)*4;
 
 3342    size_t bytesRead = 0;
 
 3350                bytesRead += 
bof_.
Read(data+bytesRead);
 
 3354                bytesRead += index_.Read(data+bytesRead);
 
 3358                bytesRead += dimensions_.Read(data+bytesRead);
 
 3362                bytesRead += cellTable_.Read(data+bytesRead);
 
 3366                bytesRead += window2_.Read(data+bytesRead);
 
 3371                bytesRead += rec.
Read(data+bytesRead);
 
 3380    size_t bytesWritten = 0;
 
 3381    bytesWritten += 
bof_.
Write(data+bytesWritten);
 
 3383    bytesWritten += index_.Write(data+bytesWritten);
 
 3385    bytesWritten += dimensions_.Write(data+bytesWritten);
 
 3387    bytesWritten += cellTable_.Write(data+bytesWritten);
 
 3389    bytesWritten += window2_.Write(data+bytesWritten);
 
 3391    bytesWritten += 
eof_.
Write(data+bytesWritten);
 
 3393    return bytesWritten;
 
 3397    size_t dataSize = 0;
 
 3399    dataSize += index_.RecordSize();
 
 3400    dataSize += dimensions_.RecordSize();
 
 3401    dataSize += cellTable_.RecordSize();
 
 3402    dataSize += window2_.RecordSize();
 
 3411    unused1_(0), firstUsedRowIndex_(0), firstUnusedRowIndex_(0), unused2_(0)
 
 3420    size_t nm = int(firstUnusedRowIndex_ - firstUsedRowIndex_ - 1) / 32 + 1;
 
 3422    DBCellPos_.resize(nm);
 
 3425        for (
size_t i=0; i<nm; ++i)
 
 3439    size_t nm = DBCellPos_.size();
 
 3440    for (
size_t i=0; i<nm; ++i)
 
 3450    return (recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3457    firstUsedRowIndex_(0), lastUsedRowIndexPlusOne_(0),
 
 3458    firstUsedColIndex_(0), lastUsedColIndexPlusOne_(0),
 
 3503    rowIndex_(0), colIndex_(0), XFRecordIndex_(0), value_(0), error_(0)
 
 3527    rowIndex_(0), colIndex_(0), XFRecordIndex_(0), SSTRecordIndex_(0)
 
 3549    rowIndex_(0), firstColIndex_(0), lastColIndex_(0)
 
 3557    size_t nc = lastColIndex_ - firstColIndex_ + 1;
 
 3558    XFRecordIndices_.clear();
 
 3559    XFRecordIndices_.resize(nc);
 
 3560    for (
size_t i=0; i<nc; ++i)
 
 3572    size_t nc = XFRecordIndices_.size();
 
 3573    for (
size_t i=0; i<nc; ++i)
 
 3583    return (recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3587    XFRecordIndex_(0), RKValue_(0) {};
 
 3607    size_t nc = lastColIndex_ - firstColIndex_ + 1;
 
 3610    for (
size_t i=0; i<nc; ++i)
 
 3612        XFRK_[i].Read(&*(data_.begin())+4+i*6);
 
 3622    size_t nc = XFRK_.size();
 
 3623    for (
size_t i=0; i<nc; ++i)
 
 3625        XFRK_[i].Write(&*(data_.begin())+4+i*6);
 
 3633    return (recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3646    intdouble_.intvalue_ = value;
 
 3647    value_ = intdouble_.doublevalue_;
 
 3656    intdouble_.doublevalue_ = value_;
 
 3657    long long value = intdouble_.intvalue_;
 
 3684    rowIndex_(0), colIndex_(0), XFRecordIndex_(0), options_(0), unused_(0), 
type_(-1)
 
 3696    RPNtoken_.resize(dataSize_-18);
 
 3699    size_t offset = dataSize_ + 4;
 
 3706            array_.Read(data+offset);
 
 3707            offset += array_.RecordSize();
 
 3712            shrfmla_.Read(data+offset);
 
 3713            offset += shrfmla_.RecordSize();
 
 3718            shrfmla1_.Read(data+offset);
 
 3719            offset += shrfmla1_.RecordSize();
 
 3724            table_.Read(data+offset);
 
 3725            offset += table_.RecordSize();
 
 3744    size_t offset = dataSize_ + 4;
 
 3748            array_.Write(data+offset);
 
 3749            offset += array_.RecordSize();
 
 3753            shrfmla_.Write(data+offset);
 
 3754            offset += shrfmla_.RecordSize();
 
 3758            shrfmla1_.Write(data+offset);
 
 3759            offset += shrfmla1_.RecordSize();
 
 3763            table_.Write(data+offset);
 
 3764            offset += table_.RecordSize();
 
 3767    if (string_.DataSize() != 0) string_.Write(data+offset);
 
 3774    recordSize_ = dataSize + 4*(dataSize/8224 + 1);
 
 3779            recordSize_ += array_.RecordSize();
 
 3783            recordSize_ += shrfmla_.RecordSize();
 
 3787            recordSize_ += shrfmla1_.RecordSize();
 
 3791            recordSize_ += table_.RecordSize();
 
 3794    if (string_.DataSize() != 0) recordSize_ += string_.RecordSize();
 
 3795    return (recordSize_);
 
 3799    firstRowIndex_(0), lastRowIndex_(0), firstColIndex_(0), lastColIndex_(0),
 
 3800    options_(0), unused_(0)
 
 3832    return (
recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3836    firstRowIndex_(0), lastRowIndex_(0), firstColIndex_(0), lastColIndex_(0),
 
 3867    return (
recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3871    firstRowIndex_(0), lastRowIndex_(0), firstColIndex_(0), lastColIndex_(0),
 
 3902    return (
recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3906    firstRowIndex_(0), lastRowIndex_(0), firstColIndex_(0), lastColIndex_(0), 
options_(0),
 
 3907    inputCellRowIndex_(0), inputCellColIndex_(0),
 
 3908    inputCellColumnInputRowIndex_(0), inputCellColumnInputColIndex_(0)
 
 3959    return (
recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 3965    rowIndex_(0), firstCellColIndex_(0), lastCellColIndexPlusOne_(0), height_(255),
 
 3995    type_(-1), normalType_(true) {};
 
 3999    size_t bytesRead = 0;
 
 4004            bytesRead += blank_.Read(data);
 
 4008            bytesRead += boolerr_.Read(data);
 
 4012            bytesRead += labelsst_.Read(data);
 
 4016            bytesRead += mulblank_.Read(data);
 
 4020            bytesRead += mulrk_.Read(data);
 
 4024            bytesRead += number_.Read(data);
 
 4028            bytesRead += rk_.Read(data);
 
 4032            bytesRead += formula_.Read(data);
 
 4039    size_t bytesWritten = 0;
 
 4043            bytesWritten += blank_.Write(data);
 
 4047            bytesWritten += boolerr_.Write(data);
 
 4051            bytesWritten += labelsst_.Write(data);
 
 4055            bytesWritten += mulblank_.Write(data);
 
 4059            bytesWritten += mulrk_.Write(data);
 
 4063            bytesWritten += number_.Write(data);
 
 4067            bytesWritten += rk_.Write(data);
 
 4071            bytesWritten += formula_.Write(data);
 
 4074    return bytesWritten;
 
 4081            return blank_.DataSize();
 
 4084            return boolerr_.DataSize();
 
 4087            return labelsst_.DataSize();
 
 4090            return mulblank_.DataSize();
 
 4093            return mulrk_.DataSize();
 
 4096            return number_.DataSize();
 
 4099            return rk_.DataSize();
 
 4102            return formula_.DataSize();
 
 4111            return blank_.RecordSize();
 
 4114            return boolerr_.RecordSize();
 
 4117            return labelsst_.RecordSize();
 
 4120            return mulblank_.RecordSize();
 
 4123            return mulrk_.RecordSize();
 
 4126            return number_.RecordSize();
 
 4129            return rk_.RecordSize();
 
 4132            return formula_.RecordSize();
 
 4141            return blank_.rowIndex_;
 
 4144            return boolerr_.rowIndex_;
 
 4147            return labelsst_.rowIndex_;
 
 4150            return mulblank_.rowIndex_;
 
 4153            return mulrk_.rowIndex_;
 
 4156            return number_.rowIndex_;
 
 4159            return rk_.rowIndex_;
 
 4162            return formula_.rowIndex_;
 
 4171            return blank_.colIndex_;
 
 4174            return boolerr_.colIndex_;
 
 4177            return labelsst_.colIndex_;
 
 4180            return mulblank_.firstColIndex_;
 
 4183            return mulrk_.firstColIndex_;
 
 4186            return number_.colIndex_;
 
 4189            return rk_.colIndex_;
 
 4192            return formula_.colIndex_;
 
 4206    size_t nm = (dataSize_-4) / 2;
 
 4208    offsets_.resize(nm);
 
 4209    for (
size_t i=0; i<nm; ++i)
 
 4219    size_t nm = offsets_.size();
 
 4220    for (
size_t i=0; i<nm; ++i)
 
 4230    return (recordSize_ = dataSize + 4*(dataSize/8224 + 1));
 
 4237    size_t bytesRead = 0;
 
 4248                rows_.push_back(row);
 
 4249                bytesRead += 
rows_.back().Read(data+bytesRead);
 
 4267                bytesRead += rec.
Read(data+bytesRead);
 
 4276    size_t bytesWritten = 0;
 
 4277    size_t maxRows = 
rows_.size();
 
 4278    {
for (
size_t i=0; i<maxRows; ++i)
 
 4280        bytesWritten += 
rows_[i].Write(data+bytesWritten);
 
 4284    {
for (
size_t i=0; i<maxCellBlocks; ++i)
 
 4286        bytesWritten += 
cellBlocks_[i].Write(data+bytesWritten);
 
 4290    return bytesWritten;
 
 4294    size_t dataSize = 0;
 
 4295    size_t maxRows = 
rows_.size();
 
 4310    size_t bytesRead = 0;
 
 4319        bytesRead += 
rowBlocks_.back().Read(data+bytesRead);
 
 4326    size_t bytesWritten = 0;
 
 4328    for (
size_t i=0; i<maxRowBlocks_; ++i)
 
 4330        bytesWritten += 
rowBlocks_[i].Write(data+bytesWritten);
 
 4332    return bytesWritten;
 
 4336    size_t dataSize = 0;
 
 4346    options_(1718), firstVisibleRowIndex_(0), firstVisibleColIndex_(0), gridLineColourIndex_(64),
 
 4347    unused1_(0), magnificationFactorPageBreakPreview_(0), magnificationFactorNormalView_(0), unused2_(0)
 
 4382    return (rkValue & 2);
 
 4388    return !(rkValue & 2);
 
 4396        long long intvalue_;
 
 4397        double doublevalue_;
 
 4400    bool isMultiplied = rkValue & 1;
 
 4402    intdouble.intvalue_ = rkValue;
 
 4403    intdouble.intvalue_ <<= 34;
 
 4404    if (isMultiplied) intdouble.doublevalue_ *= 0.01;
 
 4405    return intdouble.doublevalue_;
 
 4411    bool isMultiplied = rkValue & 1;
 
 4413    if (isMultiplied) rkValue *= 0.01;
 
 4422        long long intvalue_;
 
 4423        double doublevalue_;
 
 4426    bool isMultiplied = 
false;
 
 4427    int testVal1 = value;
 
 4429    int testVal2 = value * 100;
 
 4430    if (testVal1!=testVal2)
 
 4432        isMultiplied = 
true;
 
 4436    intdouble.doublevalue_ = value;
 
 4437    intdouble.intvalue_ >>= 34;
 
 4439    int rkValue = intdouble.intvalue_;
 
 4441    rkValue |= isMultiplied;
 
 4456    int testVal1 = value * 100;
 
 4458    int testVal2 = value * 10000;
 
 4459    if (testVal1!=testVal2) 
return false;
 
 4474    if (file_.IsOpen()) file_.Close();
 
 4481    worksheets_.clear();
 
 4483    workbook_.fonts_.resize(4);
 
 4484    workbook_.XFs_.resize(21);
 
 4485    workbook_.styles_.resize(6);
 
 4486    workbook_.boundSheets_.resize(1);
 
 4487    worksheets_.resize(1);
 
 4488    UpdateYExcelWorksheet();
 
 4490    for (
int i=0; i<sheets-1; ++i) AddWorksheet();
 
 4496    if (file_.IsOpen()) file_.Close();
 
 4497    if (file_.Open(filename))
 
 4500        worksheets_.clear();
 
 4503        file_.ReadFile(
"Workbook", data);
 
 4504        Read(&*(data.begin()), data.size());
 
 4505        UpdateYExcelWorksheet();
 
 4519        AdjustStreamPositions();
 
 4522        size_t minBytes = workbook_.RecordSize();
 
 4523        size_t maxWorkSheets = worksheets_.size();
 
 4524        for (
size_t i=0; i<maxWorkSheets; ++i)
 
 4526            minBytes += worksheets_[i].RecordSize();
 
 4530        vector<char> data(minBytes,0);
 
 4531        Write(&*(data).begin());
 
 4542    if (file_.IsOpen()) file_.Close();
 
 4544    if (!file_.Create(filename)) 
return false;
 
 4553    return worksheets_.size();
 
 4561    return &(yesheets_[sheetIndex]);
 
 4568    size_t maxWorksheets = yesheets_.size();
 
 4569    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4571        if (workbook_.boundSheets_[i].name_.unicode_ & 1) 
continue;
 
 4572        if (strcmp(
name, workbook_.boundSheets_[i].name_.name_) == 0) 
return &(yesheets_[i]);
 
 4581    size_t maxWorksheets = yesheets_.size();
 
 4582    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4584        if (!(workbook_.boundSheets_[i].name_.unicode_ & 1)) 
continue;
 
 4585        if (wcscmp(
name, workbook_.boundSheets_[i].name_.wname_) == 0) 
return &(yesheets_[i]);
 
 4597    size_t sheetNo = yesheets_.size() + 1;
 
 4602        sprintf(sname, 
"Sheet%d", sheetNo++);
 
 4603        yesheet = AddWorksheet(sname, sheetIndex);
 
 4614    size_t maxWorksheets = yesheets_.size();
 
 4615    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4617        if (workbook_.boundSheets_[i].name_.unicode_ & 1) 
continue;
 
 4618        if (strcmp(
name, workbook_.boundSheets_[i].name_.name_) == 0) 
return 0;
 
 4624    if (sheetIndex == -1)
 
 4629        boundSheet = &(workbook_.boundSheets_.back());
 
 4630        worksheet = &(worksheets_.back());
 
 4631        yesheet = &(yesheets_.back());
 
 4635        boundSheet = &*(workbook_.boundSheets_.insert(workbook_.boundSheets_.begin()+sheetIndex, 
Workbook::BoundSheet()));
 
 4636        worksheet = &*(worksheets_.insert(worksheets_.begin()+sheetIndex, 
Worksheet()));
 
 4637        yesheet = &*(yesheets_.insert(yesheets_.begin()+sheetIndex, 
BasicExcelWorksheet(
this, sheetIndex)));
 
 4638        size_t maxSheets = worksheets_.size();
 
 4639        for (
size_t i=sheetIndex+1; i<maxSheets; ++i)
 
 4655    size_t maxWorksheets = yesheets_.size();
 
 4656    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4658        if (!(workbook_.boundSheets_[i].name_.unicode_ & 1)) 
continue;
 
 4659        if (wcscmp(
name, workbook_.boundSheets_[i].name_.wname_) == 0) 
return 0;
 
 4665    if (sheetIndex == -1)
 
 4670        boundSheet = &(workbook_.boundSheets_.back());
 
 4671        worksheet = &(worksheets_.back());
 
 4672        yesheet = &(yesheets_.back());
 
 4676        boundSheet = &*(workbook_.boundSheets_.insert(workbook_.boundSheets_.begin()+sheetIndex, 
Workbook::BoundSheet()));
 
 4677        worksheet = &*(worksheets_.insert(worksheets_.begin()+sheetIndex, 
Worksheet()));
 
 4678        yesheet = &*(yesheets_.insert(yesheets_.begin()+sheetIndex, 
BasicExcelWorksheet(
this, sheetIndex)));
 
 4679        size_t maxSheets = worksheets_.size();
 
 4680        for (
size_t i=sheetIndex+1; i<maxSheets; ++i)
 
 4695    if (sheetIndex<workbook_.boundSheets_.size())
 
 4697        workbook_.boundSheets_.erase(workbook_.boundSheets_.begin()+sheetIndex);
 
 4698        worksheets_.erase(worksheets_.begin()+sheetIndex);
 
 4699        yesheets_.erase(yesheets_.begin()+sheetIndex);
 
 4709    size_t maxWorksheets = yesheets_.size();
 
 4710    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4712        if (workbook_.boundSheets_[i].name_.unicode_ & 1) 
continue;
 
 4713        if (strcmp(
name, workbook_.boundSheets_[i].name_.name_) == 0) 
return DeleteWorksheet(i);
 
 4722    size_t maxWorksheets = worksheets_.size();
 
 4723    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4725        if (!(workbook_.boundSheets_[i].name_.unicode_ & 1)) 
continue;
 
 4726        if (wcscmp(
name, workbook_.boundSheets_[i].name_.wname_) == 0) 
return DeleteWorksheet(i);
 
 4736    if (!(workbook_.boundSheets_[sheetIndex].name_.unicode_ & 1))
 
 4738        return workbook_.boundSheets_[sheetIndex].name_.name_;
 
 4748    if (workbook_.boundSheets_[sheetIndex].name_.unicode_ & 1)
 
 4750        return workbook_.boundSheets_[sheetIndex].name_.wname_;
 
 4760    if (!(workbook_.boundSheets_[sheetIndex].name_.unicode_ & 1))
 
 4762        strcpy(
name, workbook_.boundSheets_[sheetIndex].name_.name_);
 
 4773    if (workbook_.boundSheets_[sheetIndex].name_.unicode_ & 1)
 
 4775        wcscpy(
name, workbook_.boundSheets_[sheetIndex].name_.wname_);
 
 4786    size_t maxWorksheets = yesheets_.size();
 
 4787    if (sheetIndex < maxWorksheets)
 
 4789        for (
size_t i=0; i<maxWorksheets; ++i)
 
 4791            if (workbook_.boundSheets_[i].name_.unicode_ & 1) 
continue;
 
 4792            if (strcmp(to, workbook_.boundSheets_[i].name_.name_) == 0) 
return false;
 
 4794        workbook_.boundSheets_[sheetIndex].name_ = to;
 
 4805    size_t maxWorksheets = yesheets_.size();
 
 4806    if (sheetIndex < maxWorksheets)
 
 4808        for (
size_t i=0; i<maxWorksheets; ++i)
 
 4810            if (!(workbook_.boundSheets_[i].name_.unicode_ & 1)) 
continue;
 
 4811            if (wcscmp(to, workbook_.boundSheets_[i].name_.wname_) == 0) 
return false;
 
 4813        workbook_.boundSheets_[sheetIndex].name_ = to;
 
 4823    size_t maxWorksheets = yesheets_.size();
 
 4824    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4826        if (workbook_.boundSheets_[i].name_.unicode_ & 1) 
continue;
 
 4827        if (strcmp(from, workbook_.boundSheets_[i].name_.name_) == 0)
 
 4829            for (
size_t j=0; j<maxWorksheets; ++j)
 
 4831                if (workbook_.boundSheets_[j].name_.unicode_ & 1) 
continue;
 
 4832                if (strcmp(to, workbook_.boundSheets_[j].name_.name_) == 0) 
return false;
 
 4834            workbook_.boundSheets_[i].name_ = to;
 
 4845    size_t maxWorksheets = worksheets_.size();
 
 4846    for (
size_t i=0; i<maxWorksheets; ++i)
 
 4848        if (!(workbook_.boundSheets_[i].name_.unicode_ & 1)) 
continue;
 
 4849        if (wcscmp(from, workbook_.boundSheets_[i].name_.wname_) == 0)
 
 4851            for (
size_t j=0; j<maxWorksheets; ++j)
 
 4853                if (!(workbook_.boundSheets_[j].name_.unicode_ & 1)) 
continue;
 
 4854                if (wcscmp(to, workbook_.boundSheets_[j].name_.wname_) == 0) 
return false;
 
 4856            workbook_.boundSheets_[i].name_ = to;
 
 4865    size_t bytesRead = 0;
 
 4872        bof.
Read(data+bytesRead);
 
 4875            case WORKBOOK_GLOBALS:
 
 4876                bytesRead += workbook_.Read(data+bytesRead);
 
 4879            case VISUAL_BASIC_MODULE:
 
 4880                bytesRead += rec.
Read(data+bytesRead);
 
 4885                bytesRead += worksheets_.back().Read(data+bytesRead);
 
 4889                bytesRead += rec.
Read(data+bytesRead);
 
 4893                bytesRead += rec.
Read(data+bytesRead);
 
 4904    size_t bytesWritten = 0;
 
 4905    bytesWritten += workbook_.Write(data+bytesWritten);
 
 4907    size_t maxWorkSheets = worksheets_.size();
 
 4908    for (
size_t i=0; i<maxWorkSheets; ++i)
 
 4910        bytesWritten += worksheets_[i].Write(data+bytesWritten);
 
 4912    return bytesWritten;
 
 4918    AdjustBoundSheetBOFPositions();
 
 4919    AdjustDBCellPositions();
 
 4924    size_t offset = workbook_.RecordSize();
 
 4925    size_t maxBoundSheets = workbook_.boundSheets_.size();
 
 4926    for (
size_t i=0; i<maxBoundSheets; ++i)
 
 4928        workbook_.boundSheets_[i].BOFpos_ = offset;
 
 4929        offset += worksheets_[i].RecordSize();
 
 4935    size_t offset = workbook_.RecordSize();
 
 4936    size_t maxSheets = worksheets_.size();
 
 4937    for (
size_t i=0; i<maxSheets; ++i)
 
 4939        offset += worksheets_[i].bof_.RecordSize();
 
 4940        offset += worksheets_[i].index_.RecordSize();
 
 4941        offset += worksheets_[i].dimensions_.RecordSize();
 
 4943        size_t maxRowBlocks_ = worksheets_[i].cellTable_.rowBlocks_.size();
 
 4944        for (
size_t j=0; j<maxRowBlocks_; ++j)
 
 4946            size_t firstRowOffset = 0;
 
 4948            size_t maxRows = worksheets_[i].cellTable_.rowBlocks_[j].rows_.size();
 
 4949            {
for (
size_t k=0; k<maxRows; ++k)
 
 4951                offset += worksheets_[i].cellTable_.rowBlocks_[j].rows_[k].RecordSize();
 
 4952                firstRowOffset += worksheets_[i].cellTable_.rowBlocks_[j].rows_[k].RecordSize();
 
 4954            size_t cellOffset = firstRowOffset - 20; 
 
 4956            size_t maxCellBlocks = worksheets_[i].cellTable_.rowBlocks_[j].cellBlocks_.size();
 
 4957            {
for (
size_t k=0; k<maxCellBlocks; ++k)
 
 4959                offset += worksheets_[i].cellTable_.rowBlocks_[j].cellBlocks_[k].RecordSize();
 
 4960                firstRowOffset += worksheets_[i].cellTable_.rowBlocks_[j].cellBlocks_[k].RecordSize();
 
 4964            worksheets_[i].index_.DBCellPos_[j] = offset;
 
 4966            offset += worksheets_[i].cellTable_.rowBlocks_[j].dbcell_.RecordSize();
 
 4969            worksheets_[i].cellTable_.rowBlocks_[j].dbcell_.firstRowOffset_ = firstRowOffset;
 
 4973            {
for (
size_t k=0; k<maxRows; ++k)
 
 4975                for (; l<maxCellBlocks; ++l)
 
 4978                        worksheets_[i].cellTable_.rowBlocks_[j].cellBlocks_[l].RowIndex())
 
 4980                        worksheets_[i].cellTable_.rowBlocks_[j].dbcell_.offsets_[k] = cellOffset;
 
 4983                    cellOffset += worksheets_[i].cellTable_.rowBlocks_[j].cellBlocks_[l].RecordSize();
 
 4989        offset += worksheets_[i].cellTable_.RecordSize();
 
 4990        offset += worksheets_[i].window2_.RecordSize();
 
 4991        offset += worksheets_[i].eof_.RecordSize();
 
 4997    size_t offset = workbook_.bof_.RecordSize();
 
 4998    offset += workbook_.bof_.RecordSize();
 
 4999    offset += workbook_.window1_.RecordSize();
 
 5001    size_t maxFonts = workbook_.fonts_.size();
 
 5002    {
for (
size_t i=0; i<maxFonts; ++i) {offset += workbook_.fonts_[i].RecordSize();}}
 
 5004    size_t maxXFs = workbook_.XFs_.size();
 
 5005    {
for (
size_t i=0; i<maxXFs; ++i) {offset += workbook_.XFs_[i].RecordSize();}}
 
 5007    size_t maxStyles = workbook_.styles_.size();
 
 5008    {
for (
size_t i=0; i<maxStyles; ++i) {offset += workbook_.styles_[i].RecordSize();}}
 
 5010    size_t maxBoundSheets = workbook_.boundSheets_.size();
 
 5011    {
for (
size_t i=0; i<maxBoundSheets; ++i) {offset += workbook_.boundSheets_[i].RecordSize();}}
 
 5013    workbook_.extSST_.stringsTotal_ = 10;
 
 5014    size_t maxPortions = workbook_.sst_.uniqueStringsTotal_ / workbook_.extSST_.stringsTotal_ +
 
 5015                        (workbook_.sst_.uniqueStringsTotal_%workbook_.extSST_.stringsTotal_ ? 1 : 0);
 
 5016    workbook_.extSST_.streamPos_.resize(maxPortions);
 
 5017    workbook_.extSST_.firstStringPos_.resize(maxPortions);
 
 5018    workbook_.extSST_.unused_.resize(maxPortions);
 
 5020    size_t relativeOffset = 8;
 
 5021    for (
size_t i=0; i<maxPortions; ++i)
 
 5023        workbook_.extSST_.streamPos_[i] = offset + 4 + relativeOffset;
 
 5024        workbook_.extSST_.firstStringPos_[i] = 4 + relativeOffset;
 
 5025        workbook_.extSST_.unused_[i] = 0;
 
 5027        for (
size_t j = 0; j < (size_t)workbook_.extSST_.stringsTotal_; ++j)
 
 5029            if (i*workbook_.extSST_.stringsTotal_+j >= workbook_.sst_.strings_.size()) 
break;
 
 5030            size_t stringSize = workbook_.sst_.strings_[i*workbook_.extSST_.stringsTotal_+j].StringSize();
 
 5031            if (relativeOffset+stringSize+3 < 8224)
 
 5033                relativeOffset += stringSize + 3;
 
 5039                if (8224 - relativeOffset >= 12)
 
 5041                    stringSize -= (8224 - relativeOffset - 3);
 
 5042                    offset += 12 + relativeOffset;
 
 5045                    size_t additionalContinueRecords = stringSize / 8223; 
 
 5046                    for (
size_t k=0; k<additionalContinueRecords; ++k)
 
 5050                    relativeOffset += stringSize + 1;
 
 5054                    if (relativeOffset+stringSize+3 < 8224)
 
 5056                        relativeOffset += stringSize + 3;
 
 5062                        if (8224 - relativeOffset >= 12)
 
 5064                            stringSize -= (8224 - relativeOffset - 3);
 
 5065                            offset += 12 + relativeOffset;
 
 5068                            size_t additionalContinueRecords = stringSize / 8223; 
 
 5069                            for (
size_t k=0; k<additionalContinueRecords; ++k)
 
 5073                            relativeOffset += stringSize + 1;
 
 5085    size_t maxWorksheets = worksheets_.size();
 
 5087    yesheets_.reserve(maxWorksheets);
 
 5088    for (
size_t i=0; i<maxWorksheets; ++i)
 
 5098    const size_t maxWorksheets = yesheets_.size();
 
 5105    map<vector<char>, 
size_t> stringMap;
 
 5106    map<vector<char>, 
size_t>::iterator stringMapIt;
 
 5107    map<vector<wchar_t>, 
size_t> wstringMap;
 
 5108    map<vector<wchar_t>, 
size_t>::iterator wstringMapIt;
 
 5111    worksheets_.clear();
 
 5112    worksheets_.resize(maxWorksheets);
 
 5114    workbook_.sst_.stringsTotal_ = 0;
 
 5115    workbook_.sst_.uniqueStringsTotal_ = 0;
 
 5116    workbook_.sst_.strings_.clear();
 
 5118    for (
size_t s=0; s<maxWorksheets; ++s)
 
 5120        size_t maxRows = yesheets_[s].GetTotalRows();
 
 5121        size_t maxCols = yesheets_[s].GetTotalCols();
 
 5124        worksheets_[s].index_.firstUsedRowIndex_ = 100000;  
 
 5125        worksheets_[s].index_.firstUnusedRowIndex_ = maxRows;
 
 5128        worksheets_[s].dimensions_.firstUsedRowIndex_ = 100000; 
 
 5129        worksheets_[s].dimensions_.firstUsedColIndex_ = 1000;   
 
 5130        worksheets_[s].dimensions_.lastUsedRowIndexPlusOne_ = maxRows;
 
 5131        worksheets_[s].dimensions_.lastUsedColIndexPlusOne_ = maxCols;
 
 5134        if (s > 0) worksheets_[s].window2_.options_ &= ~0x200;
 
 5137        vector<Worksheet::CellTable::RowBlock>& rRowBlocks = worksheets_[s].cellTable_.rowBlocks_;
 
 5138        vector<Worksheet::CellTable::RowBlock::CellBlock>* pCellBlocks;
 
 5140        rRowBlocks.resize(maxRows/32 + (maxRows%32 ? 1 : 0));
 
 5141        for (
size_t r=0, curRowBlock=0; r<maxRows; ++r)
 
 5146                pCellBlocks = &(rRowBlocks[curRowBlock++].cellBlocks_);
 
 5149            pCellBlocks->reserve(1000);
 
 5150            for (
size_t c=0; c<maxCols; ++c)
 
 5153                int cellType = cell->
Type();
 
 5159                        worksheets_[s].index_.firstUsedRowIndex_ = r;
 
 5160                        worksheets_[s].dimensions_.firstUsedRowIndex_ = r;
 
 5164                        worksheets_[s].index_.DBCellPos_.resize(nm);
 
 5169                        worksheets_[s].dimensions_.firstUsedColIndex_ = c;
 
 5176                        rRowBlock.
rows_.push_back(row);
 
 5177                        rRowBlock.
rows_.back().rowIndex_ = r;
 
 5178                        rRowBlock.
rows_.back().lastCellColIndexPlusOne_ = maxCols;
 
 5184                    pCellBlocks->push_back(cellBlock);
 
 5185                    if (pCellBlocks->size()%1000==0) pCellBlocks->reserve(pCellBlocks->size()+1000);
 
 5186                    pCell = &(pCellBlocks->back());
 
 5195                            for (; cl<maxCols; ++cl)
 
 5199                                    cellNext->
Type()!=cell->
Type()) 
break;
 
 5211                                for (
size_t i=0; c<cl; ++c, ++i)
 
 5213                                    cell = yesheets_[s].Cell(r,c);
 
 5236                            for (; cl<maxCols; ++cl)
 
 5244                            if (cl > c+1 && canStoreAsRKValue)
 
 5253                                for (
size_t i=0; c<cl; ++c, ++i)
 
 5255                                    cell = yesheets_[s].Cell(r,c);
 
 5264                                if (canStoreAsRKValue)
 
 5292                            cell->
Get(&*(str.begin()));
 
 5296                            ++workbook_.sst_.stringsTotal_;
 
 5297                            size_t maxUniqueStrings = workbook_.sst_.uniqueStringsTotal_;
 
 5298                            size_t strIndex = 0;
 
 5299                            stringMapIt = stringMap.find(str);
 
 5300                            if (stringMapIt != stringMap.end()) strIndex = stringMapIt->second;
 
 5301                            else strIndex = maxUniqueStrings;
 
 5303                            if (strIndex < maxUniqueStrings)
 
 5311                                stringMap[str] = maxUniqueStrings;
 
 5312                                workbook_.sst_.strings_.push_back(largeString);
 
 5313                                workbook_.sst_.strings_[maxUniqueStrings].name_ = str;
 
 5314                                workbook_.sst_.strings_[maxUniqueStrings].unicode_ = 0;
 
 5316                                ++workbook_.sst_.uniqueStringsTotal_;
 
 5331                            cell->
Get(&*(str.begin()));
 
 5335                            ++workbook_.sst_.stringsTotal_;
 
 5336                            size_t maxUniqueStrings = workbook_.sst_.strings_.size();
 
 5337                            size_t strIndex = 0;
 
 5338                            wstringMapIt = wstringMap.find(str);
 
 5339                            if (wstringMapIt != wstringMap.end()) strIndex = wstringMapIt->second;
 
 5340                            else strIndex = maxUniqueStrings;
 
 5342                            if (strIndex < maxUniqueStrings)
 
 5350                                wstringMap[str] = maxUniqueStrings;
 
 5351                                workbook_.sst_.strings_.push_back(largeString);
 
 5352                                workbook_.sst_.strings_[maxUniqueStrings].wname_ = str;
 
 5353                                workbook_.sst_.strings_[maxUniqueStrings].unicode_ = 1;
 
 5355                                ++workbook_.sst_.uniqueStringsTotal_;
 
 5368            worksheets_[s].index_.firstUsedRowIndex_ = 0;
 
 5369            worksheets_[s].dimensions_.firstUsedRowIndex_ = 0;
 
 5373            worksheets_[s].index_.DBCellPos_.resize(nm);
 
 5378            worksheets_[s].dimensions_.firstUsedColIndex_ = 0;
 
 5386    excel_(excel), sheetIndex_(sheetIndex)
 
 5442    for (
size_t i=0; i<maxWorksheets; ++i)
 
 5457    for (
size_t i=0; i<maxWorksheets; ++i)
 
 5476            switch (cell->
Type())
 
 5486                    os << setprecision(15) << cell->
GetDouble();
 
 5491                    if (textQualifier != 
'\0')
 
 5495                        vector<char> cellString(maxLength+1);
 
 5496                        cell->
Get(&*(cellString.begin()));
 
 5499                        vector<char>::iterator it;
 
 5501                        while ((it=find(cellString.begin()+npos, cellString.end(), textQualifier)) != cellString.end())
 
 5503                            npos = distance(cellString.begin(), cellString.insert(it, textQualifier)) + 2;
 
 5507                        os << textQualifier << &*(cellString.begin()) << textQualifier;
 
 5520            if (c < 
maxCols_-1) os << delimiter;
 
 5544    if (row>65535 || col>255) 
return 0;
 
 5560    return &(
cells_[row][col]);
 
 5569        cells_[row][col].EraseContents();
 
 5582    vector<wchar_t> wstr;
 
 5589    vector<BasicExcelCell> cellCol(
maxCols_);
 
 5592    size_t maxRowBlocks = rRowBlocks.size();
 
 5593    for (
size_t i=0; i<maxRowBlocks; ++i)
 
 5595        vector<Worksheet::CellTable::RowBlock::CellBlock>& rCellBlocks = rRowBlocks[i].cellBlocks_;
 
 5596        size_t maxCells = rCellBlocks.size();
 
 5597        for (
size_t j=0; j<maxCells; ++j)
 
 5599            size_t row = rCellBlocks[j].RowIndex();
 
 5600            size_t col = rCellBlocks[j].ColIndex();
 
 5601            switch (rCellBlocks[j].type_)
 
 5607                    if (rCellBlocks[j].boolerr_.error_ == 0)
 
 5609                        cells_[row][col].Set(rCellBlocks[j].boolerr_.value_);
 
 5616                    if (ss[rCellBlocks[j].labelsst_.SSTRecordIndex_].unicode_ & 1)
 
 5618                        wstr = ss[rCellBlocks[j].labelsst_.SSTRecordIndex_].wname_;
 
 5619                        wstr.resize(wstr.size()+1);
 
 5620                        wstr.back() = L
'\0';
 
 5621                        cells_[row][col].Set(&*(wstr.begin()));
 
 5625                        str = ss[rCellBlocks[j].labelsst_.SSTRecordIndex_].name_;
 
 5626                        str.resize(str.size()+1);
 
 5628                        cells_[row][col].Set(&*(str.begin()));
 
 5638                    size_t maxCols = rCellBlocks[j].mulrk_.lastColIndex_ - rCellBlocks[j].mulrk_.firstColIndex_ + 1;
 
 5639                    for (
size_t k=0; k<maxCols; ++k, ++col)
 
 5642                        int rkValue = rCellBlocks[j].mulrk_.XFRK_[k].RKValue_;
 
 5656                    cells_[row][col].Set(rCellBlocks[j].number_.value_);
 
 5661                    int rkValue = rCellBlocks[j].rk_.value_;
 
 5716            val = (double)
ival_;
 
 5728        if (
str_.empty()) *str = 
'\0';
 
 5729        else strcpy(str, &*(
str_.begin()));
 
 5741        if (
wstr_.empty()) *str = L
'\0';
 
 5742        else wcscpy(str, &*(
wstr_.begin()));
 
 5752    else return wstr_.size() - 1;
 
 5760    if (
Get(val)) 
return val;
 
 5769    if (
Get(val)) 
return val;
 
 5777    vector<char> str(
str_.size());
 
 5778    if (!str.empty() && 
Get(&*(str.begin()))) 
return &*(
str_.begin());
 
 5786    vector<wchar_t> wstr(
wstr_.size());
 
 5787    if (!wstr.empty() && 
Get(&*(wstr.begin()))) 
return &*(
wstr_.begin());
 
 5832    size_t length = strlen(str);
 
 5836        str_ = vector<char>(length+1);
 
 5837        strcpy(&*(
str_.begin()), str);
 
 5846    size_t length = wcslen(str);
 
 5850        wstr_ = vector<wchar_t>(length+1);
 
 5851        wcscpy(&*(
wstr_.begin()), str);
 
 5870    switch (cell.
Type())
 
void SetBlockSize(size_t size)
std::ios_base::openmode mode_
bool Swap(size_t index1, size_t index2)
bool Move(size_t from, size_t to)
bool Write(size_t index, const char *block)
bool Insert(size_t index, const char *block)
bool Open(const wchar_t *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
bool Read(size_t index, char *block)
bool Create(const wchar_t *filename)
std::vector< char > filename_
unsigned char propertyType_
std::vector< PropertyTree * > children_
void IncreasePropertyReferences(PropertyTree *parentTree, size_t index)
bool Create(const wchar_t *filename)
int ReadFile(const wchar_t *path, char *data)
std::vector< int > sblocksIndices_
void DecreasePropertyReferences(PropertyTree *parentTree, size_t index)
void IncreaseLocationReferences(std::vector< size_t > indices)
void UpdateChildrenIndices(PropertyTree *parentTree)
void SplitPath(const wchar_t *path, wchar_t *&parentpath, wchar_t *&propertyname)
void DecreaseLocationReferences(std::vector< size_t > indices)
bool Open(const wchar_t *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
PropertyTree * propertyTrees_
int WriteFile(const wchar_t *path, const char *data, size_t size)
size_t WriteData(const char *data, size_t size, int startIndex, bool isBig)
int MakeFile(const wchar_t *path)
int MakeProperty(const wchar_t *path, Property *property)
int RemoveFile(const wchar_t *path)
std::vector< PropertyTree * > previousDirectories_
std::vector< Property * > properties_
std::vector< char > block_
PropertyTree * currentDirectory_
int DirectoryList(std::vector< std::vector< wchar_t > > &list, const wchar_t *path=0)
void GetBlockIndices(size_t startIndex, std::vector< size_t > &indices, bool isBig)
void InsertPropertyTree(PropertyTree *parentTree, Property *property, size_t index)
int PresentWorkingDirectory(wchar_t *path)
int RemoveDirectory(const wchar_t *path)
size_t DataSize(size_t startIndex, bool isBig)
size_t GetFreeBlockIndex(bool isBig)
size_t ReadData(size_t startIndex, char *data, bool isBig)
int ChangeDirectory(const wchar_t *path)
PropertyTree * FindProperty(size_t index)
int FileSize(const wchar_t *path, size_t &size)
void DeletePropertyTree(PropertyTree *tree)
void FreeBlocks(std::vector< size_t > &indices, bool isBig)
int DelTree(const wchar_t *path)
void LinkBlocks(size_t from, size_t to, bool isBig)
std::vector< int > blocksIndices_
void ExpandBATArray(bool isBig)
int MakeDirectory(const wchar_t *path)
double dval_
Double value stored in current Excel cell.
void SetDouble(double val)
Set content of current Excel cell to a double.
void Set(int val)
Set content of current Excel cell to an integer.
int Type() const
Get type of value stored in current Excel cell. Returns one of the above enums.
void SetInteger(int val)
Set content of current Excel cell to an integer.
bool Get(int &val) const
Get an integer value. Returns false if cell does not contain an integer or a double.
std::vector< wchar_t > wstr_
Unicode string stored in current Excel cell. Include null character.
size_t GetStringLength() const
Return length of ANSI or Unicode string (excluding null character).
std::vector< char > str_
ANSI string stored in current Excel cell. Include null character.
const char * GetString() const
Get an ANSI string. Returns 0 if cell does not contain an ANSI string.
int type_
Type of value stored in current Excel cell. Contains one of the above enums.
void EraseContents()
Erase the content of current Excel cell. Set type to UNDEFINED.
const wchar_t * GetWString() const
Get an Unicode string. Returns 0 if cell does not contain an Unicode string.
int ival_
Integer value stored in current Excel cell.
double GetDouble() const
Get a double value. Returns 0.0 if cell does not contain a double.
int GetInteger() const
Get an integer value. Returns 0 if cell does not contain an integer.
void SetString(const char *str)
Set content of current Excel cell to an ANSI string.
void SetWString(const wchar_t *str)
Set content of current Excel cell to an Unicode string.
wchar_t * GetUnicodeSheetName(size_t sheetIndex)
Get the worksheet name at the given index. Index starts from 0. Returns 0 if name is in Ansi format.
bool DeleteWorksheet(size_t sheetIndex)
Delete an Excel worksheet at the given index. Index starts from 0. Returns true if successful,...
void UpdateYExcelWorksheet()
Update yesheets_ using information from worksheets_.
void AdjustDBCellPositions()
void UpdateWorksheets()
Update worksheets_ using information from yesheets_.
void AdjustStreamPositions()
void New(int sheets=3)
Create a new Excel workbook with a given number of spreadsheets (Minimum 1).
BasicExcelWorksheet * GetWorksheet(size_t sheetIndex)
Get a pointer to an Excel worksheet at the given index. Index starts from 0. Returns 0 if index is in...
size_t Read(const char *data, size_t dataSize)
std::vector< Worksheet > worksheets_
Raw Worksheets.
size_t GetTotalWorkSheets()
Total number of Excel worksheets in current Excel workbook.
void AdjustBoundSheetBOFPositions()
bool Load(const char *filename)
Load an Excel workbook from a file.
bool GetSheetName(size_t sheetIndex, char *name)
Get the worksheet name at the given index. Index starts from 0. Returns false if name is in Unicode f...
char * GetAnsiSheetName(size_t sheetIndex)
Get the worksheet name at the given index. Index starts from 0. Returns 0 if name is in Unicode forma...
BasicExcelWorksheet * AddWorksheet(int sheetIndex=-1)
Add a new Excel worksheet to the given index. Name given to worksheet is SheetX, where X is a number ...
bool SaveAs(const char *filename)
Save current Excel workbook to a file.
void AdjustExtSSTPositions()
bool Save()
Save current Excel workbook to opened file.
Workbook workbook_
Raw Workbook.
bool RenameWorksheet(size_t sheetIndex, const char *to)
Rename an Excel worksheet at the given index to the given ANSI name. Index starts from 0....
size_t sheetIndex_
Index of worksheet in workbook.
std::vector< std::vector< BasicExcelCell > > cells_
Cells matrix.
size_t GetTotalCols()
Total number of columns in current Excel worksheet.
BasicExcelCell * Cell(size_t row, size_t col)
Return a pointer to an Excel cell. row and col starts from 0. Returns 0 if row exceeds 65535 or col e...
size_t maxRows_
Total number of rows in worksheet.
char * GetAnsiSheetName()
Get the current worksheet name. Returns 0 if name is in Unicode format.
bool Rename(const char *to)
Rename current Excel worksheet to another ANSI name. Returns true if successful, false if otherwise.
bool EraseCell(size_t row, size_t col)
Erase content of a cell. row and col starts from 0. Returns true if successful, false if row or col e...
BasicExcelWorksheet(BasicExcel *excel, size_t sheetIndex)
wchar_t * GetUnicodeSheetName()
Get the current worksheet name. Returns 0 if name is in Ansi format.
void Print(std::ostream &os, char delimiter=',', char textQualifier='\0')
Print entire worksheet to an output stream, separating each column with the defined delimiter and enc...
bool GetSheetName(char *name)
Get the current worksheet name. Returns false if name is in Unicode format.
BasicExcel * excel_
Pointer to instance of BasicExcel.
size_t maxCols_
Total number of columns in worksheet.
size_t GetTotalRows()
Total number of rows in current Excel worksheet.
void UpdateCells()
Update cells using information from BasicExcel.worksheets_.
virtual size_t DataSize()
virtual size_t Write(char *data)
virtual size_t RecordSize()
std::vector< char > data_
virtual size_t Read(const char *data)
std::vector< size_t > continueIndices_
std::vector< BoundSheet > boundSheets_
std::vector< Style > styles_
size_t Read(const char *data)
std::vector< Font > fonts_
size_t Read(const char *data)
ostream & operator<<(ostream &os, const BasicExcelCell &cell)
int GetRKValueFromDouble(double value)
Convert a double to a rk value.
int GetIntegerFromRKValue(int rkValue)
Convert a rk value to an integer.
double GetDoubleFromRKValue(int rkValue)
Convert a rk value to a double.
bool CanStoreAsRKValue(double value)
Returns true if the supplied double can be stored as a rk value.
bool IsRKValueADouble(int rkValue)
Returns true if the supplied rk value contains a double.
int GetRKValueFromInteger(int value)
Convert an integer to a rk value.
bool IsRKValueAnInteger(int rkValue)
Returns true if the supplied rk value contains an integer.
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
static void ReadString(const char *buffer, Type *str, int pos=0, int bytes=0)
static void WriteString(char *buffer, Type *str, int pos=0, int bytes=0)
static void Read(const char *buffer, Type &retVal, int pos=0, int bytes=0)
static void Write(char *buffer, Type val, int pos=0, int bytes=0)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
LargeString & operator=(const LargeString &s)
std::vector< wchar_t > wname_
size_t Read(const char *data)
std::vector< char > name_
size_t ContinueRead(const char *data, size_t size)
SmallString & operator=(const SmallString &s)
size_t Read(const char *data)
virtual size_t DataSize()
virtual size_t RecordSize()
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t DataSize()
virtual size_t RecordSize()
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t Read(const char *data)
virtual size_t RecordSize()
virtual size_t DataSize()
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
std::vector< LargeString > strings_
virtual size_t Write(char *data)
virtual size_t DataSize()
virtual size_t RecordSize()
virtual size_t DataSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t RecordSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
virtual size_t RecordSize()
virtual size_t Write(char *data)
virtual size_t DataSize()
void Read(const char *data)
virtual size_t RecordSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t DataSize()
std::vector< XFRK > XFRK_
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t DataSize()
std::vector< short > offsets_
virtual size_t RecordSize()
virtual size_t Read(const char *data)
virtual size_t Write(char *data)
virtual size_t Read(const char *data)
std::vector< CellBlock > cellBlocks_
size_t Read(const char *data)
std::vector< RowBlock > rowBlocks_
size_t Read(const char *data)
virtual size_t Write(char *data)
size_t lastUsedRowIndexPlusOne_
short lastUsedColIndexPlusOne_
virtual size_t Read(const char *data)
virtual size_t Read(const char *data)
virtual size_t DataSize()
std::vector< size_t > DBCellPos_
size_t firstUnusedRowIndex_
virtual size_t Write(char *data)
virtual size_t RecordSize()
size_t firstUsedRowIndex_
virtual size_t Read(const char *data)
virtual size_t Write(char *data)