一次加载多个字符串? [英] Load Multiple Strings at once?

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

问题描述

您好,我想知道一次从资源中加载多个字符串会是个好主意吗?我正在考虑使用STL std :: map< int,std :: string>可以容纳所有多个字符串并使用宏快速查找字符串,因此不必总是调用LoadString.

初始化函数将在启动时被调用以处理所有字符串

Hello i am wondering would it be a good idea to load multiple strings from a resource at once. I was thinking of using STL std::map<int,std::string> to hold all the multiple strings and use a macro to find the string on the fly so it doesn''t have to always call LoadString.

The Initializing function would be called on start-up to process all the strings

推荐答案

您*可以*创建一个字符串字典集合,并在加载它们时放入将资源ID和字符串加载到此字典中,然后再加载它们,然后编写一种方法,该方法将首先检查字典(通过键(即资源ID,还是按字符串))以查看是否已检索到该字符串,如果不是,从资源文件中获取它,并下次将其存储在字典中.
You *could* create a dictionary collection of strings, and as you load them, put the resource ID and the string into this dictionary as you load them, and then write a method that would first check the dictionary (by key aka the resource ID, or by string) to see if the string is already retrieved, and if not, get it from the resource file and store it in the dictionary for the next time.


我想多次调用LoadString不会降低性能(如果性能与您有关) .
:)
I suppose there is no performance penalty in calling LoadString multiple times (if is performance that concerns you).
:)


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

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