Is it possible to enable / import one function from a library in C ++

I need to use the case-insensitive string comparison function without tc20 in the BOOST library.

I am using #include <boost/algorithm/string.hpp> for import.

Is there any way to import the iequals function myself?

The reason I don't care (I'm really curious.) Is that the compiled DLL is about 230 KB if I don't #include and about 1.1 MB if I do. In this particular case, it doesn't really matter how big the file is, but it looks like there are many things that are imported and never used. What if the library was several GB and I needed only one of the functions? I believe that this will become a problem.

I am admittedly naive when it comes to any related cpp links, but I feel that it is not very efficient to include about 750 KB of code when probably 90% of it is not used. It may be that the iequals function uses all of these iequals , I have no idea.

Again, if the iequals function includes many of the same libraries, the file will still be as large.

Thoughts?

Thanks in advance for any advice.

EDIT:

Thanks for answers. I do my best to understand them.

I am a chemical engineer who rewrites a bunch of terribly slow and poorly optimized VBA macros in a C ++ DLL. So far, the results have been outstanding, and everything is working correctly. I just don't see the need for an extra file size if I need to do only one type of comparison between two lines.

An example of the comparison I need to do is the following:

 if (SomeBSTR == "SomeTextHere") { // do stuff } 

or more precisely:

 if (Gas == "Methane" or Gas == "CH4" or Gas == "C1") return 1; if (Gas == "Ethane" or Gas == "C2H6" or Gas == "C2") return 2; 

If this is ONLY the type of comparison I have to do, can I do it in a simpler way than:

 int wStrCmp(const BSTR Str1, const wstring Str2) { wstring wStr1(Str1, SysStringLen(Str1)); return boost::iequals(Str1, Str2); } 

which is called through:

 if (wStrCmp(Gas, L"Methane") or wStrCmp(Gas, L"CH4") or wStrCmp(Gas, L"C1")) return 1; 

These last 2 blocks are almost inserted from my code.

Thanks again guys.

+6
source share
1 answer

Believe me, you have already enabled boost::algorithm::iequals , but use boost::range and std::locale so that you might not use them elsewhere in your code, so this will make your code a lot bigger, so I I assume that in your case there is no other way to do this if you are not using some non-standard function, for example stricmp or strcasecmp .

If you want to compare wide strings in Windows (e.g. BSTR ), you can use _wcsicmp from CRT or lstrcmpiW from the Windows runtime (declared in Kernel32.lib , you may already be associated with it).

+2
source

All Articles