* Added some missing includes.

* Changed more key bindings in ElementDownloadList to commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1038 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2008-02-03 14:30:58 +00:00
parent 1b96bd6016
commit afe1312eb6
9 changed files with 73 additions and 84 deletions
+4 -4
View File
@@ -171,7 +171,7 @@ const char*
parse_object(const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char)) {
if (*first == '{') {
*dest = torrent::Object::create_list();
first = parse_list(first + 1, last, dest, &parse_is_delim_list);
first = parse_list(first + 1, last, dest, &parse_is_delim_block);
first = parse_skip_wspace(first, last);
if (first == last || *first != '}')
@@ -210,9 +210,9 @@ parse_list(const char* first, const char* last, torrent::Object* dest, bool (*de
}
const char*
parse_whole_list(const char* first, const char* last, torrent::Object* dest) {
parse_whole_list(const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char)) {
first = parse_skip_wspace(first, last);
first = parse_object(first, last, dest);
first = parse_object(first, last, dest, delim);
first = parse_skip_wspace(first, last);
if (first != last && parse_is_seperator(*first)) {
@@ -220,7 +220,7 @@ parse_whole_list(const char* first, const char* last, torrent::Object* dest) {
tmp.swap(*dest);
dest->as_list().push_back(tmp);
first = parse_list(++first, last, dest);
first = parse_list(++first, last, dest, delim);
}
return first;
+11 -3
View File
@@ -38,6 +38,7 @@
#define RTORRENT_RPC_PARSE_H
#include <string>
#include <cctype>
#include <torrent/object.h>
namespace rpc {
@@ -54,8 +55,15 @@ inline bool parse_is_escape(const char c) { return c == '\\'; }
inline bool parse_is_seperator(const char c) { return c == ','; }
inline bool parse_is_space(const char c) { return c == ' ' || c == '\t'; }
// The block delim is used in {} blocks to contain code. Since it
// doesn't check for isspace, it will include useless characters but
// that is the price for sane syntax.
inline bool parse_is_delim_default(const char c) { return parse_is_seperator(c) || std::isspace(c); }
inline bool parse_is_delim_list(const char c) { return parse_is_seperator(c) || c == '}' || std::isspace(c); }
inline bool parse_is_delim_command(const char c) { return parse_is_seperator(c) || c == ';' || std::isspace(c); }
// inline bool parse_is_delim_block(const char c) { return c == ';' || c == '}'; }
inline bool parse_is_delim_block(const char c) { return parse_is_seperator(c) || c == '}'; }
const char* parse_skip_wspace(const char* first);
const char* parse_skip_wspace(const char* first, const char* last);
@@ -69,9 +77,9 @@ const char* parse_value_nothrow(const char* src, int64_t* value, int base = 0, i
void parse_whole_value(const char* src, int64_t* value, int base = 0, int unit = 1);
bool parse_whole_value_nothrow(const char* src, int64_t* value, int base = 0, int unit = 1);
const char* parse_object(const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char) = &parse_is_delim_default);
const char* parse_list(const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char) = &parse_is_delim_default);
const char* parse_whole_list(const char* first, const char* last, torrent::Object* dest);
const char* parse_object (const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char) = &parse_is_delim_default);
const char* parse_list (const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char) = &parse_is_delim_default);
const char* parse_whole_list(const char* first, const char* last, torrent::Object* dest, bool (*delim)(const char) = &parse_is_delim_default);
std::string convert_list_to_string(const torrent::Object& src);
std::string convert_list_to_string(torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last);
+1 -1
View File
@@ -117,7 +117,7 @@ parse_command(target_type target, const char* first, const char* last) {
throw torrent::input_error("Could not find '='.");
torrent::Object args;
first = parse_whole_list(first + 1, last, &args);
first = parse_whole_list(first + 1, last, &args, &parse_is_delim_command);
// Find the last character that is part of this command, skipping
// the whitespace at the end. This ensures us that the caller