31 fReadMantisseR =
true;
32 fReadMantisseF =
false;
33 fReadExponentSign =
false;
34 fReadExponent =
false;
37 fExponentNegative =
false;
55 if (
InFile_Open(&inStream.file, fileName.c_str()) != 0) {
56 cout <<
"Cannot open input file: " << fileName << endl;
57 cout <<
"First use: \n\t \'lzma --best " << fileName.substr(0, fileName.rfind(
".lzma")) <<
"\'"
72 for (i = 0; i < 8; i++)
88 if (fStorage.empty()) {
89 const int ret = DecodeBuffer();
91 cout <<
"Error in ReadNextNumber ret=" << ret << endl;
96 data = fStorage.front();
106 for (
int i=0;
i<length; ++
i) {
108 if (fStorage.empty()) {
109 const int ret = DecodeBuffer();
111 cout <<
"Error in FillArray i=" <<
i <<
" ret=" << ret << endl;
116 data[
i] = fStorage.front();
166 const int thereIsSize = (unpackSize != (
UInt64)(
Int64)-1);
169 if (inPos == inSize) {
171 RINOK(stream->
Read(stream, inBuf, &inSize));
175 SizeT inProcessed = inSize - inPos;
180 if (thereIsSize && outProcessed > unpackSize) {
181 outProcessed = (
SizeT)unpackSize;
186 inBuf + inPos, &inProcessed, finishMode, &status);
187 inPos += inProcessed;
188 unpackSize -= outProcessed;
191 const char* strBuf = (
const char*)outBuf;
197 if (countC >=
int(outProcessed)) {
204 const char&
C = strBuf[countC];
209 if (C==
' ' || C==
'\n') {
218 const double number = (fNegative?-1:1) * (fMantisseR + fMantisseF/
pow(10, fMantisseFcount)) *
pow(10, (fExponentNegative?-1:1) * fExponent);
221 fStorage.push(number);
224 fStartNumber =
false;
227 fReadMantisseR =
true;
228 fReadMantisseF =
false;
229 fReadExponentSign =
false;
230 fReadExponent =
false;
233 fExponentNegative =
false;
244 const int num = C -
'0';
245 if (num >= 0 && num <= 9) {
247 if (fReadMantisseR) {
249 fMantisseR = fMantisseR*10 +
num;
250 }
else if (fReadMantisseF) {
252 fMantisseF = fMantisseF*10 +
num;
254 }
else if (fReadExponent) {
255 fReadExponentSign =
false;
256 fExponent = fExponent*10 +
num;
267 fReadMantisseR =
true;
268 }
else if (fReadExponentSign) {
269 fExponentNegative =
true;
270 fReadExponentSign =
false;
271 fReadExponent =
true;
273 cout <<
"LzmaFile: found \'" << C <<
"\' at wrong position. " << endl;
279 if (!fReadMantisseR) {
280 cout <<
"LzmaFile: found \'" << C <<
"\' at wrong position. " << endl;
283 fReadMantisseR =
false;
284 fReadMantisseF =
true;
290 if (!fReadMantisseR || !fReadMantisseF) {
291 fReadMantisseR =
false;
292 fReadMantisseF =
false;
293 fReadExponentSign =
true;
294 fReadExponent =
true;
298 cout <<
"LzmaFile: found \'" << C <<
"\' at wrong position. " << endl;
323 if (res !=
SZ_OK || (thereIsSize && unpackSize == 0))
326 if (inProcessed == 0 && outProcessed == 0) {
343 int thereIsSize = (unpackSize != (
UInt64)(
Int64)-1);
347 if (inPos == inSize) {
349 RINOK(stream->
Read(stream, inBuf, &inSize));
353 SizeT inProcessed = inSize - inPos;
358 if (thereIsSize && outProcessed > unpackSize) {
359 outProcessed = (
SizeT)unpackSize;
364 inBuf + inPos, &inProcessed, finishMode, &status);
365 inPos += inProcessed;
366 unpackSize -= outProcessed;
370 for (k=0; k<outProcessed; ++
k) {
371 printf(
"%c", outBuf[k]);
374 if (res !=
SZ_OK || (thereIsSize && unpackSize == 0))
377 if (inProcessed == 0 && outProcessed == 0) {
unsigned long long int UInt64
void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
void * MyAlloc(size_t size)
void MyFree(void *address)
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size)
SRes ReadNextNumber(double &data)
void File_Construct(CSzFile *p)
const char * kDataErrorMessage
const char * kCantReadMessage
const char * kCantWriteMessage
SRes FillArray(double *data, const int length)
const char * kCantAllocateMessage
#define LzmaDec_Construct(p)
WRes File_Close(CSzFile *p)
static void SzFree(void *p, void *address)
char data[epos_bytes_allocation]
void FileSeqInStream_CreateVTable(CFileSeqInStream *p)
static void * SzAlloc(void *p, size_t size)
void LzmaDec_Init(CLzmaDec *p)
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
SRes Open(const std::string &fileName)
SRes(* Read)(void *p, void *buf, size_t *size)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
WRes InFile_Open(CSzFile *p, const char *name)