DCL 3.7.4
Loading...
Searching...
No Matches
PartLink Class Reference

#include <LinkUtility.h>

Public Member Functions

 PartLink (TextTemplate *pSource, const String &strThis, const String &strLinkEnc)
void assign (TextTemplate *pDest, int nTotalPart, int nCurrentPart, int nNumberPart)

Protected Attributes

TextTemplate__pSource

Detailed Description

Definition at line 27 of file LinkUtility.h.

Constructor & Destructor Documentation

◆ PartLink()

__DCL_BEGIN_NAMESPACE PartLink::PartLink ( TextTemplate * pSource,
const String & strThis,
const String & strLinkEnc )

Definition at line 16 of file LinkUtility.cpp.

21{
22 __pSource = pSource;
23 if (__pSource) {
24 const wchar_t* aNames[] = { L"FIRST", L"PREV", L"GOTO", L"NEXT", L"LAST"};
25
26 for(int i = 0; i < 5; i++) {
27 TextTemplate* p = __pSource->atP(aNames[i]);
28 if (p) {
29 p->assign(L"THIS", strThis);
30 p->assign(L"_LIST", strLinkEnc);
31 }
32 }
33 }
34}

Member Function Documentation

◆ assign()

void PartLink::assign ( TextTemplate * pDest,
int nTotalPart,
int nCurrentPart,
int nNumberPart )

Definition at line 44 of file LinkUtility.cpp.

50{
51 __DCL_ASSERT(NULL != pDest);
52 __DCL_ASSERT(nTotalPart > 0);
53 __DCL_ASSERT(nCurrentPart > 0);
54 __DCL_ASSERT(nGotoPart > 0);
55
56 int nStartPart = nCurrentPart - ((nCurrentPart - 1) % nGotoPart);
57 int nEndPart = nStartPart + nGotoPart - 1;
58 if (nEndPart > nTotalPart)
59 nEndPart = nTotalPart;
60
61 if (nStartPart <= nGotoPart) {
62 // 1 <= nStartPart <= nGotoPart
63// __pSource->erase(L"FIRST");
64// __pSource->erase(L"PREV");
65 }
66 else {
67 TextTemplate& FIRST = (*__pSource)[L"FIRST"];
68 FIRST.assign(L"PART", __PART(1));
69 __pSource->assign(L"FIRST", FIRST);
70
71 TextTemplate& PREV = (*__pSource)[L"PREV"];
72 PREV.assign(L"PART", __PART(nStartPart - 1));
73 __pSource->assign(L"PREV", PREV);
74 }
75
76 if ((nStartPart + nGotoPart) > nTotalPart) {
77// __pSource->erase(L"NEXT");
78// __pSource->erase(L"LAST");
79 }
80 else {
81 int nNext = nCurrentPart + nGotoPart - ((nCurrentPart - 1) % nGotoPart);
82
83 TextTemplate& NEXT = (*__pSource)[L"NEXT"];
84 NEXT.assign(L"PART", __PART(nNext));
85 __pSource->assign(L"NEXT", NEXT);
86
87 TextTemplate& LAST = (*__pSource)[L"LAST"];
88 LAST.assign(L"PART", __PART(nTotalPart));
89 __pSource->assign(L"LAST", LAST);
90 }
91
92 TextTemplate& GOTO = (*__pSource)[L"GOTO"];
93 TextTemplate& CURRENT = (*__pSource)[L"CURRENT"];
94// __pSource->erase(L"CURRENT");
95
96 for(int n = nStartPart; n <= nEndPart; n++) {
97 if (n == nCurrentPart) {
98 CURRENT.assign(L"NO", String::valueOf(n));
99 __pSource->append(L"GOTO", CURRENT);
100 }
101 else {
102 GOTO.assign(L"NO", String::valueOf(n));
103 GOTO.assign(L"PART", __PART(n));
104 __pSource->append(L"GOTO", GOTO);
105 }
106 }
107
108 pDest->assign(L"PART_LINK", *__pSource);
109}
#define NULL
Definition Config.h:312
#define __DCL_ASSERT(expr)
Definition Object.h:394

Member Data Documentation

◆ __pSource

TextTemplate* PartLink::__pSource
protected

Definition at line 37 of file LinkUtility.h.


The documentation for this class was generated from the following files: