From 11a44f3a27df563a18a6ee287c5744990bdb2a47 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 21 Apr 2015 11:27:38 +0200 Subject: [PATCH] move when popping from Token deque --- alib2data/src/sax/FromXMLParserHelper.cpp | 2 +- alib2data/src/sax/Token.cpp | 7 ++++++- alib2data/src/sax/Token.h | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/alib2data/src/sax/FromXMLParserHelper.cpp b/alib2data/src/sax/FromXMLParserHelper.cpp index 0c6f33cdc5..9622f077af 100644 --- a/alib2data/src/sax/FromXMLParserHelper.cpp +++ b/alib2data/src/sax/FromXMLParserHelper.cpp @@ -28,7 +28,7 @@ void FromXMLParserHelper::popToken(std::deque<Token>& input, Token::TokenType ty std::string FromXMLParserHelper::popTokenData(std::deque<Token>& input, Token::TokenType type) { if(isTokenType(input, type)) { - std::string result = std::move(input.front().getData()); + std::string result = std::move(input.front()).getDataMove(); input.pop_front(); return std::move(result); } else { diff --git a/alib2data/src/sax/Token.cpp b/alib2data/src/sax/Token.cpp index b3c3aefc85..438783d986 100644 --- a/alib2data/src/sax/Token.cpp +++ b/alib2data/src/sax/Token.cpp @@ -7,6 +7,7 @@ #include "Token.h" #include <sstream> +#include <iostream> namespace sax { @@ -16,7 +17,7 @@ Token::Token(const std::string& data, const Token::TokenType type) : } Token::Token(std::string&& data, const Token::TokenType type) : - data(data), type(type) { + data(std::move(data)), type(type) { } @@ -24,6 +25,10 @@ const std::string& Token::getData() const { return data; } +std::string&& Token::getDataMove() && { + return std::move(data); +} + Token::TokenType Token::getType() const { return type; } diff --git a/alib2data/src/sax/Token.h b/alib2data/src/sax/Token.h index dba8b50f7e..d6f455ebac 100644 --- a/alib2data/src/sax/Token.h +++ b/alib2data/src/sax/Token.h @@ -37,6 +37,11 @@ public: */ const std::string& getData() const; + /** + * @return name of the tag or characters read + */ + std::string&& getDataMove() &&; //TODO should be named getData only + /** * @return type of the token - star of the tag, end of the tag, attribute * of the tag or characters -- GitLab