codemod 2010-2016 to 2010-present
[hiphop-php.git] / hphp / runtime / base / debuggable.h
blob87dc1b9690c164f6425c4cf2303a3ccfc7b64a0c
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_DEBUGGABLE_H_
17 #define incl_HPHP_DEBUGGABLE_H_
19 #include "hphp/runtime/base/type-string.h"
21 #include <string>
22 #include <utility>
23 #include <vector>
25 namespace HPHP {
26 ///////////////////////////////////////////////////////////////////////////////
28 /**
29 * Implement this interface to report information to debugger or execute
30 * debugger commands.
32 struct IDebuggable {
33 enum Support {
34 SupportInfo = 1,
35 SupportDump = 2,
36 SupportVerb = 4,
39 typedef std::pair<const char*, std::string> InfoEntry;
40 typedef std::vector<InfoEntry> InfoVec;
42 public:
43 static void Add(InfoVec& out, const char* name, const std::string& value);
44 static void AddServerStats(InfoVec& out, const char* name,
45 const char* statsName = nullptr);
47 static std::string FormatNumber(const char* fmt, int64_t n);
48 static std::string FormatSize(int64_t size);
49 static std::string FormatTime(int64_t milliSeconds);
51 public:
52 virtual ~IDebuggable() {}
54 /**
55 * Returns a map of those support bits. Tells caller which function can be
56 * called.
58 virtual int debuggerSupport() {
59 return 0;
62 /**
63 * Fill up vector with summary information.
65 virtual void debuggerInfo(InfoVec& info) {
68 /**
69 * Dump detailed information to return string.
71 virtual String debuggerDump() {
72 return String();
75 /**
76 * Execute a debugger action.
78 virtual String debuggerVerb(const std::string& verb,
79 const std::vector<std::string>& args) {
80 return String();
84 ///////////////////////////////////////////////////////////////////////////////
87 #endif // incl_HPHP_DEBUGGABLE_H_