Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 #5480 is a reply to message #5415] Tue, 26 September 2006 12:17 Go to previous messageGo to previous message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
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

[Updated on: Tue, 26 September 2006 12:24]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Assamblies and nests
Next Topic: Ctrl Documentation Bug?
Goto Forum:
  


Current Time: Mon Jun 03 00:50:51 CEST 2024

Total time taken to generate the page: 0.02045 seconds