| 1 |
#ifndef TOMBOURI_H |
| 2 |
#define TOMBOURI_H |
| 3 |
|
| 4 |
///////////////////////////////////////////// |
| 5 |
// Notes path information |
| 6 |
///////////////////////////////////////////// |
| 7 |
|
| 8 |
class TomboURI { |
| 9 |
int nMaxPathItem; |
| 10 |
|
| 11 |
SharedString uri; |
| 12 |
|
| 13 |
friend class TomboURITest; |
| 14 |
public: |
| 15 |
/////////////////////////////// |
| 16 |
// ctor, dtor and initializer |
| 17 |
TomboURI(); |
| 18 |
TomboURI(const TomboURI&); |
| 19 |
~TomboURI(); |
| 20 |
|
| 21 |
BOOL Init(LPCTSTR pURI); |
| 22 |
BOOL Init(const TomboURI&); |
| 23 |
BOOL InitByNotePath(LPCTSTR pRepoName, LPCTSTR pNotePath); |
| 24 |
|
| 25 |
/////////////////////////////// |
| 26 |
// accessor |
| 27 |
|
| 28 |
BOOL GetRepositoryName(TString *pRepo) const; |
| 29 |
|
| 30 |
// get full path of URI. |
| 31 |
LPCTSTR GetFullURI() const { return uri.Get(); } |
| 32 |
|
| 33 |
// get path part of URI. |
| 34 |
// ex. tombo://default/aa/bb/cc.txt -> /aa/bb/cc.txt |
| 35 |
LPCTSTR GetPath() const; |
| 36 |
|
| 37 |
// get parent path of URI. |
| 38 |
// ex. tombo://default/aa/bb/cc.txt -> tombo://default/aa/bb/ |
| 39 |
// tombo://default/aa/bb/ -> tombo://default/aa/ |
| 40 |
// tombo://default/ -> tombo://default/ |
| 41 |
BOOL GetParent(TomboURI *pParent) const; |
| 42 |
|
| 43 |
BOOL GetAttachFolder(TomboURI *pAttach) const; |
| 44 |
|
| 45 |
DWORD GetMaxPathItem() const { return nMaxPathItem; } |
| 46 |
|
| 47 |
// get last 1 item from URI. |
| 48 |
// ex. tombo://default/aa/bb/cc.txt -> cc.txt |
| 49 |
// tombo://default/aa/bb/cc/ -> cc |
| 50 |
BOOL GetBaseName(TString *pBase) const; |
| 51 |
|
| 52 |
// Is the URI point to leaf node? |
| 53 |
// Checking does only to URI string. Not confirm to repository. |
| 54 |
BOOL IsLeaf() const; |
| 55 |
|
| 56 |
// Is the URI point to root node? |
| 57 |
BOOL IsRoot() const; |
| 58 |
|
| 59 |
// Get path string |
| 60 |
// This method will be obsoleted in future version. |
| 61 |
// ex. tombo://default/aaa/bbb/ccc.txt -> aaa\bbb\ccc.txt |
| 62 |
BOOL GetFilePath(TString *pPath) const; |
| 63 |
|
| 64 |
|
| 65 |
/////////////////////////////// |
| 66 |
// helper functions |
| 67 |
static LPCTSTR GetNextSep(LPCTSTR p); |
| 68 |
|
| 69 |
TomboURI &operator=(const TomboURI &uri); |
| 70 |
}; |
| 71 |
|
| 72 |
///////////////////////////////////////////// |
| 73 |
// path item iterator |
| 74 |
///////////////////////////////////////////// |
| 75 |
|
| 76 |
class TomboURIItemIterator { |
| 77 |
const TomboURI *pURI; |
| 78 |
LPTSTR pBuf; |
| 79 |
DWORD nPos; |
| 80 |
public: |
| 81 |
|
| 82 |
/////////////////////////////// |
| 83 |
// ctor, dtor and initializer |
| 84 |
TomboURIItemIterator(const TomboURI *p) : pURI(p), pBuf(NULL) {} |
| 85 |
~TomboURIItemIterator() { if (pBuf) delete[] pBuf; } |
| 86 |
BOOL Init(); |
| 87 |
|
| 88 |
/////////////////////////////// |
| 89 |
// iteration methods |
| 90 |
void First(); |
| 91 |
LPCTSTR Current(); |
| 92 |
void Next(); |
| 93 |
|
| 94 |
/////////////////////////////// |
| 95 |
// May current item have child? |
| 96 |
BOOL IsLeaf(); |
| 97 |
}; |
| 98 |
|
| 99 |
#endif |