somehow I think pointers are the way to go when modifying an iterator function 
argument.  but I am having problems. I have a pointer to an iterator.

gcc wants me to dereference a *third* time. it says to use -> and I know a->b 
is the same as *a.b 
but gcc doesn't see it this way I guess.  or again I am not understanding 
something.
I already trieddoing *iSpecEl->tagName and this does not work. it gives me an 
error.

EVERYTHING I have tried gives me an error.

how can this be? I know you dereference iterators using * and same with 
pointers. so I had to (I thought) do a double dereference here.  here is latest 
code:

typedef struct SBraceNode {
    int64_t lineNumber, columnNumber;
    uint32_t ch;
} SBraceNode;

typedef struct {
    std::string
        name,
        val;
    bool isBoolean;
    VUI hitLineNumbers;
} SAttribute;



typedef  std::list<SAttribute> LSA;
typedef  std::list<SAttribute>::iterator LSAI;
typedef  std::list<std::string> LS;
typedef  std::list<std::string>::iterator LSI;
LSA lsGlobalIDs;

typedef std::vector<std::string> VS;
VS vsDoctypes;

typedef struct SElement {
    std::string tagName;
    bool isVoid; //void element/singleton
    bool isScriptOrStyle; //for these, we ignore any opening and closing braces 
and look for </script> tags
    bool hasSlash;
    SBraceNode
        sbnOpenStart, //start of open tag
        sbnOpenEnd,   //end of open tag
        sbnCloseStart,//start of close tag
        sbnCloseEnd;  //end of close tag
    LS lsAttributes;
} SElement;

typedef std::vector<SElement> VSE;
typedef std::vector<SElement>::iterator VSEI;


bool attribNameIsInSpecElement(std::string tagName, std::string sattrib, VSEI* 
piSpecEl, LSAI* piSpecAttrib, bool isXHTML, bool isXML) {
    //*piSpecEl is the iterator for the spec element
    //**piSpecEl is the element
    //*piSpecAttrib is the iterator for the spec attribute
    //**piSpecAttrib is the attribute
    for (piSpecEl = &(vseSpecElements.begin());
        *piSpecEl !=  vseSpecElements.end();
        *piSpecEl++) {
        if (compare(tagName,**piSpecEl.tagName,isXHTML,isXML)) {
            for (piSpecAttrib = &(**piSpecEl.lsAttributes.begin());
                *piSpecAttrib !=  **piSpecEl.lsAttributes.end();
                *piSpecAttrib++) {
                if (compare(**piSpecAttrib.name,sattrib,isXHTML,isXML)) {
                    //at this point, iAttrib and iSpecEl both point to valid 
attribute and element.
                    return true;
                }
            }
        }
    }
    //at this point, iSpecEl points to vseSpecElement.end() and iAttrib points 
to lsAttributes.end()
    return false;
}

I could not use *piSpecEl->tagName because this caused an error.
I can't use **piSpecEl.tagName because this causes an *error* in gcc and it 
says "perhaps you wanted to use -> ?"

64\errgw64bmatch2:bmatch2.cpp:405:34: error: request for member 'tagName' in 
'piSpecEl', which is of pointer type 'VSEI* {aka __gnu_cxx::__normal_iter
ator<SElement*, std::vector<SElement> >*}' (maybe you meant to use '->' ?)
64\errgw64bmatch2:bmatch2.cpp:406:37: error: request for member 'lsAttributes' 
in 'piSpecEl', which is of pointer type 'VSEI* {aka __gnu_cxx::__normal
_iterator<SElement*, std::vector<SElement> >*}' (maybe you meant to use '->' ?)
64\errgw64bmatch2:bmatch2.cpp:407:36: error: request for member 'lsAttributes' 
in 'piSpecEl', which is of pointer type 'VSEI* {aka __gnu_cxx::__normal
_iterator<SElement*, std::vector<SElement> >*}' (maybe you meant to use '->' ?)
64\errgw64bmatch2:bmatch2.cpp:409:32: error: request for member 'name' in 
'piSpecAttrib', which is of pointer type 'LSAI* {aka std::_List_iterator<SAt
tribute>*}' (maybe you meant to use '->' ?)







>________________________________
> From: Ruben Van Boxem <[email protected]>
>To: [email protected] 
>Sent: Monday, November 5, 2012 11:52 PM
>Subject: Re: [Mingw-w64-public] bug in gcc? has nothing defined for iterator 
>references
> 
>
>Op 6 nov. 2012 06:40 schreef "Jim Michaels" <[email protected]> het volgende:
>>
>> 32\errgw32bmatch2:bmatch2.cpp:404:49: error: no match for 'operator=' in 
>> 'iSpecAttrib = (& iSpecEl)->__gnu_cxx::__normal_iterator<_Iterator, 
>> _Container>::operator-><SElement*, std::vector<SElement> 
>> >()->SElement::lsAttributes.std::list<_Tp, 
>> _Alloc>::begin<std::basic_string<char>, 
>> std::allocator<std::basic_string<char> > >()'
>>
>> 32\errgw32bmatch2:bmatch2.cpp:404:93: error: no match for 'operator!=' in 
>> 'iSpecAttrib != (& iSpecEl)->__gnu_cxx::__normal_iterator<_Iterator, 
>> _Container>::operator-><SElement*, std::vector<SElement> 
>> >()->SElement::lsAttributes.std::list<_Tp, 
>> _Alloc>::end<std::basic_string<char>, std::allocator<std::basic_string<char> 
>> > >()'
>>
>> typedef struct {
>>     std::string
>>         name,
>>         val;
>>     bool isBoolean;
>>     VUI hitLineNumbers;
>> } SAttribute;
>> typedef  std::list<SAttribute> LSA;
>> typedef  std::list<SAttribute>::iterator LSAI;
>>
>> bool attribNameIsInSpecElement(std::string tagName, std::string attrib, 
>> VSEI& iSpecEl, LSAI& iSpecAttrib, bool isXHTML, bool isXML) {
>Why are you passing the iterator references into the function when you set 
>them below anyway? Remove these function parameters, and make the variables 
>local to their for loop.
>>     for (iSpecEl=vseSpecElements.begin(); iSpecEl != vseSpecElements.end(); 
>> iSpecEl++) {
>>         if (compare(tagName,iSpecEl->tagName,isXHTML,isXML)) {
>>             for (iSpecAttrib=iSpecEl->lsAttributes.begin(); iSpecAttrib != 
>> iSpecEl->lsAttributes.end(); iSpecAttrib++) {
>>
>>
>> where it's having trouble is with assigning and equating to LSAI variables. 
>> specifically last and first line of function nothing is defined as operators 
>> for any iterator that's a reference.
>>
>> maybe there's something I am missing here. I wanted to modify the original 
>> iSpecAttrib. 
>> I don't know enough about iterators to figure out how to pass a value back 
>> in an argument to the original variable in c++ now except to use pointers...
>> I really wanted to use references, they are SO much more convenient.
>It is idiomatic c++ to pass iterators by value, not by reference.
>Ruben
>>  
>> -------------
>> Jim Michaels
>> [email protected]
>> [email protected]
>> http://RenewalComputerServices.com
>> http://JesusnJim.com (my personal site, has software)
>> ---
>> IEC Units: Computer RAM & SSD measurements, microsoft disk size measurements 
>> (note: they will say GB or MB or KB or TB when it is IEC Units!):
>> [KiB] [MiB] [GiB] [TiB]
>> [2^10B=1,024^1B=1KiB]
>> [2^20B=1,024^2B=1,048,576B=1MiB]
>> [2^30B=1,024^3B=1,073,741,824B=1GiB]
>> [2^40B=1,024^4B=1,099,511,627,776B=1TiB]
>> [2^50B=1,024^5B=1,125,899,906,842,624B=1PiB]
>> SI Units: Hard disk industry disk size measurements:
>> [KB] [MB] [GB] [TB]
>> [10^3B=1,000B=1KB]
>> [10^6B=1,000,000B=1MB]
>> [10^9B=1,000,000,000B=1GB]
>> [10^12B=1,000,000,000,000B=1TB]
>> [10^15B=1,000,000,000,000,000B=1PB]
>>
>>
>> ------------------------------------------------------------------------------
>> LogMeIn Central: Instant, anywhere, Remote PC access and management.
>> Stay in control, update software, and manage PCs from one command center
>> Diagnose problems and improve visibility into emerging IT issues
>> Automate, monitor and manage. Do more in less time with Central
>> http://p.sf.net/sfu/logmein12331_d2d
>> _______________________________________________
>> Mingw-w64-public mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>>
>------------------------------------------------------------------------------
>LogMeIn Central: Instant, anywhere, Remote PC access and management.
>Stay in control, update software, and manage PCs from one command center
>Diagnose problems and improve visibility into emerging IT issues
>Automate, monitor and manage. Do more in less time with Central
>http://p.sf.net/sfu/logmein12331_d2d
>_______________________________________________
>Mingw-w64-public mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
>
>
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to