TitleCase In Visual C++ - visual-c++

I'm currently trying to find an easy way to convert a Visual (Managed) C++ string to title case.
In VB.NET, you can use either:
StrConv(sampleString, vbProperCase)
or
sampleString = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(sampleString)
In C# you use:
sampleString = System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(sampleString)
How do I do it in Visual C++? Is it something similar that I just can't seem to find?

Check the documentation on TextInfo.ToTitleCase it has examples for Managed C++

If you're talking about managed C++, you can use the same functions as in C#/VB.Net.
If you mean native C++, then:
Pretty certain there's nothing of the sort in the language itself.
AFAIK not in the Win32 API as well.
Your best hope then is to find such a function in some library (I personally can't think of one).

Related

What does access$ mean in an android studio project?

I really do not understand that, I'm a beginner in programming.
For example:
StartActivity.access$202(StartActivity.this, 0);
or
StartActivity.a|ccess$402(StartActivity.this, true ^ StartActivity.this.gl_bShowConfig);
The $ character is used in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.
See Java specs: https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8

Strange CLR compilation

So I'm doing this DirectX 11 project and had to use ...array<T>^ arr from the System header and I had to switch my Common Language RunTime Support settings to /clr. After fiddling with the other setting to get the project to compile I seem to have messed something up ,because now I cant use breakpoints and all the objects I have seem to not exist I dont know how else to put it. Please help.
Unless you need to work with .NET types, I'd recommend not using /CLR. Instead of using array<T>^, you can just use std::vector<T> and eliminate the dependency on the common language runtime.

Solution for missing std::wstring support in Android NDK?

I have a game which uses std::wstring as its basic string type in thousand of places as well as doing operations with wchar_t and its functions: wcsicmp() wcslen() vsprintf(), etc.
The problem is wstring is not supported in R5c (latest ndk at the time of this writting).
I can't change the code to use std::string because of internationalization and I would be breaking the game engine which is used by many games ...
Which options do I have?
1 - Replace string and wstring with my own string classes
This would give me better platform independency, but it is ridiculous to reimplement the wheel.
I've already started with a COW implementation of strings. I need it to be COW because I use them as keys in hash_maps.
This is of course lots of work and error prone ... but it seems it is something I can do.
2 - Try to fix the NDK recompiling the STLPort with my own implementations of the wide char string functions of the C standart library (wcslen, mbstowcs ... )
This would be the preferable way ... but I have no idea how to do it :(
How do I replace a function (lets say wcslen) in the libstdc++.a or libstlport_static.a? (not sure where they are :()
And as well I'm not sure which functions I need to reimplement, I know wcslen is not working so I guess they should be all ...
3 - Do you have any other idea?
I can't wait for an official fix for this and I will have to go with option #1 if I can't realize how to do #2.
I've read somewhere that if you target 2.3 you can use wstrings, but I ought to target Android 2.1.
PS: Forgot to say I need to use STL of course, but no RTTI and I can live without exceptions.
Thanks in advance!
Try out CrystaX's NDK. It has had stl support long before the official google one. The current version (r5), which is based off the of the official ndk r5, is still beta 3, but it does have wchar_t support.
http://www.crystax.net/android/ndk-r5.php
I'm suffering from the same problem as you, but my only other thought is to load the strings via the JNI (as jstring* in native land), then convert them to UTF characters as necessary. Take a look at the available JNI string functions here:
http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html#string_operations
Qt provides an excellent copy-on-write, international-friendly string implementation, QString, that is LGPLed.
You could, in theory extract it from the Qt source and use it in your own project. You will find the QString implementation in src/corelib/tools/qstring.h and .cpp in a Qt source download. You would also need the QChar, QByteArray, QAtomic, and QNamespace includes/classes (all under the corelib folder,) and you should define QT_NO_STL_WCHAR when compiling. (For this I would compile by hand or using my own script/Makefile.) Not simple, but once you get it up and running your life will be a lot simpler. It's better than reinventing the wheel, because it comes with loads of convenience functions and features.
Rather than stripping out just QString, you could also just use the QtCore module as a whole. See the android-lighthouse project for a Qt port to Android. (Also, it might be better to get your sources from there than from the above "vanilla" link, regardless of what you do.)

C++/CLI : Why can't I pass Strings by reference?

Why doesn't Microsoft's C++/CLI allow me to pass strings by reference? I received the following error:
C3699: '&': cannot use this indirection on type 'System::String'
First of all, there are really two Microsoft-specific C++ dialects for .NET: the older "Managed C++" (Visual Studio 2002 and 2003) and C++/CLI (Visual Studio 2005 and later).
In C++/CLI, System::String^ is a .NET reference to a string; some authors call this a "tracking pointer" to compare and contrast it with a normal C++ pointer. As in C++, you can pass .NET references "by reference", but instead of using &, you use %, as in:
void makeStr(System::String^ %result) {
result = gcnew System::String("abc");
}
Sounds like you are using Managed C++, which is a bastardised C++ used with the .NET Framework.
in Managed C++, I believe the syntax you are looking for is System::String^. The reason for this is that since managed types are garbage collected by .NET Framework, you aren't allowed to create 'regular' references since the GC needs to track all the references to a specific variable to know when it is safe to free it.
It looks like you are using Managed C++. You should use System::String^ instead.

VC++ #import directive for GCC/G++

I'm trying to test out a library that provides a VC++ example; however, I use gcc/g++ for all of my projects.
Well, the way the VC++ example accesses the library is it uses the #import directive, passing the location of the library DLL, then it does a using namespace LIBRARYNAME, and then it's able to create some undefined type (I'd assume it's defined in the DLL) and create a new instance of it with __uuidof. From then on, to call one of the library functions the example just does a createdObj->foo() and that's that.
Well... g++'s #import is different from VC++'s import (see here), so this example won't work for me.
Is there any way this can be converted to compile under g++, or am I SOL until the library developer provides me with a static library I can try out?
If you are using cygwin, then this page: http://www.cygwin.com/cygwin-ug-net/dll.html will provide you with all the help you need.
If you are using mingw, you can accomplish the same thing, but you probably won't have grep and sed, so you'll have to use some other method of doing the filtering to get your .def file.
If you were using #import in VC++ it means the DLL isn't a regular DLL, it's a COM DLL.
Since gcc doesn't have COM support, you'll just have to wait for the library author to write a non-COM version.
Maybe it could have helped you to use the OLEViewer and "View type information" to extract the basics of the IDL. Or maybe you could just use the VC++ generated .tlh and .tli files and import them into your G++ project.
I guess this answer is way too late, but right now I'm encountering similar issues myself so I just got into this thread. Hope you found the solution on time.
Regards.

Resources