]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | ||
16 | #ifndef CEPH_CLIENT_TRACE_H | |
17 | #define CEPH_CLIENT_TRACE_H | |
18 | ||
19 | #include <stdlib.h> | |
20 | ||
21 | #include <list> | |
22 | #include <string> | |
23 | #include <fstream> | |
24 | using std::list; | |
25 | using std::string; | |
26 | using std::ifstream; | |
27 | ||
28 | /* | |
29 | ||
30 | this class is more like an iterator over a constant tokenlist (which | |
31 | is protected by a mutex, see Trace.cc) | |
32 | ||
33 | */ | |
34 | ||
35 | class Trace { | |
36 | int _line; | |
37 | const char *filename; | |
38 | ifstream *fs; | |
39 | string line; | |
40 | ||
41 | public: | |
42 | explicit Trace(const char* f) : _line(0), filename(f), fs(0) {} | |
43 | ~Trace() { | |
44 | delete fs; | |
45 | } | |
46 | ||
47 | Trace(const Trace& other); | |
48 | const Trace& operator=(const Trace& other); | |
49 | ||
50 | int get_line() { return _line; } | |
51 | ||
52 | void start(); | |
53 | ||
54 | const char *peek_string(string &buf, const char *prefix); | |
55 | const char *get_string(string &buf, const char *prefix); | |
56 | ||
57 | int64_t get_int() { | |
58 | string buf; | |
59 | return atoll(get_string(buf, 0)); | |
60 | } | |
61 | bool end() { | |
62 | return !fs || fs->eof(); | |
63 | //return _cur == _end; | |
64 | } | |
65 | }; | |
66 | ||
67 | #endif |