Fission FSN
Loading...
Searching...
No Matches
fsNCoreUtils.h
Go to the documentation of this file.
1/********************************************************************
2*
3* Created: 19/2/2014 10:46
4*
5* File: fsNCoreUtils.h
6*
7* Author: Mick Waites
8*
9* Purpose:
10*
11*********************************************************************/
12
13#ifndef fsNCoreUtilshdr
14#define fsNCoreUtilshdr
15
16#include <algorithm>
17#include <map>
18
19#include "../fsStr.h"
20
21#define CALL_MEMBER_FNC(object, ptrToMember) ((object)->*(ptrToMember))
22
23namespace fsNCoreUtils
24{
26 void unicodeCharCopy(fsStr pSrcText, fsStr& pDestText, fsS32& pCurrentPos);
27
28 template <class valType>
29 void
30 clamp(valType& pVal, valType pMin, valType pMax)
31 {
32 if (pVal > pMax)
33 {
34 pVal = pMax;
35 }
36 else if (pVal < pMin)
37 {
38 pVal = pMin;
39 }
40 }
41
43 {
44 template <typename T>
45 void operator()(const T* pPtr) const
46 {
47 delete pPtr;
48 }
49 };
50
52 {
53 public:
54 template <typename T>
55 void operator()(const T& pPair) const
56 {
57 delete pPair.second;
58 }
59 };
60
61 // Use if value is pointer to which we are responsible for deleting
62 template <class keyType, class pointerType>
63 void clearMapOfValuePtrs(std::map<keyType, pointerType>& pMapToTrash)
64 {
65 std::for_each(pMapToTrash.begin(), pMapToTrash.end(), fsCFncDeletePairSecond());
66 pMapToTrash.clear();
67 }
68
69 template <class T>
70 void clearSequenceContainerOfPtrs(T& pContainerToTrash)
71 {
72 std::for_each(pContainerToTrash.begin(), pContainerToTrash.end(), fsFncDeleteObject());
73 pContainerToTrash.clear();
74 }
75};
76
77#endif
Definition fsNCoreUtils.h:52
void operator()(const T &pPair) const
Definition fsNCoreUtils.h:55
Definition fsStr.h:23
unsigned int fsU32
Definition fsBaseTypes.h:21
int fsS32
Definition fsBaseTypes.h:20
char fsChar
Definition fsBaseTypes.h:12
Definition fsNCoreUtils.cpp:8
void clamp(valType &pVal, valType pMin, valType pMax)
Definition fsNCoreUtils.h:30
fsU32 unicodeExtraCharacterCountGet(const fsChar pChar)
Definition fsNCoreUtils.cpp:9
void clearSequenceContainerOfPtrs(T &pContainerToTrash)
Definition fsNCoreUtils.h:70
void clearMapOfValuePtrs(std::map< keyType, pointerType > &pMapToTrash)
Definition fsNCoreUtils.h:63
void unicodeCharCopy(fsStr pSrcText, fsStr &pDestText, fsS32 &pCurrentPos)
Definition fsNCoreUtils.cpp:21
Definition fsNCoreUtils.h:43
void operator()(const T *pPtr) const
Definition fsNCoreUtils.h:45