I am having issues with the compiler in checking to see if a piece of a string is empty or not. I have a feeling this is simple, but today has not been my day with this code, but I am still doing my best. Ty

tableRow is a std::vector<std::string> and the enum is here

static enum Columns
{
    Name = 0,
    X800,
    Y800,
    W800,
    H800,
    X1024,
    Y1024,
    W1024,
    H1024,
    X1280,
    Y1280,
    W1280,
    H1280,
    Notes,
};
if (*(tableRow + (int)Name) == NULL || (tableRow[(int)Name]) == "")
    continue;

if ((tableRow[(int)H1280]) == NULL || (tableRow[(int)H1280]) == "")
    continue;

In line 1 of your code, you add an integer to what you claim is a vector. I don't know what you think that's supposed to do, but it's not well defined in standard C++.

Four times in you code, you explicitly convert an enum to an int. That shouldn't be necessary, and vector subscripts are unsigned anyway.

The most straightforward way to check whether a std::string object is empty is to call its empty member.

So... you should be writing something along these lines:

if(tableRow[H1280].empty())
    continue;

Edited 5 Years Ago by arkoenig: n/a

Error from trying to use .empty()

1>AoE2Wide.cpp(1168): error C2039: 'empty' : is not a member of 'System::SByte'
1> c:\windows\microsoft.net\framework\v4.0.30319\mscorlib.dll : see declaration of 'System::SByte'

Maybe this will help clear it up, there are pieces of code missing

std::vector<std::string> table = split(totalLines, "\t");
        for each (auto tableRow in table)
        {
            if (tableRow.size() < 13)
                continue;

            if (*(tableRow + (int)Name) == NULL || (tableRow[(int)Name]) == "")
                continue;

            if (tableRow[H1280].empty())
                continue;

You tell me. An element of a string is a single character. It's not immediately clear what you mean when you say that a character is empty.

These values are being read from a file, so i am testing that they actually exist when being read in, there maybe empty values in this table that I am reading.

not sure if this is completly relevent but insted of

if (*(tableRow + (int)Name) == NULL || (tableRow[(int)Name]) == "")

alterntive

if(*(tableRow +name) == ""

it seems to me you are checking twice
"" is an empty string

This question has already been answered. Start a new discussion instead.