Reviewed By: mbouaziz Differential Revision: D7399335 fbshipit-source-id: bc42b37master
parent
3ebec206dc
commit
a2d3a0ec73
@ -0,0 +1,46 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
type t = {integers: int String.Map.t; floats: float String.Map.t; strings: string String.Map.t}
|
||||
|
||||
let empty = {integers= String.Map.empty; floats= String.Map.empty; strings= String.Map.empty}
|
||||
|
||||
let add_int ({integers} as t) ~key ~data = {t with integers= String.Map.set integers ~key ~data}
|
||||
|
||||
let add_float ({floats} as t) ~key ~data = {t with floats= String.Map.set floats ~key ~data}
|
||||
|
||||
let add_string ({strings} as t) ~key ~data = {t with strings= String.Map.set strings ~key ~data}
|
||||
|
||||
let add_string_opt t ~key ~data =
|
||||
match data with Some data -> add_string t ~key ~data | None -> t
|
||||
|
||||
|
||||
let yojson_of_integers integers =
|
||||
let f ~key ~data acc = (key, `Int data) :: acc in
|
||||
`Assoc (String.Map.fold integers ~init:[] ~f)
|
||||
|
||||
|
||||
let yojson_of_floats floats =
|
||||
let f ~key ~data acc = (key, `Float data) :: acc in
|
||||
`Assoc (String.Map.fold floats ~init:[] ~f)
|
||||
|
||||
|
||||
let yojson_of_strings strings =
|
||||
let f ~key ~data acc = (key, `String data) :: acc in
|
||||
`Assoc (String.Map.fold strings ~init:[] ~f)
|
||||
|
||||
|
||||
let to_json {integers; floats; strings} =
|
||||
`Assoc
|
||||
[ ("int", yojson_of_integers integers)
|
||||
; ("double", yojson_of_floats floats)
|
||||
; ("normal", yojson_of_strings strings) ]
|
||||
|> Yojson.Basic.to_string
|
@ -1,26 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
type t = (string * Yojson.Basic.json) list
|
||||
|
||||
let empty = []
|
||||
|
||||
let add_int t ~key ~data = (key, `Int data) :: t
|
||||
|
||||
let add_float t ~key ~data = (key, `Float data) :: t
|
||||
|
||||
let add_string t ~key ~data = (key, `String data) :: t
|
||||
|
||||
let add_string_opt t ~key ~data =
|
||||
match data with Some data -> add_string t ~key ~data | None -> t
|
||||
|
||||
|
||||
let to_json t = Yojson.Basic.to_string (`Assoc t)
|
@ -1,12 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
let tracing_methods = []
|
@ -1,12 +0,0 @@
|
||||
(*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val tracing_methods : (string * string * string * string) list
|
Loading…
Reference in new issue