headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / servers / app / benchmark / DrawingModeToString.cpp
blob6defb06878bf2085016b5376b17a9cb1c5e6e7fe
1 /*
2 * Copyright (C) 2009 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
4 */
6 #include "DrawingModeToString.h"
8 #include <string.h>
11 struct DrawingModeString {
12 const char* string;
13 drawing_mode mode;
17 static const DrawingModeString kDrawingModes[] = {
18 { "B_OP_COPY", B_OP_COPY },
19 { "B_OP_OVER", B_OP_OVER },
20 { "B_OP_ERASE", B_OP_ERASE },
21 { "B_OP_INVERT", B_OP_INVERT },
22 { "B_OP_ADD", B_OP_ADD },
23 { "B_OP_SUBTRACT", B_OP_SUBTRACT },
24 { "B_OP_BLEND", B_OP_BLEND },
25 { "B_OP_MIN", B_OP_MIN },
26 { "B_OP_MAX", B_OP_MAX },
27 { "B_OP_SELECT", B_OP_SELECT },
28 { "B_OP_ALPHA", B_OP_ALPHA }
32 bool ToDrawingMode(const char* string, drawing_mode& mode)
34 int entries = sizeof(kDrawingModes) / sizeof(DrawingModeString);
35 for (int32 i = 0; i < entries; i++) {
36 if (strcmp(kDrawingModes[i].string, string) == 0) {
37 mode = kDrawingModes[i].mode;
38 return true;
41 return false;
45 bool ToString(drawing_mode mode, const char*& string)
47 int entries = sizeof(kDrawingModes) / sizeof(DrawingModeString);
48 for (int32 i = 0; i < entries; i++) {
49 if (kDrawingModes[i].mode == mode) {
50 string = kDrawingModes[i].string;
51 return true;
54 return false;