vfs: check userland buffers before reading them.
[haiku.git] / src / apps / debugger / user_interface / gui / value / TableCellBoolEditor.cpp
blob7a0ed75dea153d48da0b069ec8fd499100b1ea45
1 /*
2 * Copyright 2015, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "TableCellBoolEditor.h"
8 #include "BoolValue.h"
11 TableCellBoolEditor::TableCellBoolEditor(::Value* initialValue,
12 ValueFormatter* formatter)
14 TableCellOptionPopUpEditor(initialValue, formatter)
19 TableCellBoolEditor::~TableCellBoolEditor()
24 status_t
25 TableCellBoolEditor::ConfigureOptions()
27 BoolValue* initialValue = dynamic_cast<BoolValue*>(InitialValue());
28 if (initialValue == NULL)
29 return B_BAD_VALUE;
31 status_t error = AddOption("true", true);
32 if (error != B_OK)
33 return error;
35 error = AddOption("false", false);
36 if (error != B_OK)
37 return error;
39 return SelectOptionFor(initialValue->GetValue());
43 status_t
44 TableCellBoolEditor::GetSelectedValue(::Value*& _value) const
46 const char* name = NULL;
47 int32 selectedValue = 0;
48 SelectedOption(&name, &selectedValue);
49 BoolValue* value = new(std::nothrow) BoolValue((bool)selectedValue);
50 if (value == NULL)
51 return B_NO_MEMORY;
53 _value = value;
54 return B_OK;