From 88637db0efc1dc56e34627e71e26cc5aab5dc803 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 27 Mar 2017 15:08:19 +0300 Subject: Move StackVarEnumToString to and use in a SAL_INFO Once StackVarEnum has been changed to a scoped enum, we should probably add an operator<< for it, too. Is 'std::string FooToString(Foo e)' a good return type, signature, and naming pattern for functions to turn enums into strings? Would return type OUString be better? Is there some consistent existing convention? For use only in SAL_INFO and friends, probably just an operator<< is enough? Change-Id: I89abbcb37ba2ab925b0a9d7fc6294d8f9ee5aebd --- include/formula/token.hxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'include/formula') diff --git a/include/formula/token.hxx b/include/formula/token.hxx index 7b6e1a77a6b8..8747517ac481 100644 --- a/include/formula/token.hxx +++ b/include/formula/token.hxx @@ -88,6 +88,38 @@ typedef sal_uInt8 StackVar; typedef StackVarEnum StackVar; #endif +inline std::string StackVarEnumToString(StackVar const e) +{ + switch (e) + { + case svByte: return "Byte"; + case svDouble: return "Double"; + case svString: return "String"; + case svSingleRef: return "SingleRef"; + case svDoubleRef: return "DoubleRef"; + case svMatrix: return "Matrix"; + case svIndex: return "Index"; + case svJump: return "Jump"; + case svExternal: return "External"; + case svFAP: return "FAP"; + case svJumpMatrix: return "JumpMatrix"; + case svRefList: return "RefList"; + case svEmptyCell: return "EmptyCell"; + case svMatrixCell: return "MatrixCell"; + case svHybridCell: return "HybridCell"; + case svExternalSingleRef: return "ExternalSingleRef"; + case svExternalDoubleRef: return "ExternalDoubleRef"; + case svExternalName: return "ExternalName"; + case svSingleVectorRef: return "SingleVectorRef"; + case svDoubleVectorRef: return "DoubleVectorRef"; + case svError: return "Error"; + case svMissing: return "Missing"; + case svSep: return "Sep"; + case svUnknown: return "Unknown"; + } + return std::to_string(static_cast(e)); +} + class FORMULA_DLLPUBLIC FormulaToken : public IFormulaToken { OpCode eOp; -- cgit