User forums > Help

template implementation

(1/2) > >>

Freem:
Usually, it is possible to use F11 key to switch between headers and source files.

For templates files, it is not possible, as they don't have true implementation file (ie: no cpp file) but it is common to use a tpp (or whatever else) file to avoid spamming the header file.

The problem is that, by default, C::B do not recognize those files as CPP ones.
It disable the F11 key and find implementation/declarations.

Is it possible to force CB to recognize tpp files as cpp for templates? And if yes, how? (I am currently working on a library using nearly only templates... so it is a bit annoying)

[edit]
removed the dumb assertion about color syntax. Just have to add it in the maskfile list, in general editor options.
But maybe it could be added by default?
[/edit]

Alpha:
I am not sure about the rest, but for highlighting, you could add *.tpp to the filemasks for C/C++ under the syntax highlighting configuration.

Edit: I guess you just noticed that as well.

Freem:
that's true, thanks anyway :)

But there is still the rest, the most useful in fact.

Alpha:
Try this patch; it should register *.tpp as a source file, enabling header/source switching (warning, untested).

--- Code: ---Index: src/sdk/globals.cpp
===================================================================
--- src/sdk/globals.cpp (revision 7467)
+++ src/sdk/globals.cpp (working copy)
@@ -230,6 +230,7 @@
         ext.IsSameAs(FileFilters::CC_EXT) ||
         ext.IsSameAs(FileFilters::CPP_EXT) ||
         ext.IsSameAs(FileFilters::CXX_EXT) ||
+        ext.IsSameAs(FileFilters::TPP_EXT) ||
         ext.IsSameAs(FileFilters::S_EXT) ||
         ext.IsSameAs(FileFilters::SS_EXT) ||
         ext.IsSameAs(FileFilters::S62_EXT) ||
Index: src/sdk/filefilters.cpp
===================================================================
--- src/sdk/filefilters.cpp (revision 7467)
+++ src/sdk/filefilters.cpp (working copy)
@@ -159,6 +159,7 @@
 const wxString FileFilters::CC_EXT                       = _T("cc");
 const wxString FileFilters::CPP_EXT                      = _T("cpp");
 const wxString FileFilters::CXX_EXT                      = _T("cxx");
+const wxString FileFilters::TPP_EXT                      = _T("tpp");
 const wxString FileFilters::INL_EXT                      = _T("inl");
 const wxString FileFilters::H_EXT                        = _T("h");
 const wxString FileFilters::HH_EXT                       = _T("hh");

--- End code ---

Freem:
I have think about a workaround: added a tpp folder which contains the tpp files, renamed as cpp.
Adding the "tpp/*.cpp" files in the project, uncheck "compile file" and "linking file" in "Build" tab of files properties.

It's not very nice because I don't like to use cpp extension, but it allow to use near every CB tools (except for auto completion, because it actually don't like templates)

But I will test your patch this evening, when I will be able to download CB source code.

Navigation

[0] Message Index

[#] Next page

Go to full version