[fityk-devel] code with a new implementation of VAMAS format reading has been completed

5 views
Skip to first unread message

张鹏

unread,
Jul 13, 2007, 2:27:15 AM7/13/07
to Marcin Wojdyr, fityk-dev ML
Hi,

The code with a new implementation of VAMAS format reading has been completed, and now has been checked into the SF repository.

To Marcin:
I think I find a way to implement "ungetline()" to put the line got by "getline()" back to the stream:
before every getline() call, invoke "tellg()" to get current reading position and store it to some place; then if you want to get that line back, call "seekg(pos)" to set current reading position to the old one.

So I'd prefer to leave Rigaku::load_data() empty. Now I will try to add some more formats. If more UXD-like formats found, I think it's not a bad idea to complete the DataSet::parse_fixedstep_file().

And looking forward to you comments on the committed code.

Thanks,

--
Regards,

Peng ZHANG (张鹏)

Marcin Wojdyr

unread,
Jul 14, 2007, 3:01:46 PM7/14/07
to 张鹏, fityk-dev ML
On 7/13/07, 张鹏 <zhangp...@gmail.com> wrote:
> I think I find a way to implement "ungetline()" to put the line got by
> "getline()" back to the stream:
> before every getline() call, invoke "tellg()" to get current reading
> position and store it to some place; then if you want to get that line back,
> call "seekg(pos)" to set current reading position to the old one.

AFAIK the problem with "seek" is that it can't be used with some
streams, e.g. with stdin.

> So I'd prefer to leave Rigaku::load_data() empty. Now I will try to add some
> more formats. If more UXD-like formats found, I think it's
> not a bad idea to complete the
> DataSet::parse_fixedstep_file().

OK

>
> And looking forward to you comments on the committed code.

Makefile:
"chmod a+x testmain" in makefile is not necessary
usually CXX variable is used for C++ compiler, not XX

testmain.h:
* almost all function declared there are not implemented anywhere.
IMHO you can delete this file

testmain.cpp:
* "if (0 == strncmp("-i", argv[i], 2))"
most of people would put 0 on the right side. There is nothing wrong
about it, although it doesn't look natural, at least for me. I know
some books recommend "5 == foo", to prevent a typo "5 = foo", but
nowadays, in most of cases, compiler warns about such typos (i.e.
about
"if (foo = 5)").
* am I missing something, or the program, called without "-a" option,
doesn't do anything?
Anyway, it would be good to have a converting tool separated from
the rest of your test program, with option to dump also meta-data
(e.g. as #comments).
* "catch (const runtime_error e) {" -> "&e"


xylib.h,cpp:
* put declarations (and definitions) of functions that are to be used
only internally in a separate file. Together with a few functions
defined in common.h.
* i think that strtod and strtol are better (faster and usually easier
to use) than using istringstream.

other files:
I removed some not necessary 'using' statements.
I'd rather not use ds_ prefixes for files, because almost all files
will contain datasets, so there is not much information in the prefix.

Vamas file looks good.

You will get positive midterm evaluation. I'll fill the survey soon.

What next formats are you going to implement?

Marcin

--
Marcin Wojdyr | http://www.unipress.waw.pl/~wojdyr/

张鹏

unread,
Jul 15, 2007, 3:04:39 AM7/15/07
to Marcin Wojdyr, fityk-dev ML
Hi, Marcin:

On 7/15/07, Marcin Wojdyr <woj...@gmail.com> wrote:
AFAIK the problem with "seek" is that it can't be used with some
streams, e.g. with stdin.

yes, it cannot be used in stdin. But we are not going to handle any input from stdin; we always deal with the ifstream. 

Makefile:
  "chmod a+x testmain" in makefile is not necessary

Usually, this is not done in makefile, right? OK, I will remove this line from Makefile, and do it manually after make.
 

  usually CXX variable is used for C++ compiler, not XX

Done,  changed to CXX.

testmain.h:
*  almost all function declared there are not implemented anywhere.
IMHO you can delete this file
is it needed to test all of the sample files in the "./test" dir like what I did in the old version? I just removed them from the old version where I did implement them.
 

testmain.cpp:
*  "if (0 == strncmp("-i", argv[i], 2))"
  most of people would put 0 on the right side. There is nothing wrong
about it, although it doesn't look natural, at least for me.  I know
some books recommend "5 == foo", to prevent a typo "5 = foo", but
nowadays, in most of cases, compiler warns about such typos (i.e.
about
"if (foo = 5)").

I think this is not a big problem. I'd like to keep this manner to let the 
compiler to comlain with an error, rather than just a warning.

* am I missing something, or the program, called without "-a" option,
doesn't do anything?

yes, it does nothing if it is called without "-a".  This is because I removed the
test_xxx_file() functions from testmain.cpp to see a quick result. 

  Anyway, it would be good to have a converting tool separated from
the rest of your test program, with option to dump also meta-data
(e.g. as #comments).

yes, this will be added soon, like it was in the former code.

* "catch (const runtime_error e) {" -> "&e"

changed to &e. 

xylib.h,cpp:
* put declarations (and definitions) of functions that are to be used
only internally in a separate file. Together with a few functions
defined in common.h.

 You mean all the functions  in xylib::util? Do you mean I should put their declarations and definations into " common.h"? Is it appropriate to put the function definations into a header file? Or I can put them into 2 new files: util.h and util.cpp

* i think that strtod and strtol are better (faster and usually easier
to use) than using istringstream.

 changed to use strtoX functions.

other files:
I removed some not necessary 'using' statements.

fine.
 

I'd rather not use ds_ prefixes for files, because almost all files
will contain datasets, so there is not much information in the prefix.

I think this does not matter. This prefix can help us to separate the XXXDataSet 
classes  with other files, e.g. xylib.cpp/h testmain.cpp/h etc.

about fp typedef.
Are you sure that we will never need a "long double"?
If so, I will change all of them back to "double".

What next formats are you going to implement?
I am going to implement the Philipse udf format. And I found that this is also a UXD-like format. Here is a sample:

//////////////////////////////////////////////////////
SampleIdent,Sample2 ,/
Title1,Dat2rit program ,/
Title2,Sample2 ,/
DiffrType,PW3710,/
DiffrNumber,1,/
Anode, Cu,/
LabdaAlpha1, 1.54060,/
LabdaAlpha2, 1.54439,/
RatioAlpha21, 0.50000,/
DivergenceSlit,Fixed,1,/
ReceivingSlit,0.1,/
MonochromatorUsed,NO ,/
GeneratorVoltage, 40,/
TubeCurrent, 20,/
FileDateTime,21-janv-2002 09:16:36,/
DataAngleRange, 5.0000, 40.0000,/
ScanStepSize, 0.040,/
ScanType,STEP,/
ScanStepTime, 5.00,/
RawScan
665, 632, 637, 624, 677, 640, 600, 622
591, 590, 575, 530, 624, 559, 534, 555
......
//////////////////////////////////////////////////////

So I will finish the parse_fixedstep_file function and apply it to all of the UXD-like formats.

 

Marcin Wojdyr

unread,
Jul 15, 2007, 4:41:27 AM7/15/07
to 张鹏, fityk-dev ML
On 7/15/07, 张鹏 <zhangp...@gmail.com> wrote:
> > AFAIK the problem with "seek" is that it can't be used with some
> > streams, e.g. with stdin.
>
> yes, it cannot be used in stdin. But we are not going to handle any input
> from stdin; we always deal with the ifstream.

With minor modifications, any seekable stream can be used. If one
would like to use a non-seekable stream (e.g. to take input from pipe,
or to decompress file on-the-fly, he has to either make a seekable
stream first, or remove all seek's.

> > Makefile:
> > "chmod a+x testmain" in makefile is not necessary
>
> Usually, this is not done in makefile, right? OK, I will remove this line
> from Makefile, and do it manually after make.

You don't have to do it at all, because the file should be +x without chmod.

> > testmain.h:
> > * almost all function declared there are not implemented anywhere.
> > IMHO you can delete this file
> is it needed to test all of the sample files in the "./test" dir like what I
> did in the old version? I just removed them from the old version where I did
> implement them.

It's up to you how you test it. I'd make a program that can convert
any supported file to a plain ascii file.

> > xylib.h,cpp:
> > * put declarations (and definitions) of functions that are to be used
> > only internally in a separate file. Together with a few functions
> > defined in common.h.
>
> You mean all the functions in xylib::util? Do you mean I should put their
> declarations and definations into " common.h"? Is it appropriate to put the
> function definations into a header file? Or I can put them into 2 new files:
> util.h and util.cpp

Yes, I was thinking about .h and .cpp files.

> > I'd rather not use ds_ prefixes for files, because almost all files
> > will contain datasets, so there is not much information in the prefix.
>
> I think this does not matter. This prefix can help us
> to separate the XXXDataSet
> classes with other files, e.g. xylib.cpp/h testmain.cpp/h etc.

ok

> Are you sure that we will never need a "long double"?
> If so, I will change all of them back to "double".

I'm pretty sure, I've never met this kind of data stored with a
precision greater than double.

> > What next formats are you going to implement?
> I am going to implement the Philipse udf format. And I found that this is
> also a UXD-like format. Here is a sample:

[...]


> So I will finish the parse_fixedstep_file function and apply it to all of
> the UXD-like formats.

Could you write, what arguments will this function take, and how it
will be called in these three cases? (i.e. parse_fixedstep_file(",",
.....) for file type X, etc.)

Reply all
Reply to author
Forward
0 new messages