Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » Enhancing project templates (upt files)
Re: Enhancing project templates (upt files) [FEATURE REQUEST] [message #5481 is a reply to message #5480] |
Tue, 26 September 2006 12:26   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
Werner wrote on Tue, 26 September 2006 06:17 | Thank you for adopting my suggestion.
After using "PACKAGE_UPPERCASE" for a couple of days, I'm no longer happy with the simplistic creation of its content. This was obviously an over-quick suggestion. Sorry!
As far as I can see, it is quite common - and I adhere to this quasi-standard - to capitalize mixed-uppercase-lowercase identifiers by inserting an underscore ("_") when the change from a lowercase letter to an uppercase letter indicates a new component.
That is why I wrote the following tiny function, which I suggest to include into Ultimate++, maybe into "uppsrc/ide".
I intentionally wrote it as a non-menber function of "String" (compare e. g., Stroustrup, The C++ Programming Language, Special Edition, 10.3.2; Sutter, Alexandrescu, C++ Coding Standards, 44; Meyers, Effective C++, 4.6 / 23).
String MkInclGuard(const String& name)
{
String output("");
int str_len = name.GetLength();
for (int i = 0; i < str_len; ++i)
{
int ch = name[i];
if (IsAlNum(ch))
{
output += ToUpper(ch);
if (i < str_len - 1)
if (IsLower(ch) && IsUpper(name[i + 1]))
output += '_';
}
else
output += '_';
}
return output;
}
The patched function then reads:
ArrayMap<String, EscValue> TemplateDlg::MakeVars0()
{
ArrayMap<String, EscValue> var;
String n = ~package;
int q = n.ReverseFind('/');
n = q >= 0 ? n.Mid(q + 1) : n;
var.Add("PACKAGE", n);
var.Add("PACKAGE_UPPERCASE", MkInclGuard(n));
return var;
}
Werner
|
I think we should add it to the Core, it is a nice complement to "InitCaps" sort of function.
I only do not quite like the name (because it is not necessarily related to include guards) - what about something like "ToLowerUnderscoreCaps"? 
|
|
|
 |
|
Enhancing project templates (upt files)
By: Werner on Tue, 19 September 2006 16:57
|
 |
|
Re: Enhancing project templates (upt files)
By: mirek on Tue, 19 September 2006 18:27
|
 |
|
Re: Enhancing project templates (upt files)
By: Werner on Wed, 20 September 2006 10:12
|
 |
|
Re: Enhancing project templates (upt files)
By: mirek on Wed, 20 September 2006 10:30
|
 |
|
Re: Enhancing project templates (upt files)
By: Werner on Thu, 21 September 2006 11:25
|
 |
|
Re: Enhancing project templates (upt files)
By: mirek on Thu, 21 September 2006 15:50
|
 |
|
Re: Enhancing project templates (upt files)
By: Werner on Thu, 21 September 2006 20:46
|
 |
|
Re: Enhancing project templates (upt files)
By: Werner on Sun, 03 December 2006 13:43
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: Werner on Tue, 26 September 2006 12:17
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: mirek on Tue, 26 September 2006 12:26
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: Werner on Tue, 26 September 2006 13:52
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: mirek on Tue, 26 September 2006 14:03
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: Werner on Tue, 26 September 2006 16:25
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: mirek on Tue, 26 September 2006 21:02
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: Werner on Tue, 26 September 2006 21:36
|
 |
|
Re: Enhancing project templates (upt files) [FEATURE REQUEST]
By: mirek on Tue, 26 September 2006 22:58
|
Goto Forum:
Current Time: Tue Apr 29 00:31:32 CEST 2025
Total time taken to generate the page: 0.00884 seconds
|