'struct std :: _ List_iterator <sequence *>'没有名为'_Ptr'的成员。为什么?</序列*>

时间:2014-10-30 01:36:19

标签: c++ unix

#include "SequenceDatabase.h"
#include <cstdlib>
#include <cstring>

// Parameterized constructor
SequenceDatabase::SequenceDatabase()
{
this->sequenceList = list<Sequence *>();
}

//destructor 
SequenceDatabase::~SequenceDatabase(){}

// method to find an entry in the list

//method to process the line passed and get the commands 
void SequenceDatabase::processLine(string line)
{
char *charPrtLine = new char[line.length() + 1];
strcpy(charPrtLine, line.c_str());
char * command = strtok (charPrtLine," \t");

if(command[0] == 'p' || command[0] == 'P') // Print
{
    char * idStr = strtok (NULL," \t");
    long id = atol(idStr);
    cout << "Note: Printing " << id << "...\n";
    bool idFound = false;
    list<Sequence*>::iterator iter = sequenceList.begin();  // iterator to the list 
    while(iter != sequenceList.end())
    {
        if(iter._Ptr->_Myval->getId() == id)
        {
            iter._Ptr->_Myval->print();
            idFound = true;
            break;
        }
        iter++;
    }
    if(!idFound)
        cout << "Can not find item (" << id << ") !\n";
}  
else if(command[0] == 'o' || command[0] == 'O') // obliterate
{
    char * idStr = strtok (NULL," \t");
    long id = atol(idStr);
    cout << "Note: Obliterating " << id << "...\n";
    bool idFound = false;
    list<Sequence*>::iterator iter = sequenceList.begin();  // iterator to the list 
    while(iter != sequenceList.end())
    {
        if(iter._Ptr->_Myval->getId() == id)
        {
            sequenceList.remove(iter._Ptr->_Myval);
            idFound = true;
            break;
        }
        iter++;
    }
    if(!idFound)
        cout << "Can not delete item (" << id << "), NOT found!\n";
}

else if(command[0] == 'd' || command[0] == 'D') // DNA
{
    char * labelStr = strtok (NULL," \t");
    string label(labelStr);

    char * idStr = strtok (NULL," \t");
    long id = atol(idStr);

    char * SeqStr = strtok (NULL," \t");
    string seq(SeqStr);

    char * seqLenStr = strtok (NULL," \t");
    unsigned int seqLen = atoi(seqLenStr);

    char * indexCodeRegStr = strtok (NULL," \t");
    int indexCodeReg = atoi(indexCodeRegStr);

    this->sequenceList.push_back(new DNA(label,id,seq,seqLen,indexCodeReg));
}
else if(command[0] == 'r' || command[0] == 'R') // RNA
{
    char * labelStr = strtok (NULL," \t");
    string label(labelStr);

    char * idStr = strtok (NULL," \t");
    long id = atol(idStr);

    char * SeqStr = strtok (NULL," \t");
    string seq(SeqStr);

    char * seqLenStr = strtok (NULL," \t");
    unsigned int seqLen = atoi(seqLenStr);

    char * typeRNAStr = strtok (NULL," \t");
    int typeRNA = atoi(typeRNAStr);

    this->sequenceList.push_back(new RNA(label,id,seq,seqLen,(typeOfRNA)typeRNA));
}
else if(command[0] == 'a' || command[0] == 'A') // AA
{
    char * labelStr = strtok (NULL," \t");
    string label(labelStr);

    char * idStr = strtok (NULL," \t");
    long id = atol(idStr);

    char * SeqStr = strtok (NULL," \t");
    string seq(SeqStr);

    char * seqLenStr = strtok (NULL," \t");
    unsigned int seqLen = atoi(seqLenStr);

    char * readingFrameStr = strtok (NULL," \t");
    int readingFrame = atoi(readingFrameStr);

    this->sequenceList.push_back(new AA(label,id,seq,seqLen,readingFrame));
}
else if(command[0] == 's' || command[0] == 'S') // Size of the master list
{
    cout << "Entries: "
        << this->sequenceList.size()    << " total\n";
}
delete [] charPrtLine;
}
//method to import entries from the supplied command file 
void SequenceDatabase::importEntries(string fileName)
{
string line;
const char * ttt = fileName.c_str();
ifstream myfile (ttt);

if (myfile.is_open())
{
    while ( getline(myfile,line) )
    {
        this->processLine(line);           
    }
    myfile.close();
}
}

代码在Visual Studio中编译良好,但在使用g ++的Unix终端中编译。

g ++中弹出的错误:

在成员函数&#39; void SequenceDatabase :: processLine(string line)&#39;:

32,34,52,54:错误:&#39; struct std :: _ List_iterator&#39;没有名为&#39; _Ptr&#39;

的成员

我意识到使用_Ptr成员是为什么它不能使用g ++在Unix终端中工作,但是如何将它替换为在Visual Studio和Unix中工作?

0 个答案:

没有答案
相关问题