#include "ordertxt.ih"

bool OrderTxt::inspectIH(bool *sawINL, ConstIterVectIter *ihIter, bool sawIH, 
                           ConstIterVectIter const &hdrIter,
                           ConstIterVectIter const &iter,
                           VectConstIterPair const &pair) const
{
    if (*ihIter == pair.second)
        *ihIter = iter;

    bool multiple = false;

    if (hdrIter != pair.second)
    {
        if (*ihIter == hdrIter + 1)
            *sawINL = false;
        else if (sawIH)
            multiple = true;
        else
            errIdx((**ihIter)->idx) << "the internal header must " << 
                (hdrIter == pair.second ? 
                    "be first\n" 
                : 
                    "follow the header file\n");
    }
    else if (*ihIter == pair.first)  // no hdr seen, so the ih must be first
        *sawINL= false;
    else if (sawIH)
        multiple = true;
    else
        errIdx((**ihIter)->idx) << "the internal header file must be first\n";

    if (multiple)
        errIdx((**ihIter)->idx) << 
                "multiple internal header files not supported\n";

    return true;
}




