need help with determining typeid

closed account (Dy7SLyTq)
so im writing a lexer and i want to be able to pass it one of the following to the constructor:
1) vector<vector<string>> for the contents of multiple files
2) vector<string> for one file
3) string[][] see 1
4) string[] see 2
5) string so that i can run a test or make it inline c++ or something like that. ie:
 
Lexer Lex("Here is my jade script");


and then the constructor determines the type and sends it to be converted back to one string. the only problem is i get this error:
dtscode@dtscode-Latitude-E6410:~/Desktop/compiler$ ../gcc*/bin/g++ -std=c++11 main.cpp Lexer.cpp -o jade
/tmp/ccrEM7FN.o: In function `main':
main.cpp:(.text+0x1be): undefined reference to `Lexer::Lexer<std::vector<std::string, std::allocator<std::string> > >(std::vector<std::string, std::allocator<std::string> >)'
collect2: error: ld returned 1 exit status


main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include  <fstream>
#include  <sstream>
#include   <string>
#include   <vector>

#include "Token.hpp"
#include "Lexer.hpp"

using std::      ostream;
using std::         cout;
using std::         cerr;
using std::         endl;
using std::          cin;
using std::     ifstream;
using std::istringstream;
using std::       string;
using std::       vector;

void Log(int Line)
{
    static int Current = 1;

    cout<<"Log ("<< Current++ <<") @ Line: "<< Line << endl;
}

constexpr unsigned int Str2Int(const char *Line, int CurrentPos = 0)
{
    return !Line[CurrentPos] ? 5381 : (Str2Int(Line, CurrentPos + 1) * 33) ^ Line[CurrentPos];
}

void Help    ();
void Version ();
void About   ();

int main(int argc, char *argv[])
{

    vector<string> Arguments(argv + 1, argv + argc);
    vector<string> FileList;

    for(auto &Counter : Arguments)
    {
        switch(Str2Int(Counter.c_str()))
        {
            case Str2Int("--help"):
                Help();
                break;

            case Str2Int("--version"):
                Version();
                break;

            case Str2Int("--about"):
                About();
                break;

            default:
                FileList.push_back(Counter);
        }
    }

    ifstream File;

    Lexer Lex(FileList);
}

void Help()
{
}

void Version()
{
}

void About()
{
}

(i know main() looks a little weird but thats because i decided to change it to classes instead of functions and decided to implement it first before cleaning it up)

Lexer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef _Lexer_hpp
#define _Lexer_hpp

#include <string>
#include "Token.hpp"

using std::string;

class Lexer
{
    Token  TokenList;
    string Source;
/*
    string VecVecToString   (vector<vector<string>>);
    string VecToString      (vector<string>);
    string ArrayPtrToString (string**);
    string ArrayToString    (string*);

    Token& MiniLex(string);
*/
    public:
        template<class Type> Lexer(Type);
/*
        void   StartLex           ();
        Token& GetTokenList       ();
        string GetFormattedSource ();
        void   PrintSource        ();
        void   PrintTokenList     ();*/
};

#endif 

(the other functions are commented out because i wanted to test the constructor out first)

Lexer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <typeinfo>
#include <vector>
#include <string>

using namespace std;

#include "Lexer.hpp"

template<class Type>
Lexer::Lexer(Type RawSource)
{
    std::cout<< typeid(RawSource).name() << std::endl;
}

right now its just supposed to print the types so i know what to test for
Topic archived. No new replies allowed.