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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 09:12 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】odstringgetlength90 question

odstring::getlength() question
odstring::getlength() question
i just tracked down a bug in my mtext processing that was caused by an incorrect return value from getlength(). specifically the sp_mtx->contents().getlength() value seems to be one high (in other words it includes the trailing null). ("sp_mtx" is a smart pointer to an oddbmtext object.)
i fixed it by using strlen(sp_mtx->contents().c_str()) instead.
could this be a bug in your code? i can't imagine that no one would have noticed by now...
thanks,
-jimc
quote:
originally posted by exeye
could this be a bug in your code? i can't imagine that no one would have noticed by now...
-jimc
i have noticed the behavior too. i think length refers to buffer length and not string length. whatever it is, i believe, it is a feature not a bug.
- jaydutt shuklafff">
quote:
originally posted by jaydutt
i have noticed the behavior too. i think length refers to buffer length and not string length. whatever it is, i believe, it is a feature not a bug.
the reasons that i think this should be considered a bug are:
1. the documentation says that the function "returns the number of characters in this string".
2. all string length functions i know of return the length without the null terminating byte.
at the very least the documentation should make this peculiar behavior very clear.
-jimc
odstring stores data length and returns it from getlength().
example:
code:
odstring str;
str = "a";
int len = str.getlength(); // len = 1
str = "a\0";
len = str.getlength(); // len = 1 (because strlen is used to calculate const string length
str += '\0';
len = str.getlength(); // len = 2 - character is appended
how mtext with contents having extra length (together with null terminator) was created?
sergey slezkin
i am using a drawing created by a client, using autocad 2000 i think. i can send it privately if you want (give me an email address) but don't want to post it publicly as it is not mine.
the code used to read it is:
// get pointer to mtext entity
oddbmtextptr sp_mtx = id_ent.safeopenobject();
// get text
str_txt = sp_mtx->contents();
nchmtx = strlen(str_txt.c_str());
originally i was using:
nchmtx = str_txt.getlength();
in place of the last line. when i traced the results of the two lines they were different.
if i can give you any more info, please ask. sorry for the unconventional coding style; i like short variable names.
-jimc
my e-mail is sslezkin_at_softdev_dot_spb_dot_ru
it would be interesting to look at the file showing this problem (minimized version with single mtext entity would be enough if you do not want to share client's file)
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】oddbleader question yang686526 DirectDWG 0 2009-05-06 07:51 PM
【转帖】oddbbackground question yang686526 DirectDWG 0 2009-05-06 07:25 PM
【转帖】autodesk, odx and arxdbx question yang686526 DirectDWG 0 2009-05-04 04:32 PM
【转帖】acis question yang686526 DirectDWG 0 2009-05-04 03:38 PM
【转帖】assembly drawing bom change question yang686526 American standards 0 2009-04-29 06:31 PM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多