Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ashish 1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements. See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership. The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License. You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied. See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19
 
20
#ifndef T_OOP_GENERATOR_H
21
#define T_OOP_GENERATOR_H
22
 
23
#include <string>
24
#include <iostream>
25
 
26
#include "globals.h"
27
#include "t_generator.h"
28
 
29
#include <algorithm>
30
 
31
/**
32
 * Class with utility methods shared across common object oriented languages.
33
 * Specifically, most of this stuff is for C++/Java.
34
 *
35
 */
36
class t_oop_generator : public t_generator {
37
 public:
38
  t_oop_generator(t_program* program) :
39
    t_generator(program) {}
40
 
41
  /**
42
   * Scoping, using curly braces!
43
   */
44
 
45
  void scope_up(std::ostream& out) {
46
    indent(out) << "{" << std::endl;
47
    indent_up();
48
  }
49
 
50
  void scope_down(std::ostream& out) {
51
    indent_down();
52
    indent(out) << "}" << std::endl;
53
  }
54
 
55
  std::string upcase_string(std::string original) {
56
    std::transform(original.begin(), original.end(), original.begin(), (int(*)(int)) toupper);
57
    return original;
58
  }
59
 
60
  /**
61
   * Generates a comment about this code being autogenerated, using C++ style
62
   * comments, which are also fair game in Java / PHP, yay!
63
   *
64
   * @return C-style comment mentioning that this file is autogenerated.
65
   */
66
  virtual std::string autogen_comment() {
67
    return
68
      std::string("/**\n") +
69
      " * Autogenerated by Thrift\n" +
70
      " *\n" +
71
      " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
72
      " */\n";
73
  }
74
};
75
 
76
#endif
77