类字符串 [英] class string

查看:75
本文介绍了类字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我要为我的操作系统实现一个新的字符串类,你有什么想法来增强标准的c ++字符串类吗?

如果比较c ++字符串类与CS ++ CString类和java字符串

类,你有什么看法?

感谢
来自Peter的
(cm****@hotmail.com)

Hi
I am going to implement a new string class for my os, do you have
any idea to enhance of standard c++ string class?
If compare c++ string class with CS++ CString class and java String
class, what is your opinion?
thanks
from Peter (cm****@hotmail.com)

推荐答案


cm **** @ hotmail.com 写道:

我要为我的操作系统实现一个新的字符串类,你有什么想法来增强标准的c ++字符串类吗?
如果比较c ++字符串类和CS ++ CString类以及java String
类,你有什么看法?
谢谢你彼得(cm **** @ hotmail.com)
Hi
I am going to implement a new string class for my os, do you have
any idea to enhance of standard c++ string class?
If compare c++ string class with CS++ CString class and java String
class, what is your opinion?
thanks
from Peter (cm****@hotmail.com)




我们不需要另一个字符串类!使用标准字符串类。

我厌倦了必须在CString之间转换的所有废话,

wxString,qtString,std :: string,char *,等等。

std :: string。如果你想添加功能,可以在头文件中放置独立的

函数并包含它。



we don''t need yet another string class! Use the standard string class.
I''m tired of all the bullshit of having to convert among CString,
wxString, qtString, std::string, char*, etc. Just stick with
std::string. If you want to add functionality, put free-standing
functions in a header file and include that.


" Alipha" ; <人***** @ hotmail.com>在消息中写道

news:11 ********************* @ o13g2000cwo.googlegro ups.com ...
"Alipha" <al*****@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...

cm****@hotmail.com 写道:
嗨<我将为我的操作系统实现一个新的字符串类,你有什么想法来增强标准的c ++字符串类吗?
如果比较c ++字符串类与CS ++ CString类和java String <你有什么看法?
感谢彼得(cm **** @ hotmail.com)
Hi
I am going to implement a new string class for my os, do you have
any idea to enhance of standard c++ string class?
If compare c++ string class with CS++ CString class and java String
class, what is your opinion?
thanks
from Peter (cm****@hotmail.com)



我们不需要又一个字符串类!使用标准字符串类。
我厌倦了必须在CString,
wxString,qtString,std :: string,char *等之间进行转换的所有废话。只需坚持使用
std :: string。如果你想添加功能,把独立的
函数放在头文件中并包含它。



we don''t need yet another string class! Use the standard string class.
I''m tired of all the bullshit of having to convert among CString,
wxString, qtString, std::string, char*, etc. Just stick with
std::string. If you want to add functionality, put free-standing
functions in a header file and include that.




难道Unicode文本不需要特殊的字符串处理功能? :)那将是

另一堂课。


Alex



Shouldn''t Unicode text need special string handling functions? :) That''ll be
another class.

Alex


< cm * ***@hotmail.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...
<cm****@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
我要为我的操作系统实现一个新的字符串类,你有什么想法来增强标准的c ++字符串类吗?
如果将c ++字符串类与CS ++ CString类和java字符串进行比较
课程,您有什么看法?
感谢
I am going to implement a new string class for my os, do you have
any idea to enhance of standard c++ string class?
If compare c++ string class with CS++ CString class and java String
class, what is your opinion?
thanks



与Alipha相同的建议:最好只使用std :: string

(假设你的操作系统存在完整的C ++工具链。)

如果你有理由不这样做,请在这里讨论。

字符串结束了 - 搜索主题。由C ++标准定义的字符串类

只有两个弱点IMO,

它们可能不是你想的那样:


1)std :: string有太多的成员函数

函数/转换的数量没有结束一个

可能想要应用于std: :串。处理

的正确方法是仅执行基本操作

作为成员函数,其余所有作为免费函数。

大多数C ++专家都认为,作为std :: string的成员,已经包含了太多的内容。

(是的,其他字符串类已经做得更糟.. 。)


2)可能有一个不可变字符串的位置

如果std :: string实例的字符不是

可修改(如Java中的情况),可以应用一些优化

。一些图书馆作者质疑

是否只有一个不可变的字符串,或者std :: const_string

和std :: string都比现在的情况要好。

hth -Ivan

-
http://ivan.vecerina.com/contact/?subject=NG_POST < - 电子邮件联系表格


Same advice as Alipha: best is to just use std::string
(assuming a complete C++ toolchain exists for "your os").
If you see a reason not to do so, please discuss it here.
Strings are an over-researched topic. The string class
defined by the C++ Standard only has two weaknesses IMO,
and they probably aren''t what you would think:

1) std::string has too many member functions
There is no end to the number of functions/transforms one
may want to apply to std::string. The right way to deal
with the situation is to implement only essential operations
as member functions, and all the rest as ''free'' functions.
Most C++ experts agree that too much has already been
included as members of std::string.
(yes, other string classes have done worse...)

2) there could be a place for a non-mutable string
If the characters of an std::string instance were not
modifiable (as is the case in Java), some optimizations
could be applied. Some library writers question whether
having only a non-mutable string, or both std::const_string
and std::string, would be better that the current situation.
hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form


这篇关于类字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆