gennaropirozzi
Programmer
hello,
in this code:
/*
This file is a part of the OSC Library (Open Sound Code).
Visit the OSC website at for the complete OSC library, the latest update, documentation,
user forum, etc.
Allthough the source code to the OSC Library is publicly available,
use and distribution of the OSC Library is governed by a license agreement.
The License Agreement can be found at the OSC website.
*/
#ifndef HCOMMANDLINELIBRARY_H
#define HCOMMANDLINELIBRARY_H
#include <map>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
#pragma warning( disable : 4786 ) // Disable debug warnings for long id-names
#include <assert.h>
#include <stdlib.h>
/*
A little note about using option prefix:
You still have to include the prefix when specifying the template
Syntax checking will be stricter
*/
class HCLL_Template
{
private:
map<string, int> m_optionMap; // m_option[label]=numParams
string m_optionPrefix;
bool m_useOptionPrefix;
public:
HCLL_Template()
{
m_useOptionPrefix=false;
};
HCLL_Template(const HCLL_Template &t)
{
operator=(t);
}
const HCLL_Template &operator=(const HCLL_Template &t)
{
m_optionMap=t.m_optionMap; // Hmmm...
m_optionPrefix=t.m_optionPrefix;
m_useOptionPrefix=t.m_useOptionPrefix;
return *this;
}
void setOptionPrefix(string pre)
{
m_useOptionPrefix=true;
m_optionPrefix=pre;
};
const string &getOptionPrefix()
{
return m_optionPrefix;
};
bool usingOptionPrefix()
{
return m_useOptionPrefix;
}
void addOption(const string &label, int numParams)
{
m_optionMap[label]=numParams;
}
bool optionExists(const string &label) const
{
return m_optionMap.find(label) != m_optionMap.end();
}
int operator[](const string &label)
{
if (optionExists(label))
return m_optionMap[label];
else
return 0;
// ERROR (but it is not reported, it is the caller's
// responsibility to check optionExists() first !
}
};
class HCLL_VarType
{
private:
string m_string;
public:
HCLL_VarType()
{
setString("");
}
HCLL_VarType(const string &str)
{
setString(str);
}
bool operator<(const HCLL_VarType &vt) const
{
return m_string<vt.getString();
};
bool operator==(const HCLL_VarType &vt) const
{
return m_string==vt.getString();
};
void setString(const string &str)
{
m_string=str;
}
const string & getString() const
{
return m_string;
}
long getInt() const
{
return atol(m_string.c_str());
}
double getFloat() const
{
return atof(m_string.c_str());
}
};
typedef vector<HCLL_VarType> HCLL_Option;
typedef map<string, HCLL_Option> HCLL_OptionMap; // HCLL_OptionMap["label"] = HCLL_Option
typedef vector<HCLL_VarType> HCLL_VarTypeArray;
#define HCLL_RESULT_OK 0
#define HCLL_RESULT_ERROR_TOO_FEW_OPTION_PARAMS 1
#define HCLL_RESULT_ERROR_UNRECOGNIZED_OPTION 2
typedef int HCLL_Result;
class HCLL_CommandLine
{
private:
HCLL_VarTypeArray m_progParam;
HCLL_OptionMap m_optionMap;
HCLL_Template m_template;
string m_lastOptionParsed;
public:
// må ha templaten først
void setTemplate(const HCLL_Template &t)
{
m_template=t;
}
HCLL_Result parse(int argc, char* argv[]);
const string &getLastOptionParsed() const
{
return m_lastOptionParsed;
}
void dump(); // for debugging
int getNumProgParams() const
{
return m_progParam.size();
};
const HCLL_VarType &getProgParam(int i) const
{
assert( (i>=0) && (i<m_progParam.size()) ); // should do proper error checking
return m_progParam;
};
int getNumOptions() const
{
return m_optionMap.size();
};
bool optionExists(const string &label) const
{
return m_optionMap.find(label) != m_optionMap.end();
}
int getNumOptionParams(const string &label)
{
// const_cast<HCLL_OptionMap>(m_optionMap);
return m_optionMap[label].size();
};
const HCLL_VarType &getOptionParam(const string &label, int i)
{
assert( (i>=0) && (i<m_optionMap[label].size()) ); // should do proper error checking
return (m_optionMap[label]);
};
};
#endif
I have this error:
Error: HCOMMANDLINELIBRARY.H(36,18):Too few arguments in template class name 'map'
Error: HCOMMANDLINELIBRARY.H(36,31)eclaration terminated incorrectly
Error: HCOMMANDLINELIBRARY.H(52,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(52,3):'m_optionMap' is not a member of 'HCLL_Template'
Error: HCOMMANDLINELIBRARY.H(77,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(82,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(89,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(139,33):Too few arguments in template class name 'map'
Error: HCOMMANDLINELIBRARY.H(139,49)eclaration terminated incorrectly
Error: HCOMMANDLINELIBRARY.H(152,28):Type name expected
Error: HCOMMANDLINELIBRARY.H(152,28)eclaration missing ;
Warn : HCOMMANDLINELIBRARY.H(174,3):Comparing signed and unsigned values
Error: HCOMMANDLINELIBRARY.H(179,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(183,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(188,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(192,3):Undefined symbol 'm_optionMap'
Warn : vector.h(985,31):Cannot create pre-compiled header: code in header
Error: HCOMMANDLINELIBRARY.H(77,29):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,26):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,28):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,29):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Too many error or warning messages
How to solve?
Thanks you.
in this code:
/*
This file is a part of the OSC Library (Open Sound Code).
Visit the OSC website at for the complete OSC library, the latest update, documentation,
user forum, etc.
Allthough the source code to the OSC Library is publicly available,
use and distribution of the OSC Library is governed by a license agreement.
The License Agreement can be found at the OSC website.
*/
#ifndef HCOMMANDLINELIBRARY_H
#define HCOMMANDLINELIBRARY_H
#include <map>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
#pragma warning( disable : 4786 ) // Disable debug warnings for long id-names
#include <assert.h>
#include <stdlib.h>
/*
A little note about using option prefix:
You still have to include the prefix when specifying the template
Syntax checking will be stricter
*/
class HCLL_Template
{
private:
map<string, int> m_optionMap; // m_option[label]=numParams
string m_optionPrefix;
bool m_useOptionPrefix;
public:
HCLL_Template()
{
m_useOptionPrefix=false;
};
HCLL_Template(const HCLL_Template &t)
{
operator=(t);
}
const HCLL_Template &operator=(const HCLL_Template &t)
{
m_optionMap=t.m_optionMap; // Hmmm...
m_optionPrefix=t.m_optionPrefix;
m_useOptionPrefix=t.m_useOptionPrefix;
return *this;
}
void setOptionPrefix(string pre)
{
m_useOptionPrefix=true;
m_optionPrefix=pre;
};
const string &getOptionPrefix()
{
return m_optionPrefix;
};
bool usingOptionPrefix()
{
return m_useOptionPrefix;
}
void addOption(const string &label, int numParams)
{
m_optionMap[label]=numParams;
}
bool optionExists(const string &label) const
{
return m_optionMap.find(label) != m_optionMap.end();
}
int operator[](const string &label)
{
if (optionExists(label))
return m_optionMap[label];
else
return 0;
// ERROR (but it is not reported, it is the caller's
// responsibility to check optionExists() first !
}
};
class HCLL_VarType
{
private:
string m_string;
public:
HCLL_VarType()
{
setString("");
}
HCLL_VarType(const string &str)
{
setString(str);
}
bool operator<(const HCLL_VarType &vt) const
{
return m_string<vt.getString();
};
bool operator==(const HCLL_VarType &vt) const
{
return m_string==vt.getString();
};
void setString(const string &str)
{
m_string=str;
}
const string & getString() const
{
return m_string;
}
long getInt() const
{
return atol(m_string.c_str());
}
double getFloat() const
{
return atof(m_string.c_str());
}
};
typedef vector<HCLL_VarType> HCLL_Option;
typedef map<string, HCLL_Option> HCLL_OptionMap; // HCLL_OptionMap["label"] = HCLL_Option
typedef vector<HCLL_VarType> HCLL_VarTypeArray;
#define HCLL_RESULT_OK 0
#define HCLL_RESULT_ERROR_TOO_FEW_OPTION_PARAMS 1
#define HCLL_RESULT_ERROR_UNRECOGNIZED_OPTION 2
typedef int HCLL_Result;
class HCLL_CommandLine
{
private:
HCLL_VarTypeArray m_progParam;
HCLL_OptionMap m_optionMap;
HCLL_Template m_template;
string m_lastOptionParsed;
public:
// må ha templaten først
void setTemplate(const HCLL_Template &t)
{
m_template=t;
}
HCLL_Result parse(int argc, char* argv[]);
const string &getLastOptionParsed() const
{
return m_lastOptionParsed;
}
void dump(); // for debugging
int getNumProgParams() const
{
return m_progParam.size();
};
const HCLL_VarType &getProgParam(int i) const
{
assert( (i>=0) && (i<m_progParam.size()) ); // should do proper error checking
return m_progParam;
};
int getNumOptions() const
{
return m_optionMap.size();
};
bool optionExists(const string &label) const
{
return m_optionMap.find(label) != m_optionMap.end();
}
int getNumOptionParams(const string &label)
{
// const_cast<HCLL_OptionMap>(m_optionMap);
return m_optionMap[label].size();
};
const HCLL_VarType &getOptionParam(const string &label, int i)
{
assert( (i>=0) && (i<m_optionMap[label].size()) ); // should do proper error checking
return (m_optionMap[label]);
};
};
#endif
I have this error:
Error: HCOMMANDLINELIBRARY.H(36,18):Too few arguments in template class name 'map'
Error: HCOMMANDLINELIBRARY.H(36,31)eclaration terminated incorrectly
Error: HCOMMANDLINELIBRARY.H(52,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(52,3):'m_optionMap' is not a member of 'HCLL_Template'
Error: HCOMMANDLINELIBRARY.H(77,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(82,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(89,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(139,33):Too few arguments in template class name 'map'
Error: HCOMMANDLINELIBRARY.H(139,49)eclaration terminated incorrectly
Error: HCOMMANDLINELIBRARY.H(152,28):Type name expected
Error: HCOMMANDLINELIBRARY.H(152,28)eclaration missing ;
Warn : HCOMMANDLINELIBRARY.H(174,3):Comparing signed and unsigned values
Error: HCOMMANDLINELIBRARY.H(179,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(183,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(188,3):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(192,3):Undefined symbol 'm_optionMap'
Warn : vector.h(985,31):Cannot create pre-compiled header: code in header
Error: HCOMMANDLINELIBRARY.H(77,29):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,26):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,28):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,29):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Undefined symbol 'm_optionMap'
Error: HCOMMANDLINELIBRARY.H(77,25):Too many error or warning messages
How to solve?
Thanks you.