templates

Templates and nested classes/structures

I have a simple container : template <class nodeType> list { public: struct node { nodeType info; node* next; }; //... }; Now, there is a function called _search which searches the list and returns a reference to the node which matched. Now, when I am referring to the return-type of the...

Generic object carrier class - C++

I need to create a generic object carrier class. I came up with something simple like template<typename T> class ObjectCarrier { public: const T& item() const { return item_; } void setItem(T& item) { item_ = item; } private: T item_; }; This works well when T has got a default constructor (par...

C++ Templated return

Hey Folks, I have a program which is built on "Entities", which hold "Components" (composition FTW). Components may include many different types including scripts, assets, etc. I would like to build an Entity function called Entities have a map of strings, and actual Components, such that the Components can be searched for by type na...

C++ Template specialization to provide extra member function?

Hello, how do I provide extra member function for specialized template in a non-inline way? i.e. template<typename T> class sets { void insert(const int& key, const T& val); }; template<> class sets<bool> { void insert(const int& key, const bool& val); void insert(const int& key){ insert(key, true); }; }; But when I write ...

Dreamweaver changing path to site's reference instead of local

I have noticed recently, when I apply a template to a new HTML website, all the relative paths are pointed to my local files, example: file:///C|/webstuff/files but I cannot set them to relative paths that are pointed to my server, http://www.websitehere.com/ I have read that some versions of Dreamweaver will not allow this, can anyone c...

Templated HTML Editor

Hi, I'm looking for a HTML editor that kinda supports templated editing or live snippets or something like that. Background: I'm working on a website for a friend. As there are no specifications what the webspace/webserver can or can't do, I decided to make it a pure HTML/CSS page, or rather 10 of them. I wrote a template, copied it 10 ...

Template lookup in class?

It's hard to get a word for this. Sometimes I see a class like this: template <typename T> class Wrapper { public: Wrapper(const T& t) : t_(t) {} Wrapper(const Wrapper& w) : t_(w.t_) {} private: T t_; } As far as I can tell this is legitimate code. However, why is the copy constructor allowed to accept a const Wrapper& wit...

How to put XML element's content into XUL template?

Hi, I've gotten trouble with passing XML data into XUL template. Look: For example, we have the datasource XML with the next structure: <people> <person name="Joe"/> <person name="Tom"/> <person name="Lisa"/> <person name="Bob"/> </people> In this case we may use the next template in XUL: <template> <query expr="person"/> <ac...

Good Visio Template (or alternative) for SOA/Distributed Systems?

Apologies if this has been asked (I couldn't see a duplicate when searching) but I'm wondering if anyone can recommend a reliable Visio template for SOA/Distributed Systems design or a decent alternative? What have you found which works well for you? There isn't anything which stands out from either the templates shipped with Visio P...

__FILE__ macro manipulation handling at compile time.

One of the issues I have had in porting some stuff from Solaris to Linux is that the Solaris compiler expands the macro __FILE__ during preprocessing to the file name (e.g. MyFile.cpp) whereas gcc on Linux expandeds out to the full path (e.g. /home/user/MyFile.cpp). This can be reasonably easily resolved using basename() but....if you're...

Load ruby on rails template from database

I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in database, so I would like to have the template stored in database but still retain the whole ActionView mechanism. ...

Template metaprogram converting type to unique number

I just started playing with metaprogramming and I am working on different tasks just to explore the domain. One of these was to generate a unique integer and map it to type, like below: int myInt = TypeInt<AClass>::value; I want to know if this is at all possible, and in that case how. Because although I have learned much about explor...

shared_ptr with templates

Hello! If I want to create a smart pointer to struct I do that: struct A { int value; }; typedef boost::shared_ptr<A> A_Ptr; So, I can write the following: A_Ptr pA0(new A); pA0->value = 123; But, If I have a template struct like that: template<typename T> struct B { T value; }; And I want to write the following: ...

Nested class forward declaration for template inheritance

What's the proper way to inherit from a template class with the template argument being a nested class within the inheriting class? class SomeClass : public TemplateClass<NestedClass> { class NestedClass {}; }; ...

Safe ERB Language?

I wonder if there is a safe template that reassemble ERB. ERB is very easy to use, but the deadly part to use that in a CMS is the over powerful access (you can just write some really nasty stuff with that in a matter of seconds...) So I wonder if there is any chance such language exist. Please I don't want radius/liquid..... writing ex...

Untrusted templates in Python - what is a safe library to use?

I am building a library that will be used in several Python applications. It get multilingual e-mail templates from an RMDBS, and then variable replacement will be performed on the template in Python before the e-mail is sent. In addition to variable replacement, I need the template library to support if, elif, and for statements in the...

C++ Composite Template Class Factory

Is it possible to make a composite template class factory without manually specifying all of the combinations? What I mean is if I have these classes: class CompositeBase {}; template< typename C1, typename C2, typename C3 > class Composite : public CompositeBase { private: C1 component1; C2 component2; C3 component3; }; ...

Template class with different order or variables (Color/Pixel class).

I got two class templates Color3_t and Color4_t that store 3 and 4 color channels and look like this: template <typename TYPE> struct Color3_t { TYPE Red; TYPE Green; TYPE Blue; void Zero() { Red = Green = Blue = 0; } (...) } Both templates have several function for inverting, swapping etc. color channels a...

What are your most useful Xcode templates?

Xcode comes with a few templates (file templates, project template, etc.). If you don't know what I'm talking about, take a look. After searching on Google for some time I couldn't find any other useful templates. So here it is: What are your most useful Xcode templates? I'll start with a pretty boring Objcetive-C category file temple....

Type of template if the template is the return value (Java)

I was wondering what is the data type of the template variable if the return is set to a template. I have seen this in a code somewhere but I do not know where does it cast the value retrieved from the session. public class RequestObject { public <T> T getFromSessionMap(String sessionKey) { return (T)session.getAttribute(sessio...