Skip to content

Commit

Permalink
equals operate
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jun 10, 2017
1 parent 56c0f95 commit 0571138
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ link_directories(${PHP_LDFLAGS})
include_directories(include)
include_directories(BEFORE ${PHP_INCLUDE_DIR} ${PHP_INCLUDE_DIR}/Zend ${PHP_INCLUDE_DIR}/main ${PHP_INCLUDE_DIR}/TSRM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

IF (APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
message(${CMAKE_SHARED_LINKER_FLAGS})
ENDIF ()

#libary
add_library(phpx SHARED ${DIR_SRCS})

#install
INSTALL(CODE "MESSAGE(\"Are you run command using root user?\")")
INSTALL(TARGETS phpx LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
INSTALL(FILES ${HEADER_FILES} DESTINATION include)
INSTALL(FILES ${HEADER_FILES} DESTINATION include)
58 changes: 53 additions & 5 deletions include/phpx.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,50 @@ class Variant
}
return static_cast<T *>(_ptr);
}
bool operator ==(Variant &v)
{
return equals(v);
}
bool operator ==(bool v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(int v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(long v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(float v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(double v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(nullptr_t v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(string &v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(const char *v)
{
Variant _tmp(v);
return equals(_tmp);
}
bool equals(Variant &v, bool strict = false)
{
if (strict)
Expand Down Expand Up @@ -455,6 +499,10 @@ class String
}
return memcmp(str.c_str(), value->val, value->len) == 0;
}
inline bool operator ==(String &v)
{
return equals(v);
}
bool equals(String &str, bool ci = false)
{
if (str.length() != value->len)
Expand Down Expand Up @@ -1387,11 +1435,11 @@ typedef void (*resource_dtor)(zend_resource *);
typedef void (*method_t)(Object &, Args &, Variant &retval);

struct strCmp
{
bool operator()( const char * s1, const char * s2 ) const
{
return strcmp( s1, s2 ) < 0;
}
{
bool operator()( const char * s1, const char * s2 ) const
{
return strcmp( s1, s2 ) < 0;
}
};

extern map<const char *, map<const char *, method_t, strCmp>, strCmp> method_map;
Expand Down

0 comments on commit 0571138

Please sign in to comment.