Linking to C++ includes, or having a Dictionary or List template?

Is it possible to link to c++ includes? I need to use the List template. Also is the list able to replace the dictionary (C#) in c++? I really need to know if I am able to use lists. And no, arrays are just out of the question for what I am intending to do.

What I need is a list containing. <"string", object>. ^.^

You can include the standard template library (STL):

Please don't make polls: yes/no/maybe. Just start a normal topic.

However before you go including the STL I would ask what your end objective is. Maybe you don't need them (lists).

It's for a preference system, attaching temporary preferences to a string which contains an object.

Here's an example.

*entity = example arduino hardware.

entity.Preferences.Add("myPreference", object);

Is it possible to have, the 'object' syntax for c++?

Can you clarify? C++ is object oriented. So what do you mean by 'object' syntax?

It's for a preference system, attaching temporary preferences to a string which contains an object.

That's not your end objective. An end objective it so make a security system / helicopter / fish feeding system.

I don't really know what you mean by "attaching temporary preferences to a string which contains an object".

Heres the c# version which i'm trying to make arduino compatible -.-
. -.-.

    public class Preferences
    {
        #region Fields
        /// <summary>
        /// Collection of temporary attributes.
        /// 
        ///     <para>These attributes are not gauranteed to be there, 
        ///     and should proceed with caution when using.</para>
        /// </summary>
        private Dictionary<string, object> temporaryAttributes = new Dictionary<string, object>();
        /// <summary>
        /// Provides a lock for the attributes.
        /// </summary>
        private object attributesLock = new object();
        #endregion Fields

        #region Properties
        /// <summary>
        /// Gets a temporary attribute specified by the key.
        /// </summary>
        /// <param name="key">The attribute to obtain.</param>
        /// <returns>Returns the value of the specified key.</returns>
        public object this[string key]
        {
            get 
            {
                lock (this.attributesLock)
                {
                    if (this.temporaryAttributes.ContainsKey(key))
                    {
                        return this.temporaryAttributes[key];
                    }
                    else
                    {
                        return null;
                    }
                }
            }
            set 
            {
                lock (this.attributesLock)
                {
                    if (this.temporaryAttributes.ContainsKey(key))
                    {
                        this.temporaryAttributes[key] = value;
                    }
                }
            }
        }

        /// <summary>
        /// Gets or sets whether the character is using a hd client.
        /// </summary>
        public bool Hd { get; set; }
        /// <summary>
        /// Gets or sets whether the character's connected client is resized.
        /// </summary>
        public bool Resized { get; set; }
        /// <summary>
        /// Gets or sets if player is playing on FullScreen.
        /// </summary>
        public bool FullScreen { get; set; }
        /// <summary>
        /// Gets or sets whether the character is using a singe click mouse.
        /// </summary>
        public bool SingleMouse { get; set; }
        /// <summary>
        /// Gets or sets whether the character allows chat effects.
        /// </summary>
        public bool DisableChatEffects { get; set; }
        /// <summary>
        /// Gets or sets whether the character's private chat messages are split
        /// from the chat box.
        /// </summary>
        public bool SplitChat { get; set; }
        /// <summary>
        /// Gets or sets whether the character accepts aid.
        /// </summary>
        public bool AcceptAid { get; set; }
        /// <summary>
        /// Contains character private messages options.
        /// </summary>
        public PrivateMessageOptionType PrivateOptions { get; set; }
        /// <summary>
        /// Gets or sets whether the character's window is currently the active window.
        /// </summary>
        public bool ActiveWindow { get; set; }
        /// <summary>
        /// Gets or sets the character's attack style.
        /// </summary>
        public byte AttackStyle { get; set; }
        /// <summary>
        /// Gets or sets if the auto retaliate is on.
        /// </summary>
        public bool AutoRetaliate { get; set; }
        /// <summary>
        /// Gets or sets the character's custom withdraw/deposit amount.
        /// </summary>
        public int BankX { get; set; }
        /// <summary>
        /// Gets or sets if character's special bar is toogled.
        /// </summary>
        public bool SpecialToogled { get; set; }
        /// <summary>
        /// Gets or sets if character is on ancient curses book.
        /// </summary>
        public bool AncientCurses { get; set; }
        #endregion Properties

        #region Constructors
        /// <summary>
        /// Constructs the preferences with default values.
        /// </summary>
        public Preferences()
        {
            this.PrivateOptions = PrivateMessageOptionType.PrivateOnline;
            this.FullScreen = false;
            this.ActiveWindow = true;
            this.BankX = 50;
            this.SpecialToogled = false;
            this.AncientCurses = false;
        }
        #endregion Constructors

        #region Methods
        /// <summary>
        /// Attempts to add the specified key and value.
        /// </summary>
        /// <param name="key">The key to be added.</param>
        /// <param name="value">The key's value.</param>
        /// <returns>True if successfully added; false if not.</returns>
        public bool Add(string key, object value)
        {
            lock (this.attributesLock)
            {
                if (!this.temporaryAttributes.ContainsKey(key))
                {
                    this.temporaryAttributes.Add(key, value);
                    return true;
                }
                return false;
            }
        }

        /// <summary>
        /// Attempts to remove the specified key.
        /// </summary>
        /// <param name="key">The key to be removed.</param>
        /// <returns>True if successfully removed; false if not.</returns>
        public bool Remove(string key)
        {
            lock (this.attributesLock)
            {
                return this.temporaryAttributes.Remove(key);
            }
        }
        #endregion Methods
    }
}

Here is the code I have after linking the STL includes . Thanks Nick. Is it possible to have an unserialised object. Like plain object as there is c# or in java how there is ? because templates don't really let you typecast :l

template<class object>
class Attribute
{
public:
	std::map<std::string, object> attributes;
	
	void setAttribute(std::string string, object o)
	{
		attributes.insert(string, o);
	}

	object getAttribute(std::string string)
	{
		return (object) attributes.find(string);
	}

	object getAttributes(std::string string, object fail)
	{
		object o = (object) attributes.find(string);

		if(object != NULL)
		{
			return object;
		}
		return fail;
	}

	void removeAttribute(std::string string)
	{
		attributes.erase(string);
	}
};

Hello visser,
In my opinion you should consider to change approach instead of trying to port code from C# or STL that are very high level programming frameworks. Arduino is a simple microcontroller with limited resources, suitable for low level embedded applications. If you really need dictionaries, serialization and other complex data structures probably you should re considering your system architecture (this is my personal opinion, of course).

If you really need dictionaries, serialization and other complex data structures probably you should re considering your system architecture (this is my personal opinion, of course).

You are not unique in having that opinion. 2K SRAM won't go near as far as 8G SRAM on a PC, with swap space when memory runs out.

visser:
Heres the c# version which i'm trying to make arduino compatible -.-

You really have to think what might be compatible with arduino. Whatever you do you have a mind of a software engineer, you need to think there are actually hardware constraints others pointed out. You can't program the way you program a windows box. Think how you programed your first C/C++ code without much objects and bunch of windows api.

visser:
Here is the code I have after linking the STL includes . Thanks Nick. Is it possible to have an unserialised object. Like plain object as there is c# or in java how there is ? because templates don't really let you typecast :l

Anything's possible, but I agree with the others. With only 2 Kb of RAM, trying to have some fancy system of mapping preferences to strings is probably simply going to run out of memory.

Is there any other way to do this.As I really need a system like this.

What board are you using and why?

visser:
Is there any other way to do this.As I really need a system like this.

Why?

Maybe you can look at this netduino that is based on some sort of .NET framework or whatnot:

http://netduino.com/netduino/specs.htm

Because I want pretty much an event system out of this. Pretty much, accessing sensor values or motor directions when needed. Then destroyed, once accessed.

visser:
It's for a preference system, attaching temporary preferences to a string which contains an object.

...

visser:
Because I want pretty much an event system out of this. Pretty much, accessing sensor values or motor directions when needed. Then destroyed, once accessed.

Make up your mind. You want a preference system, you want an event system. What DO you want? Your requirements seem to have changed completely.

I thought it was made clear, but it was not. I am trying to use the preference/attribute system to trigger tasks. So basically it is an event system in some way is it not? Hmmmm?

AND BY THE WAY. Everyone has been telling me about the constraints to this, memory, yes I understand all of it, but I do not want to store them over a long period of time. So please get you replies on the topic and try to help me out.

AND BY THE WAY. Everyone has been telling me about the constraints to this, memory, yes I understand all of it, but I do not want to store them over a long period of time. So please get you replies on the topic and try to help me out.

The doors thatta way.

visser:
Because I want pretty much an event system out of this. Pretty much, accessing sensor values or motor directions when needed. Then destroyed, once accessed.

In a microprocessor, data like that is simply stored in an array. Not a complex "preference system."

visser:
I thought it was made clear, but it was not. I am trying to use the preference/attribute system to trigger tasks. So basically it is an event system in some way is it not? Hmmmm?

No, you have not been clear. As Nick points out you haven't said what you were trying to do and it makes it appear you are changing the requirements of your question. A "preference/attribute system" makes very little since on a microcontroller, so everyone here is struggling to understand what you are trying to accomplish.

Creating "events" to respond to "senor values" can easily (and most commonly) be done with if-statements or switch-cases.

visser:
AND BY THE WAY. Everyone has been telling me about the constraints to this, memory, yes I understand all of it, but I do not want to store them over a long period of time. So please get you replies on the topic and try to help me out.

What is "long period of time"? You keep using abstracts and not giving actual information. You aren't programming a PC. You claim to understand this, but I don't think you actually do.

It sounds like you are trying to store sensor values and act on them. You are significantly overcomplicating the situation with your high-level "preferences" system.