00001 /* 00002 * File Name: search_criteria_impl.cpp 00003 */ 00004 00005 /* 00006 * This file is part of uds-plugin-plaintext. 00007 * 00008 * uds-plugin-plaintext is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * uds-plugin-plaintext is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 /** 00023 * Copyright (C) 2008 iRex Technologies B.V. 00024 * All rights reserved. 00025 */ 00026 00027 #include "search_criteria_impl.h" 00028 00029 namespace text 00030 { 00031 00032 utils::ObjectTable<PluginSearchCriteria> 00033 PluginSearchCriteria::g_instances_table; 00034 00035 PluginSearchCriteria::PluginSearchCriteria(void) 00036 { 00037 // IPluginUnkown 00038 query_interface = query_interface_impl; 00039 release = release_impl; 00040 00041 // IPluginSearchCriteria 00042 set_search_text = set_search_text_impl; 00043 set_case_sensitive = set_case_sensitive_impl; 00044 set_match_whole_word = set_match_whole_word_impl; 00045 set_forward = set_forward_impl; 00046 00047 g_instances_table.add_interface<IPluginUnknown>(this); 00048 g_instances_table.add_interface<IPluginSearchCriteria>(this); 00049 } 00050 00051 PluginSearchCriteria::~PluginSearchCriteria(void) 00052 { 00053 g_instances_table.remove(this); 00054 } 00055 00056 PluginStatus 00057 PluginSearchCriteria::query_interface_impl(IPluginUnknown *thiz, 00058 const UDSString *id, 00059 void **ptr ) 00060 { 00061 // check object. 00062 PluginSearchCriteria *instance = g_instances_table.get_object(thiz); 00063 00064 // check interface. 00065 if (g_instances_table.query_interface(instance, id->get_buffer(id), ptr)) 00066 { 00067 return PLUGIN_OK; 00068 } 00069 return PLUGIN_FAIL; 00070 } 00071 00072 int PluginSearchCriteria::release_impl(IPluginUnknown *thiz ) 00073 { 00074 // check object. 00075 PluginSearchCriteria *instance = g_instances_table.get_object(thiz); 00076 delete instance; 00077 return PLUGIN_OK; 00078 } 00079 00080 /// IPluginSearchCriteria 00081 PluginStatus 00082 PluginSearchCriteria::set_search_text_impl(IPluginUnknown *thiz, 00083 const UDSString *text ) 00084 { 00085 PluginSearchCriteria *instance = g_instances_table.get_object(thiz); 00086 instance->sc.pattern = text->get_buffer(text); 00087 return PLUGIN_OK; 00088 } 00089 00090 PluginStatus 00091 PluginSearchCriteria::set_case_sensitive_impl(IPluginUnknown *thiz, 00092 const PluginBool is_sensitive ) 00093 { 00094 PluginSearchCriteria *instance = g_instances_table.get_object(thiz); 00095 instance->sc.case_sensitive = (is_sensitive == PLUGIN_TRUE); 00096 return PLUGIN_OK; 00097 } 00098 00099 PluginStatus 00100 PluginSearchCriteria::set_match_whole_word_impl(IPluginUnknown *thiz, 00101 const PluginBool do_match_word ) 00102 { 00103 PluginSearchCriteria *instance = g_instances_table.get_object(thiz); 00104 instance->sc.match_whole_word = (do_match_word == PLUGIN_TRUE); 00105 return PLUGIN_OK; 00106 } 00107 00108 PluginStatus 00109 PluginSearchCriteria::set_forward_impl(IPluginUnknown *thiz, 00110 const PluginBool do_search_forward ) 00111 { 00112 PluginSearchCriteria *instance = g_instances_table.get_object(thiz); 00113 instance->sc.forward = (do_search_forward == PLUGIN_TRUE); 00114 return PLUGIN_OK; 00115 } 00116 00117 } // namespace text 00118