几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】getting contents from oddbmte (http://www.dimcax.com/hust/showthread.php?t=16405)

yang686526 2009-05-05 11:27 AM

【转帖】getting contents from oddbmte
 
getting contents from oddbmtext
getting contents from oddbmtext
hi,
i am looking for functions to get each line of text from oddbmtext.contents(). i wrote some logic to do this. but it doesn't work properly. my code is as follows:
.........
strcpy(contents, pmtext->contents());
char *token = strtok(contents, pmtext->linebreak());
while( token != null )
{
strcpy(set.content, token);
sets.push_back(set);
// go to next line of text
token = strtok( null, pmtext->linebreak());
}
...
i can see the pmtext->contents() seems like "aaa\pbbb\bccc", and pmtext->linebreak() seems like "\p". but the tokens returning are "aaa", "pbbb", "bccc".
but if i do this as follows, it works.
.........
strcpy(contents, "aaa\pbbb\bccc");
char *token = strtok(contents, "\p");
while( token != null )
{
strcpy(set.content, token);
sets.push_back(set);
// go to next line of text
token = strtok( null, "\p");
}
...
so i guess the return values of pmtext->contents() and pmtext->linebreak() are not what they look like.
is there a way to get these line of text from the lib?
thanks..
the character '\' starts escape sequence in c++ code. pmtext->linebreak() returns string with two characters '\' and 'p' or in other words in c++ code it will be string "\\p". the mtext string contains same two characters.(for example: it is "aaa\\pbbb" in c++ code). try use strstr() function. note paragraphbreak()("\\p") is line break also.
--
best regards,
sergey zaitcev
it works. thanks for the help.
maybe it's easier to use oddbmtext::explodefragments() instead of parsing the contents manualy?
sergey slezkin


所有的时间均为北京时间。 现在的时间是 11:07 AM.