OSDN Git Service

initial files
[iptd/iPTd_R3.git] / src / Raym / Dictionary.h
1 //
2 // Dictionary.h
3 //
4
5 #pragma once
6
7 #include <vector>
8
9 #include <Raym/Object.h>
10 #include <Raym/String.h>
11 #include <Raym/Array.h>
12 #include <Raym/Number.h>
13 //#include <Raym/URL.h>
14
15 namespace Raym
16 {
17
18 class Dictionary : public Object
19 {
20 protected:
21     Dictionary();
22     ~Dictionary();
23
24     class KeyAndValue : public Object
25     {
26     protected:
27         KeyAndValue();
28         ~KeyAndValue();
29         String *    _key;
30         Object *    _value;
31     public:
32         static KeyAndValue *keyAndValue(String *key, Object *value);
33         String *key();
34         Object *value();
35
36         virtual const char *className();
37     };
38
39     std::vector<Object *> _dict;
40
41
42 //    static Dictionary *dictionaryWithData(Data *data, StringEncoding encoding);
43 //    static Array *arrayWithData(Data *data, StringEncoding encoding);
44
45     void writeTo(int fd, int level);
46     void writeValue(int fd, int level, Object *value);
47
48     std::string toString(int level);
49     std::string toStringValue(int level, Object *value);
50
51 public:
52     //
53     static Dictionary *dictionaryWithCapacity(UInteger numItems);
54     static Dictionary *dictionaryWithDictionary(Dictionary *dictionary);
55 //    static Dictionary *dictionaryWithContentsOfURL(URL *url);
56     static Dictionary *alloc();
57     Dictionary *initWithCapacity(UInteger numItems);
58     Dictionary *initWithDictionary(Dictionary *dictionary);
59     Dictionary *initWithContentsOfFile(String *path);
60     Dictionary *initWithContentsOfFile(const char *path);
61     Dictionary *retain();
62     Dictionary *autorelease();
63
64     void setObject(Object *object, String *forKey);
65     Object *objectForKey(String *key);
66     void removeObjectForKey(String *key);
67     void removeObjectForKey(const char *key);
68
69     void setObject(Object *object, const char *forKey);
70     Object *objectForKey(const char *key);
71     void setString(String *string, const char *forKey);
72     void setString(const char *string, const char *forKey);
73     String *stringForKey(String *key);
74     String *stringForKey(const char *key);
75     void setInteger(int value, String *key);
76     void setInteger(int value, const char *key);
77     int integerForKey(String *key);
78     int integerForKey(const char *key);
79     Dictionary *dictionaryForKey(String *key);
80     Dictionary *dictionaryForKey(const char *key);
81     Array *arrayForKey(String *key);
82     Array *arrayForKey(const char *key);
83     void setBool(bool value, String *key);
84     void setBool(bool value, const char *key);
85     bool boolForKey(String *key);
86     bool boolForKey(const char *key);
87
88     Array *allKeys();
89     UInteger count();
90
91     bool writeToFile(String *path, bool atomically);
92     bool writeToFile(const char *path, bool atomically);
93
94     std::string toString();
95
96 //    virtual String *description();
97     virtual const char *className();
98 };
99
100 } // Raym
101