Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#ifndef GENERS_FINDNAME_HH_
#define GENERS_FINDNAME_HH_

#include <vector>
#include <string>
#include <cassert>

namespace gs {
    inline unsigned long findName(const std::vector<std::string>& vec,
                                  const char* name)
    {
        assert(name);
        if (vec.empty())
            return 0UL;
        const std::string* names = &vec[0];
        const unsigned long ncols = vec.size();
        unsigned long col = 0;
        for (; col < ncols && names[col] != name; ++col) {;}
        return col;
    }
}

#endif // GENERS_FINDNAME_HH_