-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathFormatFunc.cpp
More file actions
executable file
·67 lines (51 loc) · 933 Bytes
/
FormatFunc.cpp
File metadata and controls
executable file
·67 lines (51 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include "stdafx.h"
#include "Lua.h"
#include <sstream>
extern void FormatName(const std::string& s, Lua::ValType type, std::string& out)
{
std::ostringstream ost;
ost << s;
switch (type)
{
case Lua::Function:
ost << "()";
break;
//case Lua::String:
// ost << "$";
// break;
case Lua::Table:
ost << " { }";
break;
//case Lua::LightUserData:
// ost << "()";
// break;
default:
break;
}
// enum ValType { None= -1, Nil, Bool, LightUserData, Number, String, Table, Function, UserData, Thread };
out = ost.str();
}
extern void FormatValue(const std::string& s, Lua::ValType type, std::string& out)
{
std::ostringstream ost;
switch (type)
{
case Lua::String:
ost << '"' << s << '"';
break;
case Lua::Nil:
ost << "nil";
break;
case Lua::None:
ost << '?';
break;
case Lua::Function:
ost << "fn " << s;
break;
default:
out = s;
return;
}
out = ost.str();
}