27 #include "../../../../dataaccess/dataset/Constraint.h" 28 #include "../../common/Utils.h" 32 #include <boost/cstdint.hpp> 38 if(args.Holder().IsEmpty())
39 return ::v8::ThrowException(::v8::String::New(
"In order to use the getId method, you must use the object notation: \"id = obj.getId();\""));
44 return ::v8::ThrowException(::v8::String::New(
"Invalid constraint in the getId method!"));
46 unsigned int id = c->
getId();
48 ::v8::Local<::v8::Integer> jid = ::v8::Uint32::New(static_cast<boost::uint32_t>(
id));
57 if(args.Holder().IsEmpty())
58 return ::v8::ThrowException(::v8::String::New(
"In order to use setId method, you must use the object notation: \"obj.setId();\""));
63 return ::v8::ThrowException(::v8::String::New(
"Invalid id in setId method!"));
65 if((args.Length() != 1) || args[0].IsEmpty() || !args[0]->IsUint32())
66 return ::v8::ThrowException(::v8::String::New(
"Invalid id in setId method!"));
68 unsigned int id = args[0]->ToUint32()->Value();
71 return hs.Close(::v8::Undefined());
78 if(args.Holder().IsEmpty())
79 return ::v8::ThrowException(::v8::String::New(
"In order to use the getName method you must use the object notation: \"name = obj.getName();\""));
84 return ::v8::ThrowException(::v8::String::New(
"Invalid constraint in the getName method!"));
86 const std::string& name = c->
getName();
88 ::v8::Local<::v8::String> jname = ::v8::String::New(name.c_str());
90 return hs.Close(jname);
95 if(args.Length() != 1 || args[0].IsEmpty() || args.Holder().IsEmpty())
96 return ::v8::ThrowException(::v8::String::New(
"In order to use the setName method, you must use the object notation: \"obj.setName(\"name\");\""));
101 return ::v8::ThrowException(::v8::String::New(
"Invalid constraint in the setName method!"));
103 v8::String::Utf8Value jconnStr(args[0]->
ToString());
107 return ::v8::Undefined();
112 return ::v8::Undefined();
117 return ::v8::Undefined();
122 ::v8::HandleScope hs;
124 if(args.Holder().IsEmpty())
125 return ::v8::ThrowException(::v8::String::New(
"In order to use the getType method you must use the object notation: \"t = obj.getType();\""));
130 return ::v8::ThrowException(::v8::String::New(
"Invalid constraint in the getType method!"));
134 ::v8::Local<::v8::Integer> jtype = ::v8::Integer::New(static_cast<boost::int32_t>(type));
136 return hs.Close(jtype);
141 return ::v8::Undefined();
150 ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
152 ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
154 prototype->Set(::v8::String::NewSymbol(
"getId"), ::v8::FunctionTemplate::New(
Constraint_GetId));
155 prototype->Set(::v8::String::NewSymbol(
"setId"), ::v8::FunctionTemplate::New(
Constraint_SetId));
156 prototype->Set(::v8::String::NewSymbol(
"getName"), ::v8::FunctionTemplate::New(
Constraint_GetName));
157 prototype->Set(::v8::String::NewSymbol(
"setName"), ::v8::FunctionTemplate::New(
Constraint_SetName));
160 prototype->Set(::v8::String::NewSymbol(
"getType"), ::v8::FunctionTemplate::New(
Constraint_GetType));
161 prototype->Set(::v8::String::NewSymbol(
"clone"), ::v8::FunctionTemplate::New(
Constraint_Clone));
virtual void setName(const std::string &name)
It sets the constraint name.
::v8::Handle<::v8::Value > Constraint_GetDataSetType(const ::v8::Arguments &)
::v8::Handle<::v8::Value > Constraint_SetId(const ::v8::Arguments &args)
JavaScript exporting routine for the TerraLib Data Access module.
::v8::Handle<::v8::Value > Constraint_GetType(const ::v8::Arguments &args)
virtual void setId(unsigned int id)
It sets the constraint identifier.
::v8::Handle<::v8::Value > Constraint_Clone(const ::v8::Arguments &)
::v8::Handle<::v8::Value > Constraint_GetId(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Constraint_SetName(const ::v8::Arguments &args)
ConstraintType
A ConstraintType can have one of the following types:
virtual ConstraintType getType() const =0
It returns the constraint type.
virtual unsigned int getId() const
It returns the constraint identifier.
::v8::Handle<::v8::Value > Constraint_SetDataSetType(const ::v8::Arguments &)
::v8::Persistent<::v8::FunctionTemplate > & GetConstraintTemplate()
It returns a reference to the persistent template of a Constraint object.
::v8::Handle<::v8::Value > Constraint_GetName(const ::v8::Arguments &args)
virtual const std::string & getName() const
It returns the constraint name.
static::v8::Persistent<::v8::FunctionTemplate > sg_constraint_template
std::string ToString(const XMLCh *const value)
It converts the XML string to a standard C++ string.