File: MGRTObject.cpp

package info (click to toggle)
mysql-admin 1.2.5rc-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 80,944 kB
  • ctags: 43,103
  • sloc: sql: 295,916; pascal: 256,535; cpp: 74,487; ansic: 68,881; objc: 26,417; sh: 16,867; yacc: 10,755; java: 9,917; xml: 8,453; php: 2,806; python: 2,068; makefile: 1,252; perl: 3
file content (112 lines) | stat: -rw-r--r-- 2,086 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 *  MGRTObject.cpp
 *  MySQL GRT
 *
 *  Created by Alfredo Kojima on 05/8/17.
 *  Copyright 2005 MySQL AB. All rights reserved.
 *
 */

#include "MGRTObject.h"


MGRTObject::MGRTObject(MYX_GRT *grt, MYX_GRT_VALUE *object)
: _grt(grt), _original(object), _object(myx_grt_value_dup(object))
{
  myx_grt_value_release(_object.grtValue());
}

MGRTObject::~MGRTObject()
{
}




MGRTValue MGRTObject::ownerSchema()
{
  return lookupObject(_object["owner"].asString());
}


MGRTValue MGRTObject::ownerCatalog()
{
  MGRTValue schema(ownerSchema());
  if (schema.isValid())
    return lookupObject(schema["owner"].asString());
  else
    return schema;
}


MGRTValue MGRTObject::lookupObject(const char *typeId)
{
  return MGRTValue(myx_grt_reference_cache_lookup(_grt, typeId));
}


void MGRTObject::revert()
{
  _object.assign(MGRTValue(myx_grt_value_dup(_original.grtValue())));
  myx_grt_value_release(_object.grtValue());
}


void MGRTObject::commit()
{
  MYX_GRT_VALUE *diff;
  
  diff= myx_grt_value_diff_make(_grt, _original.grtValue(), _object.grtValue());
  
  myx_grt_value_diff_apply(_grt, _original.grtValue(), diff);
  
  myx_grt_value_release(diff);
}

const char *MGRTObject::name() const
{
  return _object["name"].asString();
}

void MGRTObject::setName(const char *name)
{
  _object.set("name", name);
}


const char *MGRTObject::comment() const
{
  return _object["comment"].asString();
}


void MGRTObject::setComment(const char *comment)
{
  _object.set("comment", comment);
}

/*
std::vector<const char*>MGRTObject::getCollations()
{
  std::vector<const char*> collations;
  MGRTValue catalog(ownerCatalog());
  if (catalog.isValid())
  {
    MGRTValue charsets(catalog["characterSets"]);
    if (charsets.isValid())
    {
      int i, c= charsets.count();
      
      for (i= 0; i < c; i++)
      {
        MGRTValue chs(MGRTValue::refObject(_grt, charsets[i].asString()));    
        MGRTValue colls(chs["collations"]);
        for (int j= 0; j < colls.count(); j++)
          collations.push_back(colls[j].asString());
      }
    }
  }
  return collations;
}

*/