Question

I am using scintilla's lexing capabilities and I want to do something a bit out of the box.

Please mind that even though i have a bit of experience in other languages I am a beginner C++ coder.

I am looking for pointers on how to save specific information about a line for later used. The first idea that came to mind is to create an array and filling the corresponding array field for our line number, eg:

int lineOpt[];

...

lineOpt[20] = 20;
lineOpt[21] = 20;
lineOpt[372]= 75;

...

But something doesnt seem right here. I am not sure if this is the correct way to it not only because of the 'unlimited' size array i just created but also because of the 'gaps' that will be present.

Only a few specific lines will have those options set (depending on some text present in them) and again I have a feeling that this could be done another way.

Any help or pointers to some article would be appreciated.

Was it helpful?

Solution

It sounds like you need an associative container structure, not an array. Arrays are always of a fixed length set at compile time; you cannot change their size at run time. Your declaration int lineOpt[] is not legal.

Consider std::map<unsigned int, unsigned int> or std::unordered_map<unsigned int, unsigned int>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top