Commit 65c22085 authored by Ronan's avatar Ronan

remove useless constructors/destructors

parent 6a0a84da
......@@ -56,6 +56,8 @@ struct TransitionMap{
class Recognizer : public std::enable_shared_from_this<Recognizer>{
virtual ~Recognizer() = default;
void setName(const std::string &name);
const std::string &getName()const;
BELR_PUBLIC size_t feed(const std::shared_ptr<ParserContextBase> &ctx, const std::string &input, size_t pos);
......@@ -65,7 +67,6 @@ public:
bool getTransitionMap(TransitionMap *mask);
void optimize();
void optimize(int recursionLevel);
virtual ~Recognizer() { }
/*returns true if the transition map is complete, false otherwise*/
virtual bool _getTransitionMap(TransitionMap *mask);
......@@ -28,7 +28,8 @@ class ABNFAlternation;
class ABNFBuilder{
virtual ~ABNFBuilder();
virtual ~ABNFBuilder() = default;
virtual std::shared_ptr<Recognizer> buildRecognizer(const std::shared_ptr<Grammar> &grammar)=0;
......@@ -34,7 +34,7 @@ template<typename _parserElementT>
class AbstractCollector{
virtual void invokeWithChild(_parserElementT obj, _parserElementT child)=0;
virtual ~AbstractCollector();
virtual ~AbstractCollector() = default;
template<typename _parserElementT, typename _valueT>
......@@ -141,7 +141,7 @@ public:
class HandlerContextBase : public std::enable_shared_from_this<HandlerContextBase>{
BELR_PUBLIC virtual ~HandlerContextBase();
BELR_PUBLIC virtual ~HandlerContextBase() = default;
template <typename _parserElementT>
......@@ -295,10 +295,6 @@ T universal_pointer_cast(U * p){
return static_cast<T>(p);
template <typename _parserElementT>
template <typename _derivedParserElementT, typename _parserElementT, typename _valueT>
void ParserCollector<_derivedParserElementT,_parserElementT, _valueT>::invoke(_parserElementT obj, _valueT value){
......@@ -30,10 +30,6 @@ using namespace std;
// =============================================================================
namespace belr{
ABNFNumval::ABNFNumval() : mIsRange(false) {
......@@ -25,8 +25,7 @@ using namespace std;
namespace belr{
DebugElement::DebugElement(const string& rulename, const string& value)
:mRulename(rulename), mValue(value){
......@@ -20,11 +20,7 @@ using namespace::std;
/*This is our base class for all our parsed elements. It does nothing but is required for run time type identification*/
class SipElement{
//put a virtual destructor to enable polymorphism and dynamic casting.
virtual ~SipElement(){
virtual ~SipElement () = default;
/*this the class representing uri "other" params, per the grammar. They will be added to the SIP-URI when found.*/
......@@ -102,7 +98,7 @@ public:
int main(int argc, char *argv[]){
string uriToParse;
if (argc<2){
cerr<<argv[0]<<" <uri to parse>"<<endl;
return -1;
......@@ -112,16 +108,16 @@ int main(int argc, char *argv[]){
ABNFGrammarBuilder builder;
//construct the grammar from the grammar file, the core rules are included since required by most RFCs.
shared_ptr<Grammar> grammar=builder.createFromAbnfFile("sipgrammar.txt", make_shared<CoreRules>());
if (!grammar){
cerr<<"Could not build grammar from sipgrammar.txt"<<endl;
return -1;
//now instanciate a parser and assign it collectors and handlers
//This parser expects to build objects which are all inherited from SipElement, and that are stored as shared_ptr.
Parser<shared_ptr<SipElement>> parser(grammar);
//Now, tell our parser where to assign elements when they are found during parsing.
parser.setHandler("SIP-URI", make_fn(&SipUri::create)) //tells that whenever a SIP-URI is found, a SipUri object must be created.
->setCollector("user", make_sfn(&SipUri::setUsername)) //tells that when a "user" field is found, SipUri::setUsername() is to be called for assigning the "user"
......@@ -132,7 +128,7 @@ int main(int argc, char *argv[]){
parser.setHandler("other-param", make_fn(&OtherParam::create)) //when other-param is matched, construct an OtherParam object to hold the name and value of the other-params.
->setCollector("pname", make_sfn(&OtherParam::setName))
->setCollector("pvalue", make_sfn(&OtherParam::setValue));
//now, parse the input. We have to tell the parser the root object, which is the SIP-URI in this example.
size_t parsedSize = 0;
shared_ptr<SipElement> ret = parser.parseInput("SIP-URI", uriToParse, &parsedSize);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment